mirror of
https://github.com/Novartis/cellxgene-gateway.git
synced 2026-10-09 10:28:12 +08:00
#2 blackened
This commit is contained in:
@@ -30,7 +30,11 @@ class BackendCache:
|
|||||||
|
|
||||||
def check_entry(self, dataset):
|
def check_entry(self, dataset):
|
||||||
contents = self.entry_list
|
contents = self.entry_list
|
||||||
matches = [c for c in contents if c.dataset == dataset and c.status != "terminated"]
|
matches = [
|
||||||
|
c
|
||||||
|
for c in contents
|
||||||
|
if c.dataset == dataset and c.status != "terminated"
|
||||||
|
]
|
||||||
|
|
||||||
if len(matches) == 0:
|
if len(matches) == 0:
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ class CacheEntry:
|
|||||||
p.terminate()
|
p.terminate()
|
||||||
self.status = "terminated"
|
self.status = "terminated"
|
||||||
|
|
||||||
|
|
||||||
def serve_content(self, path):
|
def serve_content(self, path):
|
||||||
dataset = self.dataset
|
dataset = self.dataset
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ env_vars = {
|
|||||||
"GATEWAY_IP": ip,
|
"GATEWAY_IP": ip,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def validate():
|
def validate():
|
||||||
if not all(env_vars.values()):
|
if not all(env_vars.values()):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
from cellxgene_gateway import env
|
from cellxgene_gateway import env
|
||||||
from json import loads
|
from json import loads
|
||||||
|
|
||||||
|
|
||||||
def get_extra_scripts():
|
def get_extra_scripts():
|
||||||
# can be array of script tags to inject on every page, e.g. for google analytics could be
|
# can be array of script tags to inject on every page, e.g. for google analytics could be
|
||||||
# ['https://www.googletagmanager.com/gtag/js?id=UA-123456-2',
|
# ['https://www.googletagmanager.com/gtag/js?id=UA-123456-2',
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ def handle_invalid_usage(error):
|
|||||||
"cellxgene_error.html",
|
"cellxgene_error.html",
|
||||||
extra_scripts=get_extra_scripts(),
|
extra_scripts=get_extra_scripts(),
|
||||||
message=message,
|
message=message,
|
||||||
path=error.path
|
path=error.path,
|
||||||
),
|
),
|
||||||
error.http_status,
|
error.http_status,
|
||||||
)
|
)
|
||||||
@@ -187,11 +187,10 @@ def do_view(path):
|
|||||||
elif match.status == "error":
|
elif match.status == "error":
|
||||||
raise ProcessException.from_cache_entry(match)
|
raise ProcessException.from_cache_entry(match)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/cache_status", methods=["GET"])
|
@app.route("/cache_status", methods=["GET"])
|
||||||
def do_GET_status():
|
def do_GET_status():
|
||||||
return render_template(
|
return render_template("cache_status.html", entry_list=cache.entry_list)
|
||||||
"cache_status.html", entry_list=cache.entry_list
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/relaunch/<path:path>", methods=["GET"])
|
@app.route("/relaunch/<path:path>", methods=["GET"])
|
||||||
@@ -200,7 +199,8 @@ def do_relaunch(path):
|
|||||||
match = cache.check_entry(dataset)
|
match = cache.check_entry(dataset)
|
||||||
if not match is None:
|
if not match is None:
|
||||||
match.terminate()
|
match.terminate()
|
||||||
return redirect(url_for('do_view', path=path), code=302)
|
return redirect(url_for("do_view", path=path), code=302)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
env.validate()
|
env.validate()
|
||||||
|
|||||||
@@ -33,5 +33,4 @@ class PruneProcessCache:
|
|||||||
try:
|
try:
|
||||||
cache.prune(process)
|
cache.prune(process)
|
||||||
except Exception as detail:
|
except Exception as detail:
|
||||||
print('failed to prune process:', detail)
|
print("failed to prune process:", detail)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user