From 204a308be0f741726b9a620d88fbc22b22124c81 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Fri, 29 Dec 2023 18:55:37 +0000 Subject: Namespace all modules under gn2. We move all modules under a gn2 directory. This is important for "correct" packaging and deployment as a Guix service. --- gn2/base/data_set/probably_unused.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 gn2/base/data_set/probably_unused.py (limited to 'gn2/base/data_set/probably_unused.py') diff --git a/gn2/base/data_set/probably_unused.py b/gn2/base/data_set/probably_unused.py new file mode 100644 index 00000000..12be05a7 --- /dev/null +++ b/gn2/base/data_set/probably_unused.py @@ -0,0 +1,35 @@ +"Functions that are probably unused in the code" + +import pickle as pickle + +from gn2.wqflask.database import database_connection +from gn2.utility.tools import get_setting + +def create_datasets_list(): + if USE_REDIS: + key = "all_datasets" + result = redis_conn.get(key) + + if result: + datasets = pickle.loads(result) + + if result is None: + datasets = list() + type_dict = {'Publish': 'PublishFreeze', + 'ProbeSet': 'ProbeSetFreeze', + 'Geno': 'GenoFreeze'} + + for dataset_type in type_dict: + with database_connection(get_setting("SQL_URI")) as conn, conn.cursor() as cursor: + cursor.execute("SELECT Name FROM %s", + (type_dict[dataset_type],)) + results = cursor.fetchall(query) + if results: + for result in results: + datasets.append( + create_dataset(result.Name, dataset_type)) + if USE_REDIS: + redis_conn.set(key, pickle.dumps(datasets, pickle.HIGHEST_PROTOCOL)) + redis_conn.expire(key, 60 * 60) + + return datasets -- cgit v1.2.3