Skip to content

Commit

Permalink
Improve error handling of invalid workflow_engine_parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Amstutz committed Apr 4, 2019
1 parent 4c03521 commit 13bfbeb
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 26 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
long_description = readmeFile.read()

setup(name='wes-service',
version='3.2',
version='3.3',
description='GA4GH Workflow Execution Service reference implementation',
long_description=long_description,
author='GA4GH Containers and Workflows task team',
Expand Down
5 changes: 4 additions & 1 deletion wes_service/arvados_wes.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,10 @@ def RunWorkflow(self, **args):

workflow_url = body.get("workflow_url")

project_uuid = body.get("workflow_engine_parameters", {}).get("project_uuid")
workflow_engine_parameters = body.get("workflow_engine_parameters", {})
project_uuid = None
if workflow_engine_parameters:
project_uuid = workflow_engine_parameters.get("project_uuid")

threading.Thread(target=self.invoke_cwl_runner, args=(cr["uuid"],
workflow_url,
Expand Down
54 changes: 30 additions & 24 deletions wes_service/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,31 +51,37 @@ def collect_attachments(self, run_id=None):
body = {}
has_attachments = False
for k, ls in iterlists(connexion.request.files):
for v in ls:
if k == "workflow_attachment":
sp = v.filename.split("/")
fn = []
for p in sp:
if p not in ("", ".", ".."):
fn.append(secure_filename(p))
dest = os.path.join(tempdir, *fn)
if not os.path.isdir(os.path.dirname(dest)):
os.makedirs(os.path.dirname(dest))
self.log_for_run(run_id, "Staging attachment '%s' to '%s'" % (v.filename, dest))
v.save(dest)
has_attachments = True
body[k] = "file://%s" % tempdir # Reference to temp working dir.
elif k in ("workflow_params", "tags", "workflow_engine_parameters"):
content = v.read()
body[k] = json.loads(content.decode("utf-8"))
else:
body[k] = v.read().decode()
try:
for v in ls:
if k == "workflow_attachment":
sp = v.filename.split("/")
fn = []
for p in sp:
if p not in ("", ".", ".."):
fn.append(secure_filename(p))
dest = os.path.join(tempdir, *fn)
if not os.path.isdir(os.path.dirname(dest)):
os.makedirs(os.path.dirname(dest))
self.log_for_run(run_id, "Staging attachment '%s' to '%s'" % (v.filename, dest))
v.save(dest)
has_attachments = True
body[k] = "file://%s" % tempdir # Reference to temp working dir.
elif k in ("workflow_params", "tags", "workflow_engine_parameters"):
content = v.read()
body[k] = json.loads(content.decode("utf-8"))
else:
body[k] = v.read().decode()
except Exception as e:
raise ValueError("Error reading parameter '%s': %s" % (k, e))
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
try:
for v in ls:
if k in ("workflow_params", "tags", "workflow_engine_parameters") and v != "":
body[k] = json.loads(v)
else:
body[k] = v
except Exception as e:
raise ValueError("Error reading parameter '%s': %s" % (k, e))

if "workflow_url" in body:
if ":" not in body["workflow_url"]:
Expand Down

0 comments on commit 13bfbeb

Please sign in to comment.