mirror of
https://github.com/Novartis/cellxgene-gateway.git
synced 2026-10-11 02:50:55 +08:00
blackened code
This commit is contained in:
@@ -26,6 +26,7 @@ class CacheEntryStatus(Enum):
|
|||||||
error = "error"
|
error = "error"
|
||||||
terminated = "terminated"
|
terminated = "terminated"
|
||||||
|
|
||||||
|
|
||||||
class CacheEntry:
|
class CacheEntry:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
|||||||
@@ -24,15 +24,16 @@ external_protocol = os.environ.get(
|
|||||||
ip = os.environ.get("GATEWAY_IP")
|
ip = os.environ.get("GATEWAY_IP")
|
||||||
extra_scripts = os.environ.get("GATEWAY_EXTRA_SCRIPTS")
|
extra_scripts = os.environ.get("GATEWAY_EXTRA_SCRIPTS")
|
||||||
ttl = os.environ.get("GATEWAY_TTL")
|
ttl = os.environ.get("GATEWAY_TTL")
|
||||||
enable_upload = os.environ.get(
|
enable_upload = os.environ.get("GATEWAY_ENABLE_UPLOAD", "").lower() in [
|
||||||
"GATEWAY_ENABLE_UPLOAD", ""
|
"true",
|
||||||
).lower() in ["true", "1"]
|
"1",
|
||||||
|
]
|
||||||
enable_annotations = os.environ.get(
|
enable_annotations = os.environ.get(
|
||||||
"GATEWAY_ENABLE_ANNOTATIONS", ""
|
"GATEWAY_ENABLE_ANNOTATIONS", ""
|
||||||
).lower() in ["true", "1"]
|
).lower() in ["true", "1"]
|
||||||
enable_backed_mode = os.environ.get(
|
enable_backed_mode = os.environ.get(
|
||||||
"GATEWAY_ENABLE_BACKED_MODE", ""
|
"GATEWAY_ENABLE_BACKED_MODE", ""
|
||||||
).lower() in ['true', '1']
|
).lower() in ["true", "1"]
|
||||||
|
|
||||||
env_vars = {
|
env_vars = {
|
||||||
"CELLXGENE_LOCATION": cellxgene_location,
|
"CELLXGENE_LOCATION": cellxgene_location,
|
||||||
|
|||||||
@@ -9,7 +9,12 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
from cellxgene_gateway import env
|
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):
|
def recurse_dir(path):
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
@@ -18,6 +23,7 @@ def recurse_dir(path):
|
|||||||
)
|
)
|
||||||
|
|
||||||
all_entries = sorted(os.listdir(path))
|
all_entries = sorted(os.listdir(path))
|
||||||
|
|
||||||
def is_h5ad(el):
|
def is_h5ad(el):
|
||||||
return el.endswith(".h5ad") and os.path.isfile(os.path.join(path, el))
|
return el.endswith(".h5ad") and os.path.isfile(os.path.join(path, el))
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
from flask import request
|
from flask import request
|
||||||
|
|
||||||
|
|
||||||
def querystring():
|
def querystring():
|
||||||
qs = request.query_string.decode()
|
qs = request.query_string.decode()
|
||||||
return f'?{qs}' if len(qs) > 0 else ''
|
return f"?{qs}" if len(qs) > 0 else ""
|
||||||
|
|||||||
@@ -236,7 +236,10 @@ def do_view(path):
|
|||||||
|
|
||||||
match.timestamp = current_time_stamp()
|
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)
|
return match.serve_content(path)
|
||||||
elif match.status == CacheEntryStatus.error:
|
elif match.status == CacheEntryStatus.error:
|
||||||
raise ProcessException.from_cache_entry(match)
|
raise ProcessException.from_cache_entry(match)
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ from cellxgene_gateway.path_util import get_annotation_file_path, get_file_path
|
|||||||
from cellxgene_gateway.process_exception import ProcessException
|
from cellxgene_gateway.process_exception import ProcessException
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SubprocessBackend:
|
class SubprocessBackend:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
@@ -29,7 +28,9 @@ class SubprocessBackend:
|
|||||||
):
|
):
|
||||||
if enable_annotations and not annotation_file_path is None:
|
if enable_annotations and not annotation_file_path is None:
|
||||||
if annotation_file_path == "":
|
if annotation_file_path == "":
|
||||||
extra_args = f" --annotations-dir {make_annotations(file_path)}"
|
extra_args = (
|
||||||
|
f" --annotations-dir {make_annotations(file_path)}"
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
extra_args = f" --annotations-file {annotation_file_path}"
|
extra_args = f" --annotations-file {annotation_file_path}"
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -9,5 +9,6 @@ class TestCacheEntry(unittest.TestCase):
|
|||||||
entry = CacheEntry.for_key("some-key", 1)
|
entry = CacheEntry.for_key("some-key", 1)
|
||||||
self.assertEqual(entry.status, CacheEntryStatus.loading)
|
self.assertEqual(entry.status, CacheEntryStatus.loading)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class TestRenderEntry(unittest.TestCase):
|
|||||||
"path": "/somepath/",
|
"path": "/somepath/",
|
||||||
"name": "entry",
|
"name": "entry",
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"annotations": []
|
"annotations": [],
|
||||||
}
|
}
|
||||||
rendered = render_entry(entry)
|
rendered = render_entry(entry)
|
||||||
self.assertIn("view/somepath", rendered)
|
self.assertIn("view/somepath", rendered)
|
||||||
@@ -20,7 +20,7 @@ class TestRenderEntry(unittest.TestCase):
|
|||||||
"path": "/somepath",
|
"path": "/somepath",
|
||||||
"name": "entry",
|
"name": "entry",
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"annotations": []
|
"annotations": [],
|
||||||
}
|
}
|
||||||
rendered = render_entry(entry)
|
rendered = render_entry(entry)
|
||||||
self.assertIn("view/somepath", rendered)
|
self.assertIn("view/somepath", rendered)
|
||||||
@@ -30,7 +30,7 @@ class TestRenderEntry(unittest.TestCase):
|
|||||||
"path": "somepath/",
|
"path": "somepath/",
|
||||||
"name": "entry",
|
"name": "entry",
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"annotations": []
|
"annotations": [],
|
||||||
}
|
}
|
||||||
rendered = render_entry(entry)
|
rendered = render_entry(entry)
|
||||||
self.assertIn("view/somepath", rendered)
|
self.assertIn("view/somepath", rendered)
|
||||||
@@ -40,7 +40,7 @@ class TestRenderEntry(unittest.TestCase):
|
|||||||
"path": "somepath",
|
"path": "somepath",
|
||||||
"name": "entry",
|
"name": "entry",
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"annotations": []
|
"annotations": [],
|
||||||
}
|
}
|
||||||
rendered = render_entry(entry)
|
rendered = render_entry(entry)
|
||||||
self.assertIn("view/somepath", rendered)
|
self.assertIn("view/somepath", rendered)
|
||||||
|
|||||||
Reference in New Issue
Block a user