diff --git a/cellxgene_gateway/cache_entry.py b/cellxgene_gateway/cache_entry.py index 09108c9..438d612 100644 --- a/cellxgene_gateway/cache_entry.py +++ b/cellxgene_gateway/cache_entry.py @@ -26,6 +26,7 @@ class CacheEntryStatus(Enum): error = "error" terminated = "terminated" + class CacheEntry: def __init__( self, diff --git a/cellxgene_gateway/env.py b/cellxgene_gateway/env.py index 5650cb1..dc72f1a 100644 --- a/cellxgene_gateway/env.py +++ b/cellxgene_gateway/env.py @@ -24,15 +24,16 @@ external_protocol = os.environ.get( ip = os.environ.get("GATEWAY_IP") extra_scripts = os.environ.get("GATEWAY_EXTRA_SCRIPTS") ttl = os.environ.get("GATEWAY_TTL") -enable_upload = os.environ.get( - "GATEWAY_ENABLE_UPLOAD", "" -).lower() in ["true", "1"] +enable_upload = os.environ.get("GATEWAY_ENABLE_UPLOAD", "").lower() in [ + "true", + "1", +] enable_annotations = os.environ.get( "GATEWAY_ENABLE_ANNOTATIONS", "" ).lower() in ["true", "1"] enable_backed_mode = os.environ.get( "GATEWAY_ENABLE_BACKED_MODE", "" -).lower() in ['true', '1'] +).lower() in ["true", "1"] env_vars = { "CELLXGENE_LOCATION": cellxgene_location, diff --git a/cellxgene_gateway/filecrawl.py b/cellxgene_gateway/filecrawl.py index c505f66..cd265f6 100644 --- a/cellxgene_gateway/filecrawl.py +++ b/cellxgene_gateway/filecrawl.py @@ -9,7 +9,12 @@ import os from cellxgene_gateway import env -from cellxgene_gateway.dir_util import make_h5ad, make_annotations, annotations_suffix +from cellxgene_gateway.dir_util import ( + make_h5ad, + make_annotations, + annotations_suffix, +) + def recurse_dir(path): if not os.path.exists(path): @@ -18,6 +23,7 @@ def recurse_dir(path): ) all_entries = sorted(os.listdir(path)) + def is_h5ad(el): return el.endswith(".h5ad") and os.path.isfile(os.path.join(path, el)) diff --git a/cellxgene_gateway/flask_util.py b/cellxgene_gateway/flask_util.py index 112999f..9132929 100644 --- a/cellxgene_gateway/flask_util.py +++ b/cellxgene_gateway/flask_util.py @@ -9,6 +9,7 @@ from flask import request + def querystring(): qs = request.query_string.decode() - return f'?{qs}' if len(qs) > 0 else '' + return f"?{qs}" if len(qs) > 0 else "" diff --git a/cellxgene_gateway/gateway.py b/cellxgene_gateway/gateway.py index 227ee4b..c72b1b2 100644 --- a/cellxgene_gateway/gateway.py +++ b/cellxgene_gateway/gateway.py @@ -236,7 +236,10 @@ def do_view(path): match.timestamp = current_time_stamp() - if match.status == CacheEntryStatus.loaded or match.status == CacheEntryStatus.loading: + if ( + match.status == CacheEntryStatus.loaded + or match.status == CacheEntryStatus.loading + ): return match.serve_content(path) elif match.status == CacheEntryStatus.error: raise ProcessException.from_cache_entry(match) diff --git a/cellxgene_gateway/subprocess_backend.py b/cellxgene_gateway/subprocess_backend.py index 9c793b5..e68ec69 100644 --- a/cellxgene_gateway/subprocess_backend.py +++ b/cellxgene_gateway/subprocess_backend.py @@ -19,7 +19,6 @@ from cellxgene_gateway.path_util import get_annotation_file_path, get_file_path from cellxgene_gateway.process_exception import ProcessException - class SubprocessBackend: def __init__(self): pass @@ -29,7 +28,9 @@ class SubprocessBackend: ): if enable_annotations and not annotation_file_path is None: if annotation_file_path == "": - extra_args = f" --annotations-dir {make_annotations(file_path)}" + extra_args = ( + f" --annotations-dir {make_annotations(file_path)}" + ) else: extra_args = f" --annotations-file {annotation_file_path}" else: diff --git a/tests/test_cache_entry.py b/tests/test_cache_entry.py index b3a3c4b..c2563c7 100644 --- a/tests/test_cache_entry.py +++ b/tests/test_cache_entry.py @@ -9,5 +9,6 @@ class TestCacheEntry(unittest.TestCase): entry = CacheEntry.for_key("some-key", 1) self.assertEqual(entry.status, CacheEntryStatus.loading) + if __name__ == "__main__": unittest.main() diff --git a/tests/test_filecrawl.py b/tests/test_filecrawl.py index bf30259..8e4fc48 100644 --- a/tests/test_filecrawl.py +++ b/tests/test_filecrawl.py @@ -10,7 +10,7 @@ class TestRenderEntry(unittest.TestCase): "path": "/somepath/", "name": "entry", "type": "file", - "annotations": [] + "annotations": [], } rendered = render_entry(entry) self.assertIn("view/somepath", rendered) @@ -20,7 +20,7 @@ class TestRenderEntry(unittest.TestCase): "path": "/somepath", "name": "entry", "type": "file", - "annotations": [] + "annotations": [], } rendered = render_entry(entry) self.assertIn("view/somepath", rendered) @@ -30,7 +30,7 @@ class TestRenderEntry(unittest.TestCase): "path": "somepath/", "name": "entry", "type": "file", - "annotations": [] + "annotations": [], } rendered = render_entry(entry) self.assertIn("view/somepath", rendered) @@ -40,7 +40,7 @@ class TestRenderEntry(unittest.TestCase): "path": "somepath", "name": "entry", "type": "file", - "annotations": [] + "annotations": [], } rendered = render_entry(entry) self.assertIn("view/somepath", rendered)