From c3d115fc654bb852099115a0f2ccf2a0569c2f0c Mon Sep 17 00:00:00 2001 From: njzjz-bot Date: Mon, 24 Aug 2026 03:29:35 +0800 Subject: [PATCH] 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 --- dpgen/auto_test/common_prop.py | 33 +++++++++++-------------------- tests/auto_test/test_make_prop.py | 11 ++++++++++- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/dpgen/auto_test/common_prop.py b/dpgen/auto_test/common_prop.py index fd60b2bcf..2d515f78f 100644 --- a/dpgen/auto_test/common_prop.py +++ b/dpgen/auto_test/common_prop.py @@ -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 # ... @@ -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 # ... @@ -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( @@ -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"]: diff --git a/tests/auto_test/test_make_prop.py b/tests/auto_test/test_make_prop.py index 5e6649508..054677dd3 100644 --- a/tests/auto_test/test_make_prop.py +++ b/tests/auto_test/test_make_prop.py @@ -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 @@ -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), + )