about summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-12-03 11:18:14 -0600
committerFrederick Muriuki Muriithi2024-12-03 15:11:24 -0600
commitc7ff9222b74402e068630352ba37de0f15d07b88 (patch)
tree61604f01774ff170711df27f99d00ea4a2b3461b /scripts
parent0c59c583399ff0158d45c0bbdad61a056bd8fd6f (diff)
downloadgn-uploader-c7ff9222b74402e068630352ba37de0f15d07b88.tar.gz
Pass the redis connection and fully qualified job id
Pass the redis connection on to the function used to build main since
it might need to use a connection to redis.

Also pass the computed fully qualified job id rather than recomputing
it every time.

Update dependent functions to take the new arguments.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/process_rqtl2_bundle.py4
-rw-r--r--scripts/rqtl2/entry.py7
-rw-r--r--scripts/rqtl2/install_genotypes.py5
-rw-r--r--scripts/rqtl2/install_phenos.py5
-rw-r--r--scripts/rqtl2/phenotypes_qc.py2
5 files changed, 19 insertions, 4 deletions
diff --git a/scripts/process_rqtl2_bundle.py b/scripts/process_rqtl2_bundle.py
index 4efc3e0..8b7a0fb 100644
--- a/scripts/process_rqtl2_bundle.py
+++ b/scripts/process_rqtl2_bundle.py
@@ -94,7 +94,9 @@ def process_bundle(dbconn: mdb.Connection,
         if has_geno_file(thejob):
             logger.info("Processing geno files.")
             genoexit = install_genotypes(
+                rconn,
                 dbconn,
+                f"{rprefix}:{jobid}",
                 argparse.Namespace(
                     speciesid=meta["speciesid"],
                     populationid=meta["populationid"],
@@ -110,7 +112,9 @@ def process_bundle(dbconn: mdb.Connection,
 
         if has_pheno_file(thejob):
             phenoexit = install_pheno_files(
+                rconn,
                 dbconn,
+                f"{rprefix}:{jobid}",
                 argparse.Namespace(
                     speciesid=meta["speciesid"],
                     platformid=meta["platformid"],
diff --git a/scripts/rqtl2/entry.py b/scripts/rqtl2/entry.py
index 48d89fb..327ed2c 100644
--- a/scripts/rqtl2/entry.py
+++ b/scripts/rqtl2/entry.py
@@ -16,7 +16,10 @@ from scripts.redis_logger import setup_redis_logger
 
 def build_main(
         args: Namespace,
-        run_fn: Callable[[Connection, Namespace, logging.Logger], int],
+        run_fn: Callable[
+            [Redis, Connection, str, Namespace, logging.Logger],
+            int
+        ],
         loggername: str
 ) -> Callable[[],int]:
     """Build a function to be used as an entry-point for scripts."""
@@ -45,7 +48,7 @@ def build_main(
                     logger.error("File not found: '%s'.", args.rqtl2bundle)
                     return 2
 
-                returncode = run_fn(dbconn, args, logger)
+                returncode = run_fn(rconn, dbconn, fqjobid, args, logger)
                 if returncode == 0:
                     rconn.hset(fqjobid, "status", "completed:success")
                     return returncode
diff --git a/scripts/rqtl2/install_genotypes.py b/scripts/rqtl2/install_genotypes.py
index 20a19da..8762655 100644
--- a/scripts/rqtl2/install_genotypes.py
+++ b/scripts/rqtl2/install_genotypes.py
@@ -7,6 +7,7 @@ from functools import reduce
 from typing import Iterator, Optional
 from logging import Logger, getLogger
 
+from redis import Redis
 import MySQLdb as mdb
 from MySQLdb.cursors import DictCursor
 
@@ -185,8 +186,10 @@ def cross_reference_genotypes(
         cursor.executemany(insertquery, insertparams)
         return cursor.rowcount
 
-def install_genotypes(#pylint: disable=[too-many-arguments, too-many-locals]
+def install_genotypes(#pylint: disable=[too-many-locals]
+        rconn: Redis,#pylint: disable=[unused-argument]
         dbconn: mdb.Connection,
+        fullyqualifiedjobid: str,#pylint: disable=[unused-argument]
         args: argparse.Namespace,
         logger: Logger = getLogger(__name__)
 ) -> int:
diff --git a/scripts/rqtl2/install_phenos.py b/scripts/rqtl2/install_phenos.py
index a6e9fb2..9059cd6 100644
--- a/scripts/rqtl2/install_phenos.py
+++ b/scripts/rqtl2/install_phenos.py
@@ -6,6 +6,7 @@ from zipfile import ZipFile
 from functools import reduce
 from logging import Logger, getLogger
 
+from redis import Redis
 import MySQLdb as mdb
 from MySQLdb.cursors import DictCursor
 
@@ -95,8 +96,10 @@ def cross_reference_probeset_data(dbconn: mdb.Connection,
             } for row in dataids))
         return cursor.rowcount
 
-def install_pheno_files(#pylint: disable=[too-many-arguments, too-many-locals]
+def install_pheno_files(#pylint: disable=[too-many-locals]
+        rconn: Redis,#pylint: disable=[unused-argument]
         dbconn: mdb.Connection,
+        fullyqualifiedjobid: str,#pylint: disable=[unused-argument]
         args: argparse.Namespace,
         logger: Logger = getLogger()) -> int:
     """Load data in `pheno` files and other related files into the database."""
diff --git a/scripts/rqtl2/phenotypes_qc.py b/scripts/rqtl2/phenotypes_qc.py
index 4f55e40..12b1803 100644
--- a/scripts/rqtl2/phenotypes_qc.py
+++ b/scripts/rqtl2/phenotypes_qc.py
@@ -324,7 +324,9 @@ def fullyqualifiedkey(
     return f"{prefix}:{rest}"
 
 def run_qc(# pylint: disable=[too-many-locals]
+        rconn: Redis,
         dbconn: mdb.Connection,
+        fullyqualifiedjobid: str,
         args: Namespace,
         logger: Logger
 ) -> int: