Skip to content

Commit cb634fd

Browse files
committed
Merge branch 'main' of github.com:janosh/atomate
2 parents 09da51f + 8419904 commit cb634fd

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

atomate/vasp/powerups.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,19 @@ def use_custodian(original_wf, fw_name_constraint=None, custodian_params=None):
8383
Returns:
8484
Workflow
8585
"""
86-
custodian_params = custodian_params if custodian_params else {}
86+
custodian_params = custodian_params or {}
8787
vasp_fws_and_tasks = get_fws_and_tasks(
8888
original_wf,
8989
fw_name_constraint=fw_name_constraint,
9090
task_name_constraint="RunVasp",
9191
)
9292
for idx_fw, idx_t in vasp_fws_and_tasks:
93-
if "vasp_cmd" not in custodian_params:
94-
custodian_params["vasp_cmd"] = original_wf.fws[idx_fw].tasks[idx_t][
95-
"vasp_cmd"
96-
]
93+
for param in (
94+
RunVaspCustodian.optional_params + RunVaspCustodian.required_params
95+
):
96+
value = original_wf.fws[idx_fw].tasks[idx_t].get(param, None)
97+
if value is not None and param not in custodian_params:
98+
custodian_params[param] = value
9799
original_wf.fws[idx_fw].tasks[idx_t] = RunVaspCustodian(**custodian_params)
98100
return original_wf
99101

@@ -723,12 +725,14 @@ def use_gamma_vasp(original_wf, gamma_vasp_cmd):
723725

724726
def modify_gzip_vasp(original_wf, gzip_output):
725727
"""
726-
For all RunVaspCustodian tasks, modify gzip_output boolean
728+
For all RunVaspCustodian tasks, modify gzip_output boolean.
729+
727730
Args:
728731
original_wf (Workflow)
729732
gzip_output (bool): Value to set gzip_output to for RunVaspCustodian
733+
730734
Returns:
731-
Workflow
735+
Workflow: Same workflow as passed in with in-place modified gzip_output.
732736
"""
733737
idx_list = get_fws_and_tasks(original_wf, task_name_constraint="RunVaspCustodian")
734738
for idx_fw, idx_t in idx_list:

atomate/vasp/tests/test_vasp_powerups.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from atomate.vasp.powerups import (
77
add_priority,
8+
modify_gzip_vasp,
89
use_custodian,
910
add_trackers,
1011
add_modify_incar,
@@ -64,21 +65,32 @@ def test_custodian_powerups(self):
6465
self.assertTrue("RunVaspDirect" in fw.tasks[task_idx]._fw_name)
6566
self.assertEqual(fw.tasks[task_idx]["vasp_cmd"], "test_VASP")
6667

67-
my_wf_double_relax = remove_custodian(copy_wf(self.bs_wf))
68-
my_wf_double_relax = use_custodian(
69-
my_wf_double_relax,
68+
wf_double_relax = remove_custodian(copy_wf(self.bs_wf))
69+
70+
wf_double_relax = use_custodian(
71+
wf_double_relax,
7072
fw_name_constraint="structure optimization",
7173
custodian_params={"job_type": "double_relaxation_run"},
7274
)
7375

74-
for fw in my_wf_double_relax.fws:
76+
for fw in wf_double_relax.fws:
7577
if "structure optimization" in fw.name:
7678
self.assertTrue("RunVaspCustodian" in fw.tasks[1]._fw_name)
7779
self.assertEqual(fw.tasks[1]["job_type"], "double_relaxation_run")
7880
else:
7981
self.assertTrue("RunVaspDirect" in fw.tasks[2]._fw_name)
8082
self.assertFalse("job_type" in fw.tasks[2])
8183

84+
# test use_custodian() does not overwrite existing custodian params
85+
wf_double_relax = modify_gzip_vasp(wf_double_relax, False)
86+
wf_double_relax = use_custodian(wf_double_relax)
87+
idx_list = get_fws_and_tasks(
88+
wf_double_relax, task_name_constraint="RunVaspCustodian"
89+
)
90+
for idx_fw, idx_t in idx_list:
91+
task = wf_double_relax.fws[idx_fw].tasks[idx_t]
92+
assert task["gzip_output"] is False
93+
8294
def test_modify_incar(self):
8395
my_wf = add_modify_incar(
8496
copy_wf(self.bs_wf),

0 commit comments

Comments
 (0)