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
6 changes: 3 additions & 3 deletions dpgen/data/reaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def run_reaxff(jdata, mdata, log_file="reaxff_log"):
[trj_path],
outlog=log_file,
errlog=log_file,
api_version=mdata.get("api_version", "0.9"),
api_version=mdata.get("api_version", "1.0"),
)


Expand Down Expand Up @@ -146,7 +146,7 @@ def run_build_dataset(jdata, mdata, log_file="build_log"):
[f"dataset_{dataset_name}_gjf"],
outlog=log_file,
errlog=log_file,
api_version=mdata.get("api_version", "0.9"),
api_version=mdata.get("api_version", "1.0"),
)


Expand Down Expand Up @@ -191,7 +191,7 @@ def run_fp(jdata, mdata, log_file="output", forward_common_files=[]):
[log_file],
outlog=log_file,
errlog=log_file,
api_version=mdata.get("api_version", "0.9"),
api_version=mdata.get("api_version", "1.0"),
)


Expand Down
2 changes: 1 addition & 1 deletion dpgen/data/surf.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ def run_vasp_relax(jdata, mdata):
forward_common_files,
forward_files,
backward_files,
api_version=mdata.get("api_version", "0.9"),
api_version=mdata.get("api_version", "1.0"),
)


Expand Down
64 changes: 64 additions & 0 deletions tests/data/test_init_api_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import unittest
from unittest.mock import patch

from dpgen.data import reaction, surf


class TestInitApiVersionDefaults(unittest.TestCase):
def test_reaction_stages_default_to_supported_api(self):
mdata = {
"reaxff_command": "lmp",
"reaxff_machine": {},
"reaxff_resources": {},
"build_command": "build",
"build_machine": {},
"build_resources": {"cpu_per_node": 1},
"fp_command": "fp",
"fp_machine": {},
"fp_resources": {"cpu_per_node": 1},
"fp_group_size": 1,
}
jdata = {
"type_map": ["H"],
"cutoff": 3.0,
"dataset_size": 1,
"qmkeywords": "force",
}

with (
patch.object(reaction.glob, "glob", return_value=["task.000"]),
patch.object(reaction, "make_submission_compat") as submit,
):
reaction.run_reaxff(jdata, mdata)
reaction.run_build_dataset(jdata, mdata)
reaction.run_fp(jdata, mdata)

self.assertEqual(submit.call_count, 3)
for call in submit.call_args_list:
self.assertEqual(call.kwargs["api_version"], "1.0")

def test_surface_relaxation_defaults_to_supported_api(self):
jdata = {"out_dir": "out"}
mdata = {
"fp_command": "vasp",
"fp_group_size": 1,
"fp_resources": {},
"fp_machine": {},
}

with (
patch.object(
surf.glob,
"glob",
side_effect=[[], ["out/02.md/sys-0000/scale-1.000/000000"]],
),
patch.object(surf, "_vasp_check_fin", return_value=False),
patch.object(surf, "make_submission_compat") as submit,
):
surf.run_vasp_relax(jdata, mdata)

self.assertEqual(submit.call_args.kwargs["api_version"], "1.0")


if __name__ == "__main__":
unittest.main()