aboutsummaryrefslogtreecommitdiff
path: root/qc_app/jobs.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-01-19 08:29:04 +0300
committerFrederick Muriuki Muriithi2024-01-19 08:29:04 +0300
commit53b1e7cb181380a24aab4cbc7a9634b2d8dd2d29 (patch)
tree284a170506ba6557f8a163b3464487346cf40b9c /qc_app/jobs.py
parent028e84f8a179f43e092cfb35975ef30d47aca82a (diff)
downloadgn-uploader-53b1e7cb181380a24aab4cbc7a9634b2d8dd2d29.tar.gz
scripts: Process R/qtl2 bundle
Build script to start the processing of the R/qtl2 bundle.
Diffstat (limited to 'qc_app/jobs.py')
-rw-r--r--qc_app/jobs.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/qc_app/jobs.py b/qc_app/jobs.py
index c5bf5e5..a8257a3 100644
--- a/qc_app/jobs.py
+++ b/qc_app/jobs.py
@@ -3,11 +3,19 @@ import os
import sys
import shlex
import subprocess
-from uuid import uuid4
+from typing import Union
+from uuid import UUID, uuid4
from datetime import timedelta
from redis import Redis
+class JobNotFound(Exception):
+ """Raised if we try to retrieve a non-existent job."""
+
+def raise_jobnotfound(jobid: Union[str,UUID]):
+ """Utility to raise a `NoSuchJobError`"""
+ raise JobNotFound(f"Could not retrieve job '{jobid}'.")
+
def error_filename(job_id, error_dir):
"Compute the path of the file where errors will be dumped."
return f"{error_dir}/job_{job_id}.error"
@@ -70,6 +78,7 @@ def launch_job(the_job: dict, redisurl: str, error_dir):
return the_job
-def job(redis_conn, job_id: str):
+def job(redis_conn, job_id: Union[str,UUID]):
"Retrieve the job"
- return redis_conn.hgetall(job_id)
+ thejob = redis_conn.hgetall(str(job_id)) or raise_jobnotfound(job_id)
+ return thejob