Skip to content

Commit 207cf6d

Browse files
author
Peter Amstutz
committed
Handle form parameters in POST that are not attachments
1 parent 22c2d18 commit 207cf6d

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

wes_service/arvados_wes.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def invoke_cwl_runner(self, cr_uuid, workflow_url, workflow_params,
129129
})
130130

131131
try:
132-
with tempfile.NamedTemporaryFile(dir=tempdir, suffix=".json") as inputtemp:
132+
with tempfile.NamedTemporaryFile("wt", dir=tempdir, suffix=".json") as inputtemp:
133133
json.dump(workflow_params, inputtemp)
134134
inputtemp.flush()
135135

@@ -163,7 +163,7 @@ def invoke_cwl_runner(self, cr_uuid, workflow_url, workflow_params,
163163
if proc.returncode != 0:
164164
api.container_requests().update(uuid=cr_uuid, body={"priority": 0}).execute()
165165

166-
self.log_for_run(cr_uuid, stderrdata, env['ARVADOS_API_TOKEN'])
166+
self.log_for_run(cr_uuid, stderrdata.decode("utf-8"), env['ARVADOS_API_TOKEN'])
167167

168168
if tempdir:
169169
shutil.rmtree(tempdir)
@@ -212,7 +212,8 @@ def RunWorkflow(self, **args):
212212
tempdir)).start()
213213

214214
except Exception as e:
215-
self.log_for_run(cr["uuid"], str(e))
215+
logging.exception("Error")
216+
self.log_for_run(cr["uuid"], "An exception ocurred while handling your request: " + str(e))
216217
cr = api.container_requests().update(uuid=cr["uuid"],
217218
body={"container_request":
218219
{"priority": 0}}).execute()

wes_service/util.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,18 @@ def collect_attachments(self, run_id=None):
6868
body[k] = json.loads(content.decode("utf-8"))
6969
else:
7070
body[k] = v.read().decode()
71+
for k, ls in iterlists(connexion.request.form):
72+
for v in ls:
73+
if k in ("workflow_params", "tags", "workflow_engine_parameters"):
74+
body[k] = json.loads(v)
75+
else:
76+
body[k] = v
7177

72-
if ":" not in body["workflow_url"]:
73-
body["workflow_url"] = "file://%s" % os.path.join(tempdir, secure_filename(body["workflow_url"]))
74-
75-
self.log_for_run(run_id, "Using workflow_url '%s'" % body.get("workflow_url"))
78+
if "workflow_url" in body:
79+
if ":" not in body["workflow_url"]:
80+
body["workflow_url"] = "file://%s" % os.path.join(tempdir, secure_filename(body["workflow_url"]))
81+
self.log_for_run(run_id, "Using workflow_url '%s'" % body.get("workflow_url"))
82+
else:
83+
raise Exception("Missing 'workflow_url' in submission")
7684

7785
return tempdir, body

0 commit comments

Comments
 (0)