#78 Revert "Rename argument "filter" to "subpath""

This reverts commit fdd6cca297.
This commit is contained in:
Alok Saldanha
2023-07-09 08:25:27 -04:00
parent 6607b15085
commit 624d1f8567
7 changed files with 25 additions and 16 deletions
-1
View File
@@ -58,7 +58,6 @@ class CacheEntry:
@classmethod
def for_key(cls, key, port):
return cls(
None,
key,
+4 -4
View File
@@ -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)
-2
View File
@@ -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)
+1 -1
View File
@@ -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
+5 -3
View File
@@ -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
View File
@@ -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