annotate gmql_rest_queries.py @ 0:c74a1c7121ec draft default tip

planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
author geco-team
date Tue, 26 Jun 2018 08:59:49 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
1 # Galaxy plugin to REST access to the GMQL services
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
2 # (Queries)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
3 # ----------------------------------------------------------------------------
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
4 # Luana Brancato, luana.brancato@mail.polimi.it
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
5 # ----------------------------------------------------------------------------
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
6
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
7 import argparse
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
8 from time import sleep
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
9
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
10 from gmql_rest_datasets import list_datasets, import_samples
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
11 from utilities import *
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
12
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
13 module_execution = 'query_exec'
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
14 module_monitor = 'query_monitor'
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
15
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
16
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
17 def check_input(query):
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
18
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
19 # Clean the input from Galaxy escape characters.
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
20
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
21 query = query.replace('__dq__', '"')
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
22 query = query.replace('__sq__', "'")
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
23 query = query.replace('__gt__', ">")
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
24 query = query.replace('__lt__', "<")
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
25 query = query.replace('__cn__', '\n')
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
26
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
27
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
28 return query
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
29
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
30
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
31 def compile_query(user, filename, query, log_file):
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
32 """Compile the given query"""
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
33
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
34 call = 'compile'
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
35
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
36 #Read query from file
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
37 with open(query, 'r') as f_in:
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
38 query_text = f_in.read()
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
39
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
40 #Check the input
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
41 query_cl = check_input(query_text)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
42
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
43
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
44 # Then ask it to be compiled
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
45 url = compose_url(module_execution, call)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
46
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
47 outcome = post(url, query_cl, user=user, content_type='text')
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
48
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
49 status = outcome['status']
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
50 message = outcome['message']
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
51 target_ds = outcome['id']
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
52
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
53 if status == 'COMPILE_SUCCESS':
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
54 with open(log_file, 'w') as f:
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
55 f.write("{status}\n{dataset}".format(status=status, dataset=target_ds))
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
56 f.close()
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
57 if status == 'COMPILE_FAILED':
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
58 with open(log_file, 'w') as f:
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
59 f.write("{status}\n{message}".format(status=status, message=message))
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
60 f.close()
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
61 stop_err("Compilation failed.\nSee log for details.")
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
62
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
63
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
64 def run_query(user, filename, query, log_file, rs_format, importResult=True):
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
65 """Run the given query. It returns an execution log and the resulting dataset."""
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
66
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
67
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
68 call = 'run'
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
69
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
70 # Read query from file
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
71 with open(query, 'r') as f_in:
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
72 query_text = f_in.read()
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
73
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
74 # Check the input
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
75 query_cl = check_input(query_text)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
76
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
77 # Then ask it to be executed
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
78
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
79 status = "NEW"
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
80
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
81 url = compose_url(module_execution, call)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
82 url = url.format(name=filename,output=rs_format)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
83
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
84 outcome = post(url, query_cl, user=user, content_type='text')
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
85
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
86 jobid = outcome['id']
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
87
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
88 while status != "SUCCESS" and status != "EXEC_FAILED" and status != "DS_CREATION_FAILED":
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
89 log = read_status(user, jobid)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
90 status = log['status']
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
91 sleep(5)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
92
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
93 message = log['message']
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
94 time = log['executionTime']
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
95
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
96 if status == "EXEC_FAILED" or status == "DS_CREATION_FAILED":
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
97 with open(log_file, 'w') as f:
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
98 f.write("{status}\n{message}\n{execTime}".format(status=status, message=message, execTime=time))
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
99 f.close()
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
100 stop_err("Execution failed.\nSee log for details")
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
101
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
102 if status == "SUCCESS":
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
103 ext_log = read_complete_log(user, jobid)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
104 job_list = ext_log['log']
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
105 jobs = ""
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
106 for j in job_list:
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
107 jobs = "{j_list}{j}\n".format(j_list=jobs, j=j)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
108
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
109 with open(log_file, 'w') as f:
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
110 f.write("{status}\n"
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
111 "{message}\n"
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
112 "{execTime}\n"
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
113 "\n"
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
114 "{jobs}\n".format(status=status, message=message, execTime=time, jobs=jobs))
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
115 f.close()
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
116
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
117 importResult = bool(importResult)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
118
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
119 if importResult:
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
120 # For now, it gets only the final result (it's easier to deal later with simple collections
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
121 # than a nested ones)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
122
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
123 ds = log['datasets'][-1]
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
124 ds_name = ds.get('name')
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
125 import_samples(user, ds_name)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
126
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
127
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
128 def read_status(user, jobid):
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
129 """Given the job id, it retrieves the status of the current operation
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
130 (as a JSON file)"""
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
131
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
132 call = 'status'
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
133
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
134 url = compose_url(module_monitor, call)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
135 url = url.format(jobid=jobid)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
136
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
137 status = get(url, user=user, response_type='json')
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
138
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
139 return status
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
140
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
141
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
142
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
143 def read_complete_log(user, jobid):
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
144 """Given the jobid, it retrieves the complete log of the latest operation
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
145 (as a JSON file)"""
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
146
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
147 call = 'log'
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
148
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
149 url = compose_url(module_monitor, call)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
150 url = url.format(jobid=jobid)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
151
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
152 log = get(url, user=user, response_type='json')
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
153
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
154 return log
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
155
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
156
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
157 def show_jobs(user, output):
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
158 """Retrieve the list of the user's jobs"""
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
159
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
160 call = 'jobs'
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
161
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
162 url = compose_url(module_monitor, call)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
163
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
164 jobs = get(url, user=user, response_type='json')
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
165
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
166 jobs_list = jobs['jobs']
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
167 jobs_out = list()
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
168
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
169 # For each job in the list retrieve the relative status info
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
170 for j in jobs_list:
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
171 job = dict()
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
172 j_id = j['id']
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
173 job.update(id=j_id)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
174 trace = read_status(user, j_id)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
175
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
176 status = trace['status']
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
177 if status == 'SUCCESS' :
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
178 job.update(message=trace['message'],
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
179 status=status,
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
180 ds=trace['datasets'][0]['name'],
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
181 time=trace['executionTime'])
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
182 else :
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
183 job.update(message=trace['message'],
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
184 status=status,
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
185 ds=trace['datasets'][0]['name'])
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
186
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
187 jobs_out.append(job)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
188
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
189 with open(output, 'w') as f:
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
190 for j in jobs_out:
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
191 f.write("{jobid}\t"
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
192 "{status}\t"
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
193 "{message}\t"
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
194 "{ds}\t"
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
195 "{time}\n".format(jobid=j.get('id'), status=j.get('status'), message=j.get('message'),
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
196 ds=j.get('ds'),time=j.get('time')))
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
197 f.close()
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
198
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
199 def stop_query(user,jobid,output) :
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
200 """Stop the execution of the given job"""
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
201
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
202 call = 'stop'
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
203
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
204 url = compose_url(module_monitor, call)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
205 url = url.format(jobid=jobid)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
206
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
207 outcome = get(url, user=user, response_type='json')
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
208
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
209 with open(output,'w') as f_out :
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
210 json.dump(outcome, f_out)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
211
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
212
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
213
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
214 def stop_err(msg):
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
215 sys.stderr.write("%s\n" % msg)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
216
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
217
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
218 def __main__():
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
219 parser = argparse.ArgumentParser()
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
220 parser.add_argument("-user")
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
221 parser.add_argument("-cmd")
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
222 parser.add_argument("-name")
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
223 parser.add_argument("-query")
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
224 parser.add_argument("-queryNew")
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
225 parser.add_argument("-queryLocal")
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
226 parser.add_argument("-log")
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
227 parser.add_argument("-job")
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
228 parser.add_argument("-format")
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
229 parser.add_argument("-importFlag")
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
230 parser.add_argument("-add_output")
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
231
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
232
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
233 args = parser.parse_args()
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
234
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
235 if args.cmd == 'compile':
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
236 compile_query(args.user, args.name, args.query, args.log)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
237 if args.cmd == 'execute':
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
238 run_query(args.user, args.name, args.query, args.log, args.format, args.importFlag)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
239 list_datasets(args.user,args.add_output)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
240 if args.cmd == 'jobs':
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
241 show_jobs(args.user, args.log)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
242 if args.cmd == 'stop' :
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
243 stop_query(args.user, args.job, args.log)
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
244
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
245
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
246 if __name__ == "__main__":
c74a1c7121ec planemo upload for repository https://github.com/lu-brn/gmql-galaxy commit 953ee36ceda5814dc9baa03427bc0eb4ee2e93bd-dirty
geco-team
parents:
diff changeset
247 __main__()