Skip to content

Commit

Permalink
support DP 2.x inference (#162)
Browse files Browse the repository at this point in the history
* support DP 2.x inference

which has a breaking change in the inference interface

* update another place where deepmd is imported
  • Loading branch information
njzjz authored Jun 7, 2021
1 parent 5a93f08 commit 76e6892
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions dpdata/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,12 @@ def predict(self, dp):
labeled_sys LabeledSystem
The labeled system.
"""
import deepmd.DeepPot as DeepPot
try:
# DP 1.x
import deepmd.DeepPot as DeepPot
except ModuleNotFoundError:
# DP 2.x
from deepmd.infer import DeepPot
if not isinstance(dp, DeepPot):
dp = DeepPot(dp)
type_map = dp.get_type_map()
Expand Down Expand Up @@ -1800,7 +1805,12 @@ def from_deepmd_npy(self, folder):
return self

def predict(self, dp):
import deepmd.DeepPot as DeepPot
try:
# DP 1.x
import deepmd.DeepPot as DeepPot
except ModuleNotFoundError:
# DP 2.x
from deepmd.infer import DeepPot
if not isinstance(dp, DeepPot):
dp = DeepPot(dp)
new_multisystems = dpdata.MultiSystems()
Expand Down

0 comments on commit 76e6892

Please sign in to comment.