Skip to content

Commit 4c03521

Browse files
authored
Merge pull request #70 from common-workflow-language/error-reporting
Improve error reporting for bad requests
2 parents 207b971 + 042d582 commit 4c03521

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
long_description = readmeFile.read()
1212

1313
setup(name='wes-service',
14-
version='3.1',
14+
version='3.2',
1515
description='GA4GH Workflow Execution Service reference implementation',
1616
long_description=long_description,
1717
author='GA4GH Containers and Workflows task team',

wes_service/arvados_wes.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ def RunWorkflow(self, **args):
197197
"output_path": "n/a",
198198
"priority": 500}}).execute()
199199

200+
success = False
200201
try:
201202
tempdir, body = self.collect_attachments(cr["uuid"])
202203

@@ -210,14 +211,22 @@ def RunWorkflow(self, **args):
210211
env,
211212
project_uuid,
212213
tempdir)).start()
213-
214+
success = True
215+
except ValueError as e:
216+
self.log_for_run(cr["uuid"], "Bad request: " + str(e))
217+
cr = api.container_requests().update(uuid=cr["uuid"],
218+
body={"container_request":
219+
{"priority": 0}}).execute()
220+
return {"msg": str(e), "status_code": 400}, 400
214221
except Exception as e:
215222
logging.exception("Error")
216223
self.log_for_run(cr["uuid"], "An exception ocurred while handling your request: " + str(e))
217224
cr = api.container_requests().update(uuid=cr["uuid"],
218225
body={"container_request":
219226
{"priority": 0}}).execute()
220-
return {"run_id": cr["uuid"]}
227+
return {"msg": str(e), "status_code": 500}, 500
228+
else:
229+
return {"run_id": cr["uuid"]}
221230

222231
@catch_exceptions
223232
def GetRunLog(self, run_id):

wes_service/util.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def log_for_run(self, run_id, message):
4949
def collect_attachments(self, run_id=None):
5050
tempdir = tempfile.mkdtemp()
5151
body = {}
52+
has_attachments = False
5253
for k, ls in iterlists(connexion.request.files):
5354
for v in ls:
5455
if k == "workflow_attachment":
@@ -62,6 +63,7 @@ def collect_attachments(self, run_id=None):
6263
os.makedirs(os.path.dirname(dest))
6364
self.log_for_run(run_id, "Staging attachment '%s' to '%s'" % (v.filename, dest))
6465
v.save(dest)
66+
has_attachments = True
6567
body[k] = "file://%s" % tempdir # Reference to temp working dir.
6668
elif k in ("workflow_params", "tags", "workflow_engine_parameters"):
6769
content = v.read()
@@ -77,9 +79,11 @@ def collect_attachments(self, run_id=None):
7779

7880
if "workflow_url" in body:
7981
if ":" not in body["workflow_url"]:
82+
if not has_attachments:
83+
raise ValueError("Relative 'workflow_url' but missing 'workflow_attachment'")
8084
body["workflow_url"] = "file://%s" % os.path.join(tempdir, secure_filename(body["workflow_url"]))
8185
self.log_for_run(run_id, "Using workflow_url '%s'" % body.get("workflow_url"))
8286
else:
83-
raise Exception("Missing 'workflow_url' in submission")
87+
raise ValueError("Missing 'workflow_url' in submission")
8488

8589
return tempdir, body

0 commit comments

Comments
 (0)