aboutsummaryrefslogtreecommitdiff
path: root/wqflask/base
diff options
context:
space:
mode:
authorPjotr Prins2020-04-30 13:53:44 -0500
committerPjotr Prins2020-04-30 13:53:44 -0500
commit421848837d3b489762bb9e58e5e7047d02cdb20b (patch)
tree243eb730e0bc1c10a1416394927c71ea5f73ddf2 /wqflask/base
parent2e4ca1f6732d14c0ce0d953f1c08ecb000a94747 (diff)
parent86d885f5f2e1069a5b1606296a71992805486aec (diff)
downloadgenenetwork2-421848837d3b489762bb9e58e5e7047d02cdb20b.tar.gz
Merge branch 'testing' of github.com:genenetwork/genenetwork2 into testing.3
Diffstat (limited to 'wqflask/base')
-rw-r--r--wqflask/base/data_set.py44
1 files changed, 27 insertions, 17 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py
index 1f99df49..cab708ef 100644
--- a/wqflask/base/data_set.py
+++ b/wqflask/base/data_set.py
@@ -93,22 +93,29 @@ Publish or ProbeSet. E.g.
"""
self.datasets = {}
- data = json.loads(requests.get(GN2_BASE_URL + "/api/v_pre1/gen_dropdown").content)
- #data = gen_menu.gen_dropdown_json()
-
-
- for species in data['datasets']:
- for group in data['datasets'][species]:
- for dataset_type in data['datasets'][species][group]:
- for dataset in data['datasets'][species][group][dataset_type]:
- short_dataset_name = dataset[1]
- if dataset_type == "Phenotypes":
- new_type = "Publish"
- elif dataset_type == "Genotypes":
- new_type = "Geno"
- else:
- new_type = "ProbeSet"
- self.datasets[short_dataset_name] = new_type
+
+ data = Redis.get("dataset_structure")
+ if data:
+ self.datasets = json.loads(data)
+ else: #ZS: I don't think this should ever run unless Redis is emptied
+ try:
+ data = json.loads(requests.get(GN2_BASE_URL + "/api/v_pre1/gen_dropdown", timeout = 5).content)
+ for species in data['datasets']:
+ for group in data['datasets'][species]:
+ for dataset_type in data['datasets'][species][group]:
+ for dataset in data['datasets'][species][group][dataset_type]:
+ short_dataset_name = dataset[1]
+ if dataset_type == "Phenotypes":
+ new_type = "Publish"
+ elif dataset_type == "Genotypes":
+ new_type = "Geno"
+ else:
+ new_type = "ProbeSet"
+ self.datasets[short_dataset_name] = new_type
+ except:
+ pass
+
+ Redis.set("dataset_structure", json.dumps(self.datasets))
# Set LOG_LEVEL_DEBUG=5 to see the following:
logger.debugf(5, "datasets",self.datasets)
@@ -127,6 +134,7 @@ Publish or ProbeSet. E.g.
results = g.db.execute(geno_query).fetchall()
if len(results):
self.datasets[name] = "ProbeSet"
+ Redis.set("dataset_structure", json.dumps(self.datasets))
return self.datasets[name]
group_name = name.replace("Publish", "")
@@ -140,6 +148,7 @@ Publish or ProbeSet. E.g.
results = g.db.execute(pheno_query).fetchall()
if len(results):
self.datasets[name] = "Publish"
+ Redis.set("dataset_structure", json.dumps(self.datasets))
return self.datasets[name]
#ZS: For when there isn't an InfoFiles ID; not sure if this and the preceding query are both necessary
@@ -151,6 +160,7 @@ Publish or ProbeSet. E.g.
results = g.db.execute(other_pheno_query).fetchall()
if len(results):
self.datasets[name] = "Publish"
+ Redis.set("dataset_structure", json.dumps(self.datasets))
return self.datasets[name]
geno_query = """
@@ -166,11 +176,11 @@ Publish or ProbeSet. E.g.
results = g.db.execute(geno_query).fetchall()
if len(results):
self.datasets[name] = "Geno"
+ Redis.set("dataset_structure", json.dumps(self.datasets))
return self.datasets[name]
#ZS: It shouldn't ever reach this
return None
-
else:
return self.datasets[name]