Skip to content

Commit

Permalink
Merge pull request #69 from common-workflow-language/form-params
Browse files Browse the repository at this point in the history
Handle form parameters in POST that are not attachments
  • Loading branch information
tetron authored Feb 11, 2019
2 parents 22c2d18 + b236857 commit 65571a4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
'future',
'connexion==1.4.2',
'ruamel.yaml >= 0.12.4, <= 0.15.77',
'cwlref-runner==1.0',
'schema-salad >= 3.0, < 3.1',
'schema-salad',
'subprocess32==3.5.2'
],
entry_points={
'console_scripts': ["wes-server=wes_service.wes_service_main:main",
"wes-client=wes_client.wes_client_main:main"]
},
extras_require={
"cwltool": ['cwlref-runner'],
"arvados": ["arvados-cwl-runner"
],
"toil": ["toil[all]==3.18.0"
Expand Down
3 changes: 3 additions & 0 deletions test/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import logging
import sys
import requests
import pytest

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


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

Expand Down
7 changes: 4 additions & 3 deletions wes_service/arvados_wes.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def invoke_cwl_runner(self, cr_uuid, workflow_url, workflow_params,
})

try:
with tempfile.NamedTemporaryFile(dir=tempdir, suffix=".json") as inputtemp:
with tempfile.NamedTemporaryFile("wt", dir=tempdir, suffix=".json") as inputtemp:
json.dump(workflow_params, inputtemp)
inputtemp.flush()

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

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

if tempdir:
shutil.rmtree(tempdir)
Expand Down Expand Up @@ -212,7 +212,8 @@ def RunWorkflow(self, **args):
tempdir)).start()

except Exception as e:
self.log_for_run(cr["uuid"], str(e))
logging.exception("Error")
self.log_for_run(cr["uuid"], "An exception ocurred while handling your request: " + str(e))
cr = api.container_requests().update(uuid=cr["uuid"],
body={"container_request":
{"priority": 0}}).execute()
Expand Down
16 changes: 12 additions & 4 deletions wes_service/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,18 @@ def collect_attachments(self, run_id=None):
body[k] = json.loads(content.decode("utf-8"))
else:
body[k] = v.read().decode()
for k, ls in iterlists(connexion.request.form):
for v in ls:
if k in ("workflow_params", "tags", "workflow_engine_parameters"):
body[k] = json.loads(v)
else:
body[k] = v

if ":" not in body["workflow_url"]:
body["workflow_url"] = "file://%s" % os.path.join(tempdir, secure_filename(body["workflow_url"]))

self.log_for_run(run_id, "Using workflow_url '%s'" % body.get("workflow_url"))
if "workflow_url" in body:
if ":" not in body["workflow_url"]:
body["workflow_url"] = "file://%s" % os.path.join(tempdir, secure_filename(body["workflow_url"]))
self.log_for_run(run_id, "Using workflow_url '%s'" % body.get("workflow_url"))
else:
raise Exception("Missing 'workflow_url' in submission")

return tempdir, body

0 comments on commit 65571a4

Please sign in to comment.