Commit 9ccbacd6 authored by Ryan Herbert's avatar Ryan Herbert

task.py more exception handling compute_extra

Make compute_extra more verbal so we can get a better idea of what is
happening should the function fail.
parent 3bea32f7
Pipeline #48684 passed with stages
in 6 minutes and 4 seconds
......@@ -98,6 +98,7 @@ def compute_extra(id_file, id_config, min_threshold):
(db.results_file.config_id == id_config)
).select(orderby=~db.results_file.run_date).first()
filename = defs.DIR_RESULTS+results_file.data_file
try:
with open(filename, "rb") as rf:
try:
d = json.load(rf)
......@@ -115,9 +116,21 @@ def compute_extra(id_file, id_config, min_threshold):
except ValueError as e:
print('invalid_json')
return "FAIL"
except:
print('unknown error')
return 'FAIL'
except IOError as ioe:
print("I/O error opening %s" % filename)
except:
print("Unexpected error opening %s" % filename)
d['reads']['distribution'] = result
try:
with open(filename, 'wb') as extra:
json.dump(d, extra)
except IOError as ioe:
print("I/o error writing to %s" % filename)
except:
print("Unexpected error writing to %s" % filename)
return "SUCCESS"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment