mirror of
https://github.com/Novartis/cellxgene-gateway.git
synced 2026-09-15 12:47:59 +08:00
blacken
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user