Skip to content

Commit 0a4736b

Browse files
committed
revert changes in expand_sys_str since the modification cannot process symlink
1 parent 6986773 commit 0a4736b

2 files changed

Lines changed: 3 additions & 19 deletions

File tree

deepmd/common.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ def expand_sys_str(root_dir: Union[str, Path]) -> list[str]:
202202
list of string pointing to system directories
203203
"""
204204
root_dir = DPPath(root_dir)
205-
matches = [str(p.parent) for p in root_dir.rglob("type.raw") if p.is_file()]
205+
matches = [str(d) for d in root_dir.rglob("*") if (d / "type.raw").is_file()]
206+
if (root_dir / "type.raw").is_file():
207+
matches.append(str(root_dir))
206208
return matches
207209

208210

deepmd/utils/path.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,6 @@ def mkdir(self, parents: bool = False, exist_ok: bool = False) -> None:
157157
If true, no error will be raised if the target directory already exists.
158158
"""
159159

160-
@property
161-
@abstractmethod
162-
def parent(self) -> "DPPath":
163-
"""Return the parent path."""
164-
165160

166161
class DPOSPath(DPPath):
167162
"""The OS path class to data system (DeepmdData) for real directories.
@@ -272,11 +267,6 @@ def name(self) -> str:
272267
"""Name of the path."""
273268
return self.path.name
274269

275-
@property
276-
def parent(self) -> "DPPath":
277-
"""Return the parent path."""
278-
return type(self)(self.path.parent, mode=self.mode)
279-
280270
def mkdir(self, parents: bool = False, exist_ok: bool = False) -> None:
281271
"""Make directory.
282272
@@ -479,14 +469,6 @@ def name(self) -> str:
479469
"""Name of the path."""
480470
return self._name.split("/")[-1]
481471

482-
@property
483-
def parent(self) -> "DPPath":
484-
"""Return the parent path."""
485-
parent_name = "/".join(self._name.split("/")[:-1])
486-
if not parent_name:
487-
parent_name = "/"
488-
return type(self)(f"{self.root_path}#{parent_name}", mode=self.mode)
489-
490472
def mkdir(self, parents: bool = False, exist_ok: bool = False) -> None:
491473
"""Make directory.
492474

0 commit comments

Comments
 (0)