about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi <fredmanglis@gmail.com>2026-11-23 10:05:55 -0600
committerFrederick Muriuki Muriithi <fredmanglis@gmail.com>2026-11-23 10:25:49 -0600
commit54f5a1cb0cb95286e355e55d3a61eeec3396e325 (patch)
tree66e817ac79da0e4b2aed8bf72d0d8383b591ee8d
parenta090c151aa10c77b54502264b821357aafdd8e15 (diff)
downloadgenenetwork3-54f5a1cb0cb95286e355e55d3a61eeec3396e325.tar.gz
Add logging to R/qtl compute function. HEAD main
GN3 seems to die inexplicably after a call to
http://localhost:9895/api/rqtl/compute?id=…. This commit adds some
logging to help figure out whether the function is actually the cause,
and if it is, where in the code the failure occurs. The information
gleaned from this will hopefully help with resolving the currently
inexplicable failures.
-rw-r--r--gn3/api/rqtl.py13
-rw-r--r--gn3/app.py1
2 files changed, 13 insertions, 1 deletions
diff --git a/gn3/api/rqtl.py b/gn3/api/rqtl.py
index eb49f8b..0fe971b 100644
--- a/gn3/api/rqtl.py
+++ b/gn3/api/rqtl.py
@@ -2,6 +2,7 @@
 
 import os
 import uuid
+import logging
 from pathlib import Path
 
 from flask import Blueprint
@@ -19,6 +20,7 @@ from gn3.computations.streaming import run_process, enable_streaming
 from gn3.fs_helpers import assert_path_exists, get_tmpdir
 
 rqtl = Blueprint("rqtl", __name__)
+logger = logging.getLogger(__name__)
 
 
 @rqtl.route("/compute", methods=["POST"])
@@ -54,6 +56,7 @@ def compute(stream_output_file):
     if not os.path.isdir(outdir):
         os.mkdir(outdir)
 
+    logger.info("Generating the R/qtl command")
     rqtl_cmd = generate_rqtl_cmd(
         rqtl_wrapper_cmd=str(
             Path(__file__)
@@ -63,6 +66,7 @@ def compute(stream_output_file):
         rqtl_wrapper_kwargs=rqtl_kwargs,
         rqtl_wrapper_bool_kwargs=rqtl_bool_kwargs,
     )
+    logger.info("Generated R/qtl command: %s", rqtl_cmd)
 
     rqtl_output = {}
     run_id = request.args.get("id", str(uuid.uuid4()))
@@ -72,13 +76,18 @@ def compute(stream_output_file):
         )
     ):
         pass
-    run_process(rqtl_cmd.get("rqtl_cmd").split(), stream_output_file, run_id)
+    logger.info("Running R/qtl command")
+    _status = run_process(
+        rqtl_cmd.get("rqtl_cmd").split(), stream_output_file, run_id)
+    logger.info("R/qtl command finished with: %s", _status)
 
     if "pairscan" in rqtl_bool_kwargs:
+        logger.info("R/qtl: processing pairscan")
         rqtl_output["results"] = process_rqtl_pairscan(
             rqtl_cmd.get("output_file"), genofile
         )
     else:
+        logger.info("R/qtl: processing mapping")
         rqtl_output["results"] = process_rqtl_mapping(rqtl_cmd.get("output_file"))
 
     if int(rqtl_kwargs["nperm"]) > 0:
@@ -89,4 +98,6 @@ def compute(stream_output_file):
             rqtl_output["suggestive"],
             rqtl_output["significant"],
         ) = process_perm_output(perm_output_file)
+
+    logger.info("R/qtl compute completed.")
     return jsonify(rqtl_output)
diff --git a/gn3/app.py b/gn3/app.py
index b0a1e5f..afe6781 100644
--- a/gn3/app.py
+++ b/gn3/app.py
@@ -85,6 +85,7 @@ def create_app(config: Union[Dict, str, None] = None) -> Flask:
     verify_app_config(app)
     setup_app_logging(app)
     setup_modules_logging(loglevel(app), ("gn3.db.menu",
+                                          "gn3.api.rqtl",
                                           "gn_libs.mysqldb"))
     # DO NOT log anything before this point
     logging.info("Guix Profile: '%s'.", os.environ.get("GUIX_PROFILE"))