mirror of
https://github.com/Novartis/cellxgene-gateway.git
synced 2026-09-27 23:38:11 +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
|
||||
def for_key(cls, key, port):
|
||||
|
||||
return cls(
|
||||
None,
|
||||
key,
|
||||
|
||||
@@ -60,8 +60,8 @@ def render_item_tree(item_tree, item_source):
|
||||
return html
|
||||
|
||||
|
||||
def render_item_source(item_source, path=None):
|
||||
item_tree = item_source.list_items(path)
|
||||
path_part = "" if path is None else ":" + path
|
||||
heading = f"<h6><a href='/filecrawl.html?source={urllib.parse.quote_plus(item_source.name)}'>{item_source.name}</a>{path_part}</h6>"
|
||||
def render_item_source(item_source, filter=None):
|
||||
item_tree = item_source.list_items(filter)
|
||||
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>{filterpart}</h6>"
|
||||
return heading + render_item_tree(item_tree, item_source)
|
||||
|
||||
@@ -80,7 +80,6 @@ cache = BackendCache()
|
||||
|
||||
@app.errorhandler(CellxgeneException)
|
||||
def handle_invalid_usage(error):
|
||||
|
||||
message = f"{error.http_status} Error : {error.message}"
|
||||
|
||||
return (
|
||||
@@ -95,7 +94,6 @@ def handle_invalid_usage(error):
|
||||
|
||||
@app.errorhandler(ProcessException)
|
||||
def handle_invalid_process(error):
|
||||
|
||||
message = []
|
||||
|
||||
message.append(error.message)
|
||||
|
||||
@@ -50,8 +50,8 @@ class FileItemSource(ItemSource):
|
||||
def get_annotations_subpath(self, item) -> str:
|
||||
return self.convert_h5ad_path_to_annotation(item.descriptor)
|
||||
|
||||
def list_items(self, subpath: str = None) -> ItemTree:
|
||||
item_tree = self.scan_directory("" if subpath is None else subpath)
|
||||
def list_items(self, filter: str = None) -> ItemTree:
|
||||
item_tree = self.scan_directory("" if filter is None else filter)
|
||||
|
||||
"""def get_items(dir):
|
||||
if dir.branches:
|
||||
@@ -102,7 +102,9 @@ class FileItemSource(ItemSource):
|
||||
]
|
||||
# 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.
|
||||
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)
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class LookupResult:
|
||||
|
||||
class ItemSource(ABC):
|
||||
@abstractmethod
|
||||
def list_items(self, subpath: str = None) -> List[Item]:
|
||||
def list_items(self, filter: str = None) -> List[Item]:
|
||||
raise Exception('"list_items" unimplemented')
|
||||
|
||||
@abstractmethod
|
||||
|
||||
@@ -72,8 +72,8 @@ class S3ItemSource(ItemSource):
|
||||
def get_annotations_subpath(self, item) -> str:
|
||||
return self.convert_h5ad_key_to_annotation(item.descriptor)
|
||||
|
||||
def list_items(self, subpath: str = None) -> ItemTree:
|
||||
item_tree = self.scan_directory("" if subpath is None else subpath)
|
||||
def list_items(self, filter: str = None) -> ItemTree:
|
||||
item_tree = self.scan_directory("" if filter is None else filter)
|
||||
return item_tree
|
||||
|
||||
@property
|
||||
@@ -116,7 +116,9 @@ class S3ItemSource(ItemSource):
|
||||
branches = None
|
||||
if len(subdir_keys) > 0:
|
||||
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)
|
||||
|
||||
|
||||
+10
-2
@@ -51,6 +51,7 @@ class TestRenderItemSource(unittest.TestCase):
|
||||
class TestRenderItemTree(unittest.TestCase):
|
||||
def setUp(self):
|
||||
from cellxgene_gateway.gateway import app
|
||||
|
||||
self.app = app
|
||||
self.app_context = self.app.test_request_context()
|
||||
self.app_context.push()
|
||||
@@ -72,9 +73,16 @@ class TestRenderItemTree(unittest.TestCase):
|
||||
"</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)
|
||||
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:
|
||||
# - tmp
|
||||
# - foo
|
||||
|
||||
Reference in New Issue
Block a user