Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 12 additions & 21 deletions dpgen/auto_test/common_prop.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ def make_property_instance(parameters, inter_param):
raise RuntimeError(f"unknown property type {prop_type}")


def _property_suffix(parameters):
"""Return the work suffix and whether the property is a refine job."""
if "init_from_suffix" in parameters and "output_suffix" in parameters:
return parameters["output_suffix"], True
if parameters.get("reproduce", False):
return "reprod", False
return "00", False


def make_property(confs, inter_param, property_list):
# find all POSCARs and their name like mp-xxx
# ...
Expand All @@ -54,15 +63,7 @@ def make_property(confs, inter_param, property_list):
for jj in property_list:
if jj.get("skip", False):
continue
if "init_from_suffix" and "output_suffix" in jj:
do_refine = True
suffix = jj["output_suffix"]
elif "reproduce" in jj and jj["reproduce"]:
do_refine = False
suffix = "reprod"
else:
do_refine = False
suffix = "00"
suffix, do_refine = _property_suffix(jj)
# generate working directory like mp-xxx/eos_00 if jj['type'] == 'eos'
# handel the exception that the working directory exists
# ...
Expand Down Expand Up @@ -117,12 +118,7 @@ def run_property(confs, inter_param, property_list, mdata):
# ...
if jj.get("skip", False):
continue
if "init_from_suffix" and "output_suffix" in jj:
suffix = jj["output_suffix"]
elif "reproduce" in jj and jj["reproduce"]:
suffix = "reprod"
else:
suffix = "00"
suffix, _ = _property_suffix(jj)

property_type = jj["type"]
path_to_work = os.path.abspath(
Expand Down Expand Up @@ -234,12 +230,7 @@ def post_property(confs, inter_param, property_list):
# ...
if jj.get("skip", False):
continue
if "init_from_suffix" and "output_suffix" in jj:
suffix = jj["output_suffix"]
elif "reproduce" in jj and jj["reproduce"]:
suffix = "reprod"
else:
suffix = "00"
suffix, _ = _property_suffix(jj)

inter_param_prop = inter_param
if "cal_setting" in jj and "overwrite_interaction" in jj["cal_setting"]:
Expand Down
11 changes: 10 additions & 1 deletion tests/auto_test/test_make_prop.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from pymatgen.io.vasp import Incar

from dpgen.auto_test.common_prop import make_property
from dpgen.auto_test.common_prop import _property_suffix, make_property

from .context import setUpModule # noqa: F401

Expand Down Expand Up @@ -97,3 +97,12 @@ def test_make_eos(self):
with open(os.path.join(ii, "POTCAR")) as fp:
poti = fp.read()
self.assertEqual(pot0, poti)

def test_output_suffix_alone_is_not_refine(self):
self.assertEqual(_property_suffix({"output_suffix": "02"}), ("00", False))

def test_both_suffixes_enable_refine(self):
self.assertEqual(
_property_suffix({"init_from_suffix": "00", "output_suffix": "02"}),
("02", True),
)