From 55b268125ff58c7a959b9dce25f23cdbf511af64 Mon Sep 17 00:00:00 2001 From: Alok Saldanha Date: Sat, 8 Nov 2025 17:23:47 -0500 Subject: [PATCH] blacken --- cellxgene_gateway/gateway.py | 34 ++++++++++++++++++------------- tests/test_cache_entry.py | 2 +- tests/test_gateway_status_json.py | 5 ++++- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/cellxgene_gateway/gateway.py b/cellxgene_gateway/gateway.py index 1c634ad..fd7bf45 100644 --- a/cellxgene_gateway/gateway.py +++ b/cellxgene_gateway/gateway.py @@ -93,14 +93,18 @@ def _init_on_first_wsgi_request(wsgi_app): if not data_sources_initialized: with data_sources_init_lock: if not app.extensions.get("cellxgene_gateway", {}).get("launchtime"): - app.extensions.setdefault("cellxgene_gateway", {})["launchtime"] = current_time_stamp() + app.extensions.setdefault("cellxgene_gateway", {})[ + "launchtime" + ] = current_time_stamp() if not data_sources_initialized: initialize_data_sources() env.validate() if not item_sources or not len(item_sources): - raise Exception("No data sources specified for Cellxgene Gateway") + raise Exception( + "No data sources specified for Cellxgene Gateway" + ) global default_item_source if default_item_source is None: @@ -318,24 +322,21 @@ def do_GET_status_json(): dataset = entry.key.h5ad_item.descriptor annotation_file = entry.key.annotation_descriptor return { - "dataset": dataset, - "annotation_file": annotation_file, - "launchtime": entry.launchtime, - "last_access": entry.timestamp, - "status": entry.status.name, - } - + "dataset": dataset, + "annotation_file": annotation_file, + "launchtime": entry.launchtime, + "last_access": entry.timestamp, + "status": entry.status.name, + } return json.dumps( { "launchtime": app.extensions.get("cellxgene_gateway", {}).get("launchtime"), - "entry_list": [ - map_entry(entry) - for entry in cache.entry_list - ], + "entry_list": [map_entry(entry) for entry in cache.entry_list], } ) + def get_cache_key(path): if request.args.get("source_name"): source_name = request.args.get("source_name") @@ -374,6 +375,7 @@ def ip_address(): resp = make_response(env.ip) return set_no_cache(resp) + def start_pruner_thread(): pruner = PruneProcessCache(cache) @@ -384,11 +386,15 @@ def start_pruner_thread(): def launch(): start_pruner_thread() - app.extensions.setdefault("cellxgene_gateway", {})["launchtime"] = current_time_stamp() + app.extensions.setdefault("cellxgene_gateway", {})[ + "launchtime" + ] = current_time_stamp() app.run(host="0.0.0.0", port=env.gateway_port, debug=False) + app.extensions.setdefault("cellxgene_gateway", {})["launchtime"] = None + def main(): """CLI entry point for Flask development server.""" launch() diff --git a/tests/test_cache_entry.py b/tests/test_cache_entry.py index f98b1dd..30463e7 100644 --- a/tests/test_cache_entry.py +++ b/tests/test_cache_entry.py @@ -27,7 +27,7 @@ class TestRenderEntry(unittest.TestCase): def tearDown(self): self.app_context.pop() - + def test_GIVEN_key_and_port_THEN_returns_loading_CacheEntry(self): entry = CacheEntry.for_key("some-key", 1) self.assertEqual(entry.status, CacheEntryStatus.loading) diff --git a/tests/test_gateway_status_json.py b/tests/test_gateway_status_json.py index 066cdc1..fba4888 100644 --- a/tests/test_gateway_status_json.py +++ b/tests/test_gateway_status_json.py @@ -10,7 +10,10 @@ class TestGatewayStatusJson(unittest.TestCase): def test_do_GET_status_json_returns_expected_structure(self): # Create a minimal fake key with required attributes h5ad_item = SimpleNamespace(descriptor="somedir/dataset.h5ad") - key = SimpleNamespace(h5ad_item=h5ad_item, annotation_descriptor="somedir/dataset_annotations/foo.csv") + key = SimpleNamespace( + h5ad_item=h5ad_item, + annotation_descriptor="somedir/dataset_annotations/foo.csv", + ) # Create a CacheEntry with known launchtime/timestamp/status entry = CacheEntry(