mirror of
https://github.com/Novartis/cellxgene-gateway.git
synced 2026-10-08 21:08:13 +08:00
#78 Revert "Rename argument "filter" to "subpath""
This reverts commit fdd6cca297.
This commit is contained in:
@@ -58,7 +58,6 @@ class CacheEntry:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def for_key(cls, key, port):
|
def for_key(cls, key, port):
|
||||||
|
|
||||||
return cls(
|
return cls(
|
||||||
None,
|
None,
|
||||||
key,
|
key,
|
||||||
|
|||||||
@@ -60,8 +60,8 @@ def render_item_tree(item_tree, item_source):
|
|||||||
return html
|
return html
|
||||||
|
|
||||||
|
|
||||||
def render_item_source(item_source, path=None):
|
def render_item_source(item_source, filter=None):
|
||||||
item_tree = item_source.list_items(path)
|
item_tree = item_source.list_items(filter)
|
||||||
path_part = "" if path is None else ":" + path
|
filterpart = "" if filter is None else ":" + filter
|
||||||
heading = f"<h6><a href='/filecrawl.html?source={urllib.parse.quote_plus(item_source.name)}'>{item_source.name}</a>{path_part}</h6>"
|
heading = f"<h6><a href='/filecrawl.html?source={urllib.parse.quote_plus(item_source.name)}'>{item_source.name}</a>{filterpart}</h6>"
|
||||||
return heading + render_item_tree(item_tree, item_source)
|
return heading + render_item_tree(item_tree, item_source)
|
||||||
|
|||||||
@@ -80,7 +80,6 @@ cache = BackendCache()
|
|||||||
|
|
||||||
@app.errorhandler(CellxgeneException)
|
@app.errorhandler(CellxgeneException)
|
||||||
def handle_invalid_usage(error):
|
def handle_invalid_usage(error):
|
||||||
|
|
||||||
message = f"{error.http_status} Error : {error.message}"
|
message = f"{error.http_status} Error : {error.message}"
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -95,7 +94,6 @@ def handle_invalid_usage(error):
|
|||||||
|
|
||||||
@app.errorhandler(ProcessException)
|
@app.errorhandler(ProcessException)
|
||||||
def handle_invalid_process(error):
|
def handle_invalid_process(error):
|
||||||
|
|
||||||
message = []
|
message = []
|
||||||
|
|
||||||
message.append(error.message)
|
message.append(error.message)
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ class FileItemSource(ItemSource):
|
|||||||
def get_annotations_subpath(self, item) -> str:
|
def get_annotations_subpath(self, item) -> str:
|
||||||
return self.convert_h5ad_path_to_annotation(item.descriptor)
|
return self.convert_h5ad_path_to_annotation(item.descriptor)
|
||||||
|
|
||||||
def list_items(self, subpath: str = None) -> ItemTree:
|
def list_items(self, filter: str = None) -> ItemTree:
|
||||||
item_tree = self.scan_directory("" if subpath is None else subpath)
|
item_tree = self.scan_directory("" if filter is None else filter)
|
||||||
|
|
||||||
"""def get_items(dir):
|
"""def get_items(dir):
|
||||||
if dir.branches:
|
if dir.branches:
|
||||||
@@ -102,7 +102,9 @@ class FileItemSource(ItemSource):
|
|||||||
]
|
]
|
||||||
# Exclude branches without files as leaves. Since traversal is applied pre-order,
|
# Exclude branches without files as leaves. Since traversal is applied pre-order,
|
||||||
# branch.branches has already been processed and we don't need to check deeper nesting.
|
# branch.branches has already been processed and we don't need to check deeper nesting.
|
||||||
branches = [branch for branch in branches if branch.items or branch.branches]
|
branches = [
|
||||||
|
branch for branch in branches if branch.items or branch.branches
|
||||||
|
]
|
||||||
|
|
||||||
return ItemTree(subpath, items, branches)
|
return ItemTree(subpath, items, branches)
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class LookupResult:
|
|||||||
|
|
||||||
class ItemSource(ABC):
|
class ItemSource(ABC):
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def list_items(self, subpath: str = None) -> List[Item]:
|
def list_items(self, filter: str = None) -> List[Item]:
|
||||||
raise Exception('"list_items" unimplemented')
|
raise Exception('"list_items" unimplemented')
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
|||||||
@@ -72,8 +72,8 @@ class S3ItemSource(ItemSource):
|
|||||||
def get_annotations_subpath(self, item) -> str:
|
def get_annotations_subpath(self, item) -> str:
|
||||||
return self.convert_h5ad_key_to_annotation(item.descriptor)
|
return self.convert_h5ad_key_to_annotation(item.descriptor)
|
||||||
|
|
||||||
def list_items(self, subpath: str = None) -> ItemTree:
|
def list_items(self, filter: str = None) -> ItemTree:
|
||||||
item_tree = self.scan_directory("" if subpath is None else subpath)
|
item_tree = self.scan_directory("" if filter is None else filter)
|
||||||
return item_tree
|
return item_tree
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -116,7 +116,9 @@ class S3ItemSource(ItemSource):
|
|||||||
branches = None
|
branches = None
|
||||||
if len(subdir_keys) > 0:
|
if len(subdir_keys) > 0:
|
||||||
branches = [self.scan_directory(key) for key in subdir_keys]
|
branches = [self.scan_directory(key) for key in subdir_keys]
|
||||||
branches = [branch for branch in branches if branch.items or branch.branches]
|
branches = [
|
||||||
|
branch for branch in branches if branch.items or branch.branches
|
||||||
|
]
|
||||||
|
|
||||||
return ItemTree(directory_key, items, branches)
|
return ItemTree(directory_key, items, branches)
|
||||||
|
|
||||||
|
|||||||
+10
-2
@@ -51,6 +51,7 @@ class TestRenderItemSource(unittest.TestCase):
|
|||||||
class TestRenderItemTree(unittest.TestCase):
|
class TestRenderItemTree(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
from cellxgene_gateway.gateway import app
|
from cellxgene_gateway.gateway import app
|
||||||
|
|
||||||
self.app = app
|
self.app = app
|
||||||
self.app_context = self.app.test_request_context()
|
self.app_context = self.app.test_request_context()
|
||||||
self.app_context.push()
|
self.app_context.push()
|
||||||
@@ -72,9 +73,16 @@ class TestRenderItemTree(unittest.TestCase):
|
|||||||
"</li></ul></li>",
|
"</li></ul></li>",
|
||||||
)
|
)
|
||||||
|
|
||||||
@patch("os.listdir", side_effect=lambda parent: defaultdict(list, {"tmp": ["foo"], "tmp/foo": ["bar"]})[parent])
|
@patch(
|
||||||
|
"os.listdir",
|
||||||
|
side_effect=lambda parent: defaultdict(
|
||||||
|
list, {"tmp": ["foo"], "tmp/foo": ["bar"]}
|
||||||
|
)[parent],
|
||||||
|
)
|
||||||
@patch("os.path.exists", return_value=True)
|
@patch("os.path.exists", return_value=True)
|
||||||
def test_GIVEN_dirs_without_h5ad_THEN_excludes_dirs_in_output(self, listdir, exists):
|
def test_GIVEN_dirs_without_h5ad_THEN_excludes_dirs_in_output(
|
||||||
|
self, listdir, exists
|
||||||
|
):
|
||||||
# Directories:
|
# Directories:
|
||||||
# - tmp
|
# - tmp
|
||||||
# - foo
|
# - foo
|
||||||
|
|||||||
Reference in New Issue
Block a user