aboutsummaryrefslogtreecommitdiff
path: root/scripts/process_rqtl2_bundle.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-01-23 12:33:08 +0300
committerFrederick Muriuki Muriithi2024-01-23 12:33:08 +0300
commit7976230ffcb1de4f744895ee252298dea9a15f4c (patch)
tree93767bf918847c7707cf369c6f3fbc1b2a562590 /scripts/process_rqtl2_bundle.py
parent1822e893586e13334cc66d59efbe03c1ffb48b66 (diff)
downloadgn-uploader-7976230ffcb1de4f744895ee252298dea9a15f4c.tar.gz
Update scripts to use redis prefix.
Diffstat (limited to 'scripts/process_rqtl2_bundle.py')
-rw-r--r--scripts/process_rqtl2_bundle.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/scripts/process_rqtl2_bundle.py b/scripts/process_rqtl2_bundle.py
index 7b114cf..1b26264 100644
--- a/scripts/process_rqtl2_bundle.py
+++ b/scripts/process_rqtl2_bundle.py
@@ -27,12 +27,12 @@ def safe_json_decode(value: str) -> Any:
except json.decoder.JSONDecodeError:
return value
-def parse_job(rconn: Redis, jobid: uuid.UUID) -> dict:
+def parse_job(rconn: Redis, rprefix: str, jobid: uuid.UUID) -> dict:
"""Load and parse job from Redis"""
return {
key: safe_json_decode(value)
for key, value
- in jobs.job(rconn, jobid).items()
+ in jobs.job(rconn, rprefix, jobid).items()
}
def has_geno_file(job: dict) -> bool:
@@ -51,14 +51,15 @@ def percent_completion(geno: float, pheno: float) -> float:
def process_bundle(dbconn: mdb.Connection,
rconn: Redis,
+ rprefix: str,
jobid: uuid.UUID,
logger: Logger) -> int:
"""Process the R/qtl2 bundle."""
try:
- thejob = parse_job(rconn, jobid)
+ thejob = parse_job(rconn, rprefix, jobid)
meta = thejob["bundle-metadata"]
- rconn.hset(str(jobid), "geno-percent", "0")
- rconn.hset(str(jobid), "pheno-percent", "0")
+ rconn.hset(jobs.job_key(rprefix, jobid), "geno-percent", "0")
+ rconn.hset(jobs.job_key(rprefix, jobid), "pheno-percent", "0")
if has_geno_file(thejob):
logger.info("Processing geno files.")
@@ -74,7 +75,7 @@ def process_bundle(dbconn: mdb.Connection,
logger.debug(
"geno file processing completed successfully. (ExitCode: %s)",
genoexit)
- rconn.hset(str(jobid), "geno-percent", "100")
+ rconn.hset(jobs.job_key(rprefix, jobid), "geno-percent", "100")
if has_pheno_file(thejob):
phenoexit = install_pheno_files(
@@ -89,7 +90,7 @@ def process_bundle(dbconn: mdb.Connection,
logger.debug(
"pheno file processing completed successfully. (ExitCode: %s)",
phenoexit)
- rconn.hset(str(jobid), "pheno-percent", "100")
+ rconn.hset(jobs.job_key(rprefix, jobid), "pheno-percent", "100")
return 0
except jobs.JobNotFound as exc:
@@ -113,14 +114,17 @@ if __name__ == "__main__":
logger.addHandler(StreamHandler(stream=sys.stderr))
logger.setLevel("DEBUG")
- jobid = args.jobid
+ fqjobid = jobs.job_key(args.redisprefix, args.jobid)
with (database_connection(args.databaseuri) as dbconn,
Redis.from_url(args.redisuri, decode_responses=True) as rconn):
logger.addHandler(setup_redis_logger(
- rconn, jobid, f"{str(jobid)}:log-messages", args.redisexpiry))
+ rconn, fqjobid, f"{fqjobid}:log-messages",
+ args.redisexpiry))
- exitcode = process_bundle(dbconn, rconn, args.jobid, logger)
- rconn.hset(str(args.jobid), "percent", "100")
+ exitcode = process_bundle(
+ dbconn, rconn, args.redisprefix, args.jobid, logger)
+ rconn.hset(
+ jobs.job_key(args.redisprefix, args.jobid), "percent", "100")
return exitcode
sys.exit(main())