about summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-12-03 16:00:11 -0600
committerFrederick Muriuki Muriithi2024-12-03 16:02:29 -0600
commit1ed9a130988681941669295329fda88fe075f40d (patch)
treee503eeb6e7ff5ef03f243834b45c4c9a7344b432 /scripts
parent2f4d48586a67e985f0b47b358ef15d8113b56ddb (diff)
downloadgn-uploader-1ed9a130988681941669295329fda88fe075f40d.tar.gz
Provide consistent way to build file-specific fully-qualified keys
Diffstat (limited to 'scripts')
-rw-r--r--scripts/rqtl2/phenotypes_qc.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/scripts/rqtl2/phenotypes_qc.py b/scripts/rqtl2/phenotypes_qc.py
index 2c09835..7a52d09 100644
--- a/scripts/rqtl2/phenotypes_qc.py
+++ b/scripts/rqtl2/phenotypes_qc.py
@@ -159,6 +159,11 @@ def push_error(rconn: Redis, fqkey: str, error: InvalidValue) -> InvalidValue:
     return error
 
 
+def file_fqkey(prefix: str, section: str, filepath: Path) -> str:
+    """Build a files fully-qualified key in a consistent manner"""
+    return f"{prefix}:{section}:{filepath.name}"
+
+
 def qc_phenocovar_file(
         filepath: Path,
         redisuri,
@@ -176,7 +181,8 @@ def qc_phenocovar_file(
         _csvfile = rqtl2.read_csv_file(filepath, separator, comment_char)
         _headings = tuple(heading.lower() for heading in next(_csvfile))
         _errors: tuple[InvalidValue, ...] = tuple()
-        save_error = partial(push_error, rconn, f"{fqkey}:errors:{filepath.name}")
+        save_error = partial(
+            push_error, rconn, file_fqkey(fqkey, "errors", filepath))
         for heading in ("description", "units"):
             if heading not in _headings:
                 _errors = (save_error(InvalidValue(
@@ -271,7 +277,8 @@ def qc_pheno_file(# pylint: disable=[too-many-arguments]
             f"{fqkey}:logs") as logger,
           Redis.from_url(redisuri, decode_responses=True) as rconn):
         logger.info("Running QC on file: %s", filepath.name)
-        save_error = partial(push_error, rconn, f"{fqkey}:errors:{filepath.name}")
+        save_error = partial(
+            push_error, rconn, file_fqkey(fqkey, "errors", filepath))
         _csvfile = rqtl2.read_csv_file(filepath, separator, comment_char)
         _headings: tuple[str, ...] = tuple(
             heading.lower() for heading in next(_csvfile))