Skip to content

Commit c3d115f

Browse files
committed
fix: require both property refine suffixes
Fixes #1903 Coding-Agent: Codex Codex-Version: codex-cli 0.149.0 Model: gpt-5.6-sol Reasoning-Effort: xhigh
1 parent d5ce577 commit c3d115f

2 files changed

Lines changed: 22 additions & 22 deletions

File tree

dpgen/auto_test/common_prop.py

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ def make_property_instance(parameters, inter_param):
4040
raise RuntimeError(f"unknown property type {prop_type}")
4141

4242

43+
def _property_suffix(parameters):
44+
"""Return the work suffix and whether the property is a refine job."""
45+
if "init_from_suffix" in parameters and "output_suffix" in parameters:
46+
return parameters["output_suffix"], True
47+
if parameters.get("reproduce", False):
48+
return "reprod", False
49+
return "00", False
50+
51+
4352
def make_property(confs, inter_param, property_list):
4453
# find all POSCARs and their name like mp-xxx
4554
# ...
@@ -54,15 +63,7 @@ def make_property(confs, inter_param, property_list):
5463
for jj in property_list:
5564
if jj.get("skip", False):
5665
continue
57-
if "init_from_suffix" and "output_suffix" in jj:
58-
do_refine = True
59-
suffix = jj["output_suffix"]
60-
elif "reproduce" in jj and jj["reproduce"]:
61-
do_refine = False
62-
suffix = "reprod"
63-
else:
64-
do_refine = False
65-
suffix = "00"
66+
suffix, do_refine = _property_suffix(jj)
6667
# generate working directory like mp-xxx/eos_00 if jj['type'] == 'eos'
6768
# handel the exception that the working directory exists
6869
# ...
@@ -117,12 +118,7 @@ def run_property(confs, inter_param, property_list, mdata):
117118
# ...
118119
if jj.get("skip", False):
119120
continue
120-
if "init_from_suffix" and "output_suffix" in jj:
121-
suffix = jj["output_suffix"]
122-
elif "reproduce" in jj and jj["reproduce"]:
123-
suffix = "reprod"
124-
else:
125-
suffix = "00"
121+
suffix, _ = _property_suffix(jj)
126122

127123
property_type = jj["type"]
128124
path_to_work = os.path.abspath(
@@ -234,12 +230,7 @@ def post_property(confs, inter_param, property_list):
234230
# ...
235231
if jj.get("skip", False):
236232
continue
237-
if "init_from_suffix" and "output_suffix" in jj:
238-
suffix = jj["output_suffix"]
239-
elif "reproduce" in jj and jj["reproduce"]:
240-
suffix = "reprod"
241-
else:
242-
suffix = "00"
233+
suffix, _ = _property_suffix(jj)
243234

244235
inter_param_prop = inter_param
245236
if "cal_setting" in jj and "overwrite_interaction" in jj["cal_setting"]:

tests/auto_test/test_make_prop.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from pymatgen.io.vasp import Incar
1313

14-
from dpgen.auto_test.common_prop import make_property
14+
from dpgen.auto_test.common_prop import _property_suffix, make_property
1515

1616
from .context import setUpModule # noqa: F401
1717

@@ -97,3 +97,12 @@ def test_make_eos(self):
9797
with open(os.path.join(ii, "POTCAR")) as fp:
9898
poti = fp.read()
9999
self.assertEqual(pot0, poti)
100+
101+
def test_output_suffix_alone_is_not_refine(self):
102+
self.assertEqual(_property_suffix({"output_suffix": "02"}), ("00", False))
103+
104+
def test_both_suffixes_enable_refine(self):
105+
self.assertEqual(
106+
_property_suffix({"init_from_suffix": "00", "output_suffix": "02"}),
107+
("02", True),
108+
)

0 commit comments

Comments
 (0)