aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorAlexander Kabui2021-11-17 08:34:24 +0300
committerAlexander Kabui2021-11-17 08:34:24 +0300
commitc872594d21ab743ae55ae4f1d037d13394ef8c67 (patch)
treed0258b7fd88e3d63772643701ce8656d9f38c55d /wqflask
parent1090674ac9497dad22803e7bf8e51d77245f8a0c (diff)
downloadgenenetwork2-c872594d21ab743ae55ae4f1d037d13394ef8c67.tar.gz
isolate function to cache new traits metadata
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/correlation/pre_computes.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/wqflask/wqflask/correlation/pre_computes.py b/wqflask/wqflask/correlation/pre_computes.py
index 638ae860..9270bdd4 100644
--- a/wqflask/wqflask/correlation/pre_computes.py
+++ b/wqflask/wqflask/correlation/pre_computes.py
@@ -1,6 +1,7 @@
import json
import os
import hashlib
+from pathlib import Path
from base.data_set import query_table_timestamp
from base.webqtlConfig import TMPDIR
@@ -25,8 +26,22 @@ def fetch_all_cached_metadata(dataset_name):
Path(file_path).touch(exist_ok=True)
return {}
- return dataset_metadata
+ return (file_path, dataset_metadata)
+ if bool(new_traits_metadata):
+ # that means new traits exists
+ dataset_metadata.update(new_traits_metadata)
+ with open(file_path, "w+") as file_handler:
+ json.dump(dataset_metadata, file_handler)
+
+
+def cache_new_traits_metadata(dataset_metadata: dict, new_traits_metadata, file_path: str):
+ """function to cache the new traits metadata"""
+
+ if bool(new_traits_metadata):
+ dataset_metadata.update(new_traits_metadata)
+ with open(file_path,"w+") as file_handler:
+ json.dump(dataset_metadata,file_handler)
def generate_filename(base_dataset_name, target_dataset_name, base_timestamp, target_dataset_timestamp):