Skip to content

Commit 8824949

Browse files
authored
Merge pull request #7 from zhaiwenxi/fix-dpa-tools-ci-tests
Fix dpa tools CI test stability
2 parents e938570 + 94ea40c commit 8824949

46 files changed

Lines changed: 101 additions & 2453 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/property_tools_tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ jobs:
3030
python -m pip install "numpy>=1.21,<2.2" pytest scikit-learn dpdata
3131
python -m pip install torch --index-url https://download.pytorch.org/whl/cpu
3232
33+
- name: Prepare source-tree version module
34+
run: |
35+
python -c "from pathlib import Path; Path('deepmd/_version.py').write_text('version = \\\"0+unknown\\\"\\n')"
36+
3337
- name: Run unit tests
3438
run: |
3539
python -m pytest source/tests/dpa_tools/ -v --ignore=source/tests/dpa_tools/test_trainer_dim_case_embd.py

deepmd/dpa_tools/_backend.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,15 @@ def load_torch_file(path: str, map_location: str = "cpu") -> dict[str, Any]:
5858
"""
5959
import torch
6060

61-
return torch.load(path, map_location=map_location, weights_only=False)
61+
try:
62+
return torch.load(path, map_location=map_location, weights_only=False)
63+
except RuntimeError as exc:
64+
if "Invalid magic number" not in str(exc):
65+
raise
66+
import pickle
67+
68+
with open(path, "rb") as f:
69+
return pickle.load(f)
6270

6371

6472
# ---------------------------------------------------------------------------
@@ -150,6 +158,8 @@ def _run_forward(self, coord, atype, box):
150158
torch.Tensor
151159
(n_frames, n_atoms, feat_dim), detached.
152160
"""
161+
if not coord.requires_grad:
162+
raise RuntimeError("forward_common requires coord to have requires_grad=True")
153163
self._clear_accumulator()
154164
self._inner_model.forward_common(coord, atype, box)
155165
return self._atomic_model.eval_descriptor().detach()

deepmd/dpa_tools/demo/dataset_demo.csv

Lines changed: 0 additions & 41 deletions
This file was deleted.

deepmd/dpa_tools/demo/mol_convert/id0.mol

Lines changed: 0 additions & 68 deletions
This file was deleted.

deepmd/dpa_tools/demo/mol_convert/id1.mol

Lines changed: 0 additions & 81 deletions
This file was deleted.

deepmd/dpa_tools/demo/mol_convert/id10.mol

Lines changed: 0 additions & 67 deletions
This file was deleted.

deepmd/dpa_tools/demo/mol_convert/id11.mol

Lines changed: 0 additions & 76 deletions
This file was deleted.

0 commit comments

Comments
 (0)