diff --git a/cellxgene_gateway/backend_cache.py b/cellxgene_gateway/backend_cache.py index e54654e..3fbf306 100644 --- a/cellxgene_gateway/backend_cache.py +++ b/cellxgene_gateway/backend_cache.py @@ -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() diff --git a/cellxgene_gateway/cache_entry.py b/cellxgene_gateway/cache_entry.py index 829d3c5..0a61441 100644 --- a/cellxgene_gateway/cache_entry.py +++ b/cellxgene_gateway/cache_entry.py @@ -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 diff --git a/cellxgene_gateway/env.py b/cellxgene_gateway/env.py index 828d07d..9e58c2b 100644 --- a/cellxgene_gateway/env.py +++ b/cellxgene_gateway/env.py @@ -25,6 +25,7 @@ env_vars = { "GATEWAY_IP": ip, } + def validate(): if not all(env_vars.values()): raise ValueError( diff --git a/cellxgene_gateway/extra_scripts.py b/cellxgene_gateway/extra_scripts.py index 14c2c30..db15ab0 100644 --- a/cellxgene_gateway/extra_scripts.py +++ b/cellxgene_gateway/extra_scripts.py @@ -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', diff --git a/cellxgene_gateway/gateway.py b/cellxgene_gateway/gateway.py index 0586655..c84af9e 100644 --- a/cellxgene_gateway/gateway.py +++ b/cellxgene_gateway/gateway.py @@ -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/", 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() diff --git a/cellxgene_gateway/prune_process_cache.py b/cellxgene_gateway/prune_process_cache.py index 1829d51..60afc99 100644 --- a/cellxgene_gateway/prune_process_cache.py +++ b/cellxgene_gateway/prune_process_cache.py @@ -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)