Skip to content

Commit 65571a4

Browse files
authored
Merge pull request #69 from common-workflow-language/form-params
Handle form parameters in POST that are not attachments
2 parents 22c2d18 + b236857 commit 65571a4

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
'future',
2727
'connexion==1.4.2',
2828
'ruamel.yaml >= 0.12.4, <= 0.15.77',
29-
'cwlref-runner==1.0',
30-
'schema-salad >= 3.0, < 3.1',
29+
'schema-salad',
3130
'subprocess32==3.5.2'
3231
],
3332
entry_points={
3433
'console_scripts': ["wes-server=wes_service.wes_service_main:main",
3534
"wes-client=wes_client.wes_client_main:main"]
3635
},
3736
extras_require={
37+
"cwltool": ['cwlref-runner'],
3838
"arvados": ["arvados-cwl-runner"
3939
],
4040
"toil": ["toil[all]==3.18.0"

test/test_integration.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import logging
1010
import sys
1111
import requests
12+
import pytest
1213

1314
pkg_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) # noqa
1415
sys.path.insert(0, pkg_root) # noqa
@@ -180,6 +181,7 @@ def setUp(self):
180181
self.wes_server_process = subprocess.Popen(
181182
['python', os.path.abspath('wes_service/wes_service_main.py'),
182183
'--backend=wes_service.cwl_runner',
184+
'--opt', 'runner=cwltool',
183185
'--port=8080',
184186
'--debug'])
185187
time.sleep(5)
@@ -209,6 +211,7 @@ def test_local_wdl(self):
209211
self.assertTrue(self.check_for_file(outfile_path), 'Output file was not found: ' + str(outfile_path))
210212

211213

214+
@pytest.mark.skipif(not os.environ.get("ARVADOS_API_TOKEN"), reason="Arvados not configured")
212215
class ArvadosTest(IntegrationTest):
213216
"""Test using arvados-cwl-runner."""
214217

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)