about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-09-20 22:56:55 +0300
committerFrederick Muriuki Muriithi2022-09-20 22:56:55 +0300
commitd0b01d0be72ff541e72373cd085a58c3af2b4fed (patch)
tree0b85061334056ec06cf57f75da75436075fbb64c
parent768c05bb521716873e0ee1050bab360f09345a5b (diff)
downloadgenenetwork2-d0b01d0be72ff541e72373cd085a58c3af2b4fed.tar.gz
Remove global `Dataset_Getter` variable
Since the `__post_init__` method in the 'DatasetType' class checks
whether data is in redis before hitting the database, it does not
matter whether there is a global object of the type, as long as we
make sure to call the object correctly.

This commit makes that happen.
-rw-r--r--wqflask/base/data_set/__init__.py9
1 files changed, 2 insertions, 7 deletions
diff --git a/wqflask/base/data_set/__init__.py b/wqflask/base/data_set/__init__.py
index eaf80b19..6d475df2 100644
--- a/wqflask/base/data_set/__init__.py
+++ b/wqflask/base/data_set/__init__.py
@@ -31,18 +31,13 @@ DS_NAME_MAP = {
     "ProbeSet": "MrnaAssayDataSet"
 }
 
-# Do the intensive work at startup one time only
-# TODO: Pass in the Redis conniction from elsewhere to allow fo flexible
-#       configuration
-Dataset_Getter = DatasetType(Redis())
-
 def create_dataset(dataset_name, dataset_type=None,
-                   get_samplelist=True, group_name=None):
+                   get_samplelist=True, group_name=None, redis_conn=Redis()):
     if dataset_name == "Temp":
         dataset_type = "Temp"
 
     if not dataset_type:
-        dataset_type = Dataset_Getter(dataset_name)
+        dataset_type = DatasetType(redis_conn)(dataset_name)
 
     dataset_ob = DS_NAME_MAP[dataset_type]
     dataset_class = globals()[dataset_ob]