mirror of
https://github.com/Novartis/cellxgene-gateway.git
synced 2026-09-28 03:08:12 +08:00
#2 blackened
This commit is contained in:
@@ -30,7 +30,11 @@ class BackendCache:
|
||||
|
||||
def check_entry(self, dataset):
|
||||
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:
|
||||
return None
|
||||
@@ -61,7 +65,7 @@ class BackendCache:
|
||||
time.sleep(1) # Automatic refresh is too fast, needs a second to pause
|
||||
|
||||
return entry
|
||||
|
||||
|
||||
def prune(self, process):
|
||||
self.entry_list.remove(process)
|
||||
process.terminate()
|
||||
|
||||
@@ -67,7 +67,7 @@ class CacheEntry:
|
||||
self.stderr = stderr
|
||||
self.http_status = http_status
|
||||
self.status = "error"
|
||||
|
||||
|
||||
def append_output(self, output):
|
||||
if self.all_output == None:
|
||||
self.all_output = output
|
||||
@@ -83,7 +83,6 @@ class CacheEntry:
|
||||
p.terminate()
|
||||
self.status = "terminated"
|
||||
|
||||
|
||||
def serve_content(self, path):
|
||||
dataset = self.dataset
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ env_vars = {
|
||||
"GATEWAY_IP": ip,
|
||||
}
|
||||
|
||||
|
||||
def validate():
|
||||
if not all(env_vars.values()):
|
||||
raise ValueError(
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
from cellxgene_gateway import env
|
||||
from json import loads
|
||||
|
||||
|
||||
def get_extra_scripts():
|
||||
# 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',
|
||||
|
||||
@@ -48,7 +48,7 @@ def handle_invalid_usage(error):
|
||||
"cellxgene_error.html",
|
||||
extra_scripts=get_extra_scripts(),
|
||||
message=message,
|
||||
path=error.path
|
||||
path=error.path,
|
||||
),
|
||||
error.http_status,
|
||||
)
|
||||
@@ -187,11 +187,10 @@ def do_view(path):
|
||||
elif match.status == "error":
|
||||
raise ProcessException.from_cache_entry(match)
|
||||
|
||||
|
||||
@app.route("/cache_status", methods=["GET"])
|
||||
def do_GET_status():
|
||||
return render_template(
|
||||
"cache_status.html", entry_list=cache.entry_list
|
||||
)
|
||||
return render_template("cache_status.html", entry_list=cache.entry_list)
|
||||
|
||||
|
||||
@app.route("/relaunch/<path:path>", methods=["GET"])
|
||||
@@ -200,7 +199,8 @@ def do_relaunch(path):
|
||||
match = cache.check_entry(dataset)
|
||||
if not match is None:
|
||||
match.terminate()
|
||||
return redirect(url_for('do_view', path=path), code=302)
|
||||
return redirect(url_for("do_view", path=path), code=302)
|
||||
|
||||
|
||||
def main():
|
||||
env.validate()
|
||||
|
||||
@@ -33,5 +33,4 @@ class PruneProcessCache:
|
||||
try:
|
||||
cache.prune(process)
|
||||
except Exception as detail:
|
||||
print('failed to prune process:', detail)
|
||||
|
||||
print("failed to prune process:", detail)
|
||||
|
||||
Reference in New Issue
Block a user