about summary refs log tree commit diff
path: root/uploader
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-04-21 10:07:32 -0500
committerFrederick Muriuki Muriithi2025-04-21 10:07:32 -0500
commit3dfc86e8fa5d2cdd41dc0df390734ebcaf06d99f (patch)
treea23d172fcf1a2177e10ab5914c666a4e90a6e39c /uploader
parenteb9bad471e15ce77bcdeac901909bf53098dc22d (diff)
downloadgn-uploader-3dfc86e8fa5d2cdd41dc0df390734ebcaf06d99f.tar.gz
Use module-specific logger.
Diffstat (limited to 'uploader')
-rw-r--r--uploader/phenotypes/models.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/uploader/phenotypes/models.py b/uploader/phenotypes/models.py
index 52f38cc..9ff89ae 100644
--- a/uploader/phenotypes/models.py
+++ b/uploader/phenotypes/models.py
@@ -1,14 +1,17 @@
 """Database and utility functions for phenotypes."""
+import logging
 from typing import Optional
 from functools import reduce
 from datetime import datetime
 
 import MySQLdb as mdb
 from MySQLdb.cursors import Cursor, DictCursor
-from flask import current_app as app
 
 from gn_libs.mysqldb import debug_query
 
+logger = logging.getLogger(__name__)
+
+
 def datasets_by_population(
         conn: mdb.Connection,
         species_id: int,
@@ -83,7 +86,7 @@ def dataset_phenotypes(conn: mdb.Connection,
             f" LIMIT {limit} OFFSET {offset}" if bool(limit) else "")
     with conn.cursor(cursorclass=DictCursor) as cursor:
         cursor.execute(_query, (population_id, dataset_id))
-        debug_query(cursor, app.logger)
+        debug_query(cursor, logger)
         return tuple(dict(row) for row in cursor.fetchall())
 
 
@@ -94,7 +97,7 @@ def __phenotype_se__(cursor: Cursor, xref_id, dataids_and_strainids):
     cursor.execute("SELECT * FROM PublishSE WHERE (DataId, StrainId) IN "
                    f"({paramstr})",
                    flat)
-    debug_query(cursor, app.logger)
+    debug_query(cursor, logger)
     _se = {
         (row["DataId"], row["StrainId"]): {
             "DataId": row["DataId"],
@@ -107,7 +110,7 @@ def __phenotype_se__(cursor: Cursor, xref_id, dataids_and_strainids):
     cursor.execute("SELECT * FROM NStrain WHERE (DataId, StrainId) IN "
                    f"({paramstr})",
                    flat)
-    debug_query(cursor, app.logger)
+    debug_query(cursor, logger)
     _n = {
         (row["DataId"], row["StrainId"]): {
             "DataId": row["DataId"],
@@ -226,7 +229,7 @@ def phenotypes_data(conn: mdb.Connection,
                   f" LIMIT {limit} OFFSET {offset}" if bool(limit) else "")
     with conn.cursor(cursorclass=DictCursor) as cursor:
         cursor.execute(_query, (population_id, dataset_id))
-        debug_query(cursor, app.logger)
+        debug_query(cursor, logger)
         return tuple(dict(row) for row in cursor.fetchall())
 
 
@@ -253,7 +256,7 @@ def save_new_dataset(cursor: Cursor,
         "%(created)s, %(public)s, %(population_id)s, %(confidentiality)s, "
         "%(users)s)",
         params)
-    debug_query(cursor, app.logger)
+    debug_query(cursor, logger)
     return {**params, "Id": cursor.lastrowid}
 
 
@@ -281,6 +284,6 @@ def phenotypes_data_by_ids(
                                      for item in (row["population_id"],
                                                   row["phenoid"],
                                                   row["xref_id"])))
-        debug_query(cursor, app.logger)
+        debug_query(cursor, logger)
         return tuple(
             reduce(__organise_by_phenotype__, cursor.fetchall(), {}).values())