Skip to content

Commit

Permalink
view.ls: filter out path before trying to get metadata information (#517
Browse files Browse the repository at this point in the history
)
  • Loading branch information
skshetry authored Mar 23, 2024
1 parent 632a420 commit 5887a8b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/dvc_data/index/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,14 @@ def _node_factory(path_conv, key, children, *args):
def ls(self, root_key: DataIndexKey, detail=True):
self._index._ensure_loaded(root_key)

def _filter_fn(entry):
key = entry[0] if detail else entry
return self.filter_fn(key)

yield from filter(_filter_fn, self._index.ls(root_key, detail=detail))
if detail:
yield from (
(key, self._index._info_from_entry(key, entry))
for key, entry in self._index._trie.ls(root_key, with_values=True)
if self.filter_fn(key)
)
else:
yield from filter(self.filter_fn, self._index.ls(root_key, detail=False))

def has_node(self, key: DataIndexKey) -> bool:
return self.filter_fn(key) and self._index.has_node(key)
Expand Down

0 comments on commit 5887a8b

Please sign in to comment.