aboutsummaryrefslogtreecommitdiff
path: root/uploader
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-12-03 13:08:59 -0600
committerFrederick Muriuki Muriithi2024-12-03 15:11:25 -0600
commit49d8ec6bb3caae91e5d8e4b5859ee4e4c0ed4dd6 (patch)
tree057d2ed293d05acda44a6c7a668b8ff022b71fd3 /uploader
parentc6437873142ad90c6ce29dcf0e700e0e6a1c658a (diff)
downloadgn-uploader-49d8ec6bb3caae91e5d8e4b5859ee4e4c0ed4dd6.tar.gz
Fetch a jobs errors from its errors lists.
Diffstat (limited to 'uploader')
-rw-r--r--uploader/jobs.py10
-rw-r--r--uploader/phenotypes/views.py2
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")