aboutsummaryrefslogtreecommitdiff
path: root/wqflask/scripts/textfiles_generator.py
diff options
context:
space:
mode:
authorAlexander_Kabui2023-05-15 23:15:12 +0300
committerAlexander_Kabui2023-05-15 23:15:12 +0300
commita2b08a1cac5dff9a5332aa74bee12523aa4b9923 (patch)
tree552ed821138fe131eaca73b49215ae31412ebeac /wqflask/scripts/textfiles_generator.py
parent6bdc87998b23de9dae7b575b7ac49f75b28712d9 (diff)
downloadgenenetwork2-a2b08a1cac5dff9a5332aa74bee12523aa4b9923.tar.gz
read to generate datasets from todolist file
Diffstat (limited to 'wqflask/scripts/textfiles_generator.py')
-rw-r--r--wqflask/scripts/textfiles_generator.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/wqflask/scripts/textfiles_generator.py b/wqflask/scripts/textfiles_generator.py
index 59bbdb29..b7c94eb0 100644
--- a/wqflask/scripts/textfiles_generator.py
+++ b/wqflask/scripts/textfiles_generator.py
@@ -253,8 +253,7 @@ def argument_parser():
def run_textfiles_generator(args):
try:
-
- for (d_type, dataset_name, _species) in DATASET_NAMES:
+ for (d_type, dataset_name, _species) in fetch_to_generate_dataset("ProbeSet", "textfile"):
file_name = __generate_file_name__(dataset_name, args.SQL_URI)
if not check_file_expiry(os.path.join(
args.TMPDIR, "Probesets"), file_name):
@@ -266,7 +265,7 @@ def run_textfiles_generator(args):
def run_metadata_files_generator(args):
- for (dataset_type, dataset_name, species) in DATASET_NAMES:
+ for (dataset_type, dataset_name, species) in fetch_to_generate_dataset("ProbeSet", "metadata"):
try:
if not check_file_expiry(os.path.join(TMPDIR, f"metadata_{dataset_type}"), dataset_name):
return
@@ -305,6 +304,18 @@ def check_file_expiry(target_file_path, dataset_name, max_days=20):
return True
+def fetch_to_generate_dataset(dataset_type, gen_type):
+ try:
+ with lmdb.open(os.path.join("/tmp", "todolist_generate"), readonly=True, lock=False) as env:
+ with env.begin() as txn:
+ data = txn.get(f"{gen_type}:{dataset_type}".encode())
+ if data:
+ return [result for result in pickle.loads(data).values()]
+ return DATASET_NAMES
+ except Exception as err:
+ return DATASET_NAMES
+
+
if __name__ == '__main__':
args = argument_parser()
TMPDIR = args.TMPDIR