diff options
-rw-r--r-- | uploader/jobs.py | 10 | ||||
-rw-r--r-- | uploader/phenotypes/views.py | 2 |
2 files changed, 12 insertions, 0 deletions
diff --git a/uploader/jobs.py b/uploader/jobs.py index 4a3fc80..ff6a3c7 100644 --- a/uploader/jobs.py +++ b/uploader/jobs.py @@ -1,6 +1,8 @@ """Handle jobs""" import os import sys +import uuid +import json import shlex import subprocess from uuid import UUID, uuid4 @@ -128,3 +130,11 @@ def update_stdout_stderr(rconn: Redis, contents = thejob.get(stream, '') new_contents = contents + bytes_read.decode("utf-8") rconn.hset(name=job_key(rprefix, jobid), key=stream, value=new_contents) + + +def job_errors(rconn: Redis, prefix: str, job_id: Union[str, uuid.UUID]) -> tuple[dict, ...]: + """Fetch job errors""" + return tuple( + json.loads(error) + for key in rconn.keys(f"{prefix}:{str(job_id)}:*:errors:*") + for error in rconn.lrange(key, 0, -1)) diff --git a/uploader/phenotypes/views.py b/uploader/phenotypes/views.py index dd6ba7e..74de3ea 100644 --- a/uploader/phenotypes/views.py +++ b/uploader/phenotypes/views.py @@ -3,6 +3,7 @@ import sys import uuid import json from pathlib import Path +from typing import Union from functools import wraps from logging import INFO, ERROR, DEBUG, FATAL, CRITICAL, WARNING @@ -414,4 +415,5 @@ def job_status( dataset=dataset, job_id=job_id, job=job, + errors=jobs.job_errors(rconn, jobs.jobsnamespace(), job['jobid']), activelink="add-phenotypes") |