Skip to content

Commit

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

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
  • Loading branch information
njzjz committed Sep 20, 2024
1 parent c084b20 commit 8dd3b4c
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 8dd3b4c

Please sign in to comment.