Skip to content

Commit

Permalink
fix: fix DPH5Path.glob for new keys (#4152)
Browse files Browse the repository at this point in the history
Fix #4151.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Enhanced path filtering logic to include a broader range of keys when
generating subpaths.
  
- **Bug Fixes**
	- Improved the accuracy of path results returned by the `glob` method.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
  • Loading branch information
njzjz committed Sep 21, 2024
1 parent 81b9d20 commit d224fdd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion deepmd/utils/path.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import itertools
import os
from abc import (
ABC,
Expand Down Expand Up @@ -373,7 +374,11 @@ def glob(self, pattern: str) -> List["DPPath"]:
list of paths
"""
# got paths starts with current path first, which is faster
subpaths = [ii for ii in self._keys if ii.startswith(self._name)]
subpaths = [
ii
for ii in itertools.chain(self._keys, self._new_keys)
if ii.startswith(self._name)
]
return [
type(self)(f"{self.root_path}#{pp}", mode=self.mode)
for pp in globfilter(subpaths, self._connect_path(pattern))
Expand Down

0 comments on commit d224fdd

Please sign in to comment.