1313import shutil
1414
1515from wes_service .util import visit , WESBackend
16- from werkzeug .utils import secure_filename
1716
1817
1918class MissingAuthorization (Exception ):
@@ -81,7 +80,7 @@ def GetServiceInfo(self):
8180 }
8281
8382 @catch_exceptions
84- def ListWorkflows (self , page_size = None , page_token = None , tag_search = None , state_search = None ):
83+ def ListRuns (self , page_size = None , page_token = None , state_search = None ):
8584 api = get_api ()
8685
8786 paging = []
@@ -100,13 +99,13 @@ def ListWorkflows(self, page_size=None, page_token=None, tag_search=None, state_
10099
101100 uuidmap = {c ["uuid" ]: statemap [c ["state" ]] for c in containers }
102101
103- workflow_list = [{"workflow_id " : cr ["uuid" ],
102+ workflow_list = [{"run_id " : cr ["uuid" ],
104103 "state" : uuidmap .get (cr ["container_uuid" ])}
105104 for cr in requests
106105 if cr ["command" ] and cr ["command" ][0 ] == "arvados-cwl-runner" ]
107106 return {
108107 "workflows" : workflow_list ,
109- "next_page_token" : workflow_list [- 1 ]["workflow_id " ] if workflow_list else ""
108+ "next_page_token" : workflow_list [- 1 ]["run_id " ] if workflow_list else ""
110109 }
111110
112111 def invoke_cwl_runner (self , cr_uuid , workflow_url , workflow_params ,
@@ -156,23 +155,10 @@ def invoke_cwl_runner(self, cr_uuid, workflow_url, workflow_params,
156155 workflow_descriptor_file .close ()
157156
158157 @catch_exceptions
159- def RunWorkflow (self , workflow_params , workflow_type , workflow_type_version ,
160- workflow_url , workflow_descriptor , workflow_engine_parameters = None , tags = None ):
161- tempdir = tempfile .mkdtemp ()
162- body = {}
163- for k , ls in connexion .request .files .iterlists ():
164- for v in ls :
165- if k == "workflow_descriptor" :
166- filename = secure_filename (v .filename )
167- v .save (os .path .join (tempdir , filename ))
168- elif k in ("workflow_params" , "tags" , "workflow_engine_parameters" ):
169- body [k ] = json .loads (v .read ())
170- else :
171- body [k ] = v .read ()
172- body ["workflow_url" ] = "file:///%s/%s" % (tempdir , body ["workflow_url" ])
173-
174- if body ["workflow_type" ] != "CWL" or body ["workflow_type_version" ] != "v1.0" : # NOQA
175- return
158+ def RunWorkflow (self , ** args ):
159+ tempdir , body = self .collect_attachments ()
160+
161+ print (body )
176162
177163 if not connexion .request .headers .get ('Authorization' ):
178164 raise MissingAuthorization ()
@@ -215,13 +201,13 @@ def RunWorkflow(self, workflow_params, workflow_type, workflow_type_version,
215201 project_uuid ,
216202 tempdir )).start ()
217203
218- return {"workflow_id " : cr ["uuid" ]}
204+ return {"run_id " : cr ["uuid" ]}
219205
220206 @catch_exceptions
221- def GetWorkflowLog (self , workflow_id ):
207+ def GetRunLog (self , run_id ):
222208 api = get_api ()
223209
224- request = api .container_requests ().get (uuid = workflow_id ).execute ()
210+ request = api .container_requests ().get (uuid = run_id ).execute ()
225211 if request ["container_uuid" ]:
226212 container = api .containers ().get (uuid = request ["container_uuid" ]).execute () # NOQA
227213 task_reqs = arvados .util .list_all (api .container_requests ().list , filters = [["requesting_container_uuid" , "=" , container ["uuid" ]]])
@@ -273,7 +259,7 @@ def log_object(cr):
273259 return r
274260
275261 r = {
276- "workflow_id " : request ["uuid" ],
262+ "run_id " : request ["uuid" ],
277263 "request" : {
278264 "workflow_url" : "" ,
279265 "workflow_params" : request ["mounts" ].get ("/var/lib/cwl/cwl.input.json" , {}).get ("content" , {})
@@ -287,30 +273,30 @@ def log_object(cr):
287273 return r
288274
289275 @catch_exceptions
290- def CancelJob (self , workflow_id ): # NOQA
276+ def CancelRun (self , run_id ): # NOQA
291277 api = get_api ()
292- request = api .container_requests ().update (uuid = workflow_id , body = {"priority" : 0 }).execute () # NOQA
293- return {"workflow_id " : request ["uuid" ]}
278+ request = api .container_requests ().update (uuid = run_id , body = {"priority" : 0 }).execute () # NOQA
279+ return {"run_id " : request ["uuid" ]}
294280
295281 @catch_exceptions
296- def GetWorkflowStatus (self , workflow_id ):
282+ def GetRunStatus (self , run_id ):
297283 api = get_api ()
298- request = api .container_requests ().get (uuid = workflow_id ).execute ()
284+ request = api .container_requests ().get (uuid = run_id ).execute ()
299285 if request ["container_uuid" ]:
300286 container = api .containers ().get (uuid = request ["container_uuid" ]).execute () # NOQA
301287 elif request ["priority" ] == 0 :
302288 container = {"state" : "Cancelled" }
303289 else :
304290 container = {"state" : "Queued" }
305- return {"workflow_id " : request ["uuid" ],
291+ return {"run_id " : request ["uuid" ],
306292 "state" : statemap [container ["state" ]]}
307293
308294
309- def dynamic_logs (workflow_id , logstream ):
295+ def dynamic_logs (run_id , logstream ):
310296 api = get_api ()
311- cr = api .container_requests ().get (uuid = workflow_id ).execute ()
297+ cr = api .container_requests ().get (uuid = run_id ).execute ()
312298 l1 = [t ["properties" ]["text" ]
313- for t in api .logs ().list (filters = [["object_uuid" , "=" , workflow_id ],
299+ for t in api .logs ().list (filters = [["object_uuid" , "=" , run_id ],
314300 ["event_type" , "=" , logstream ]],
315301 order = "created_at desc" ,
316302 limit = 100 ).execute ()["items" ]]
@@ -327,5 +313,5 @@ def dynamic_logs(workflow_id, logstream):
327313
328314def create_backend (app , opts ):
329315 ab = ArvadosBackend (opts )
330- app .app .route ('/ga4gh/wes/v1/workflows/<workflow_id >/x-dynamic-logs/<logstream>' )(dynamic_logs )
316+ app .app .route ('/ga4gh/wes/v1/runs/<run_id >/x-dynamic-logs/<logstream>' )(dynamic_logs )
331317 return ab
0 commit comments