Skip to content

Commit

Permalink
Move vasp inputs to fp_config (#85)
Browse files Browse the repository at this point in the history
* mv vasp_inputs to fp_config

* fix UTs

* fix UTs

* fix mocked ops

* fix bugs

* fix bug of import

* do not do strict argcheck in run vasp op

Co-authored-by: Han Wang <wang_han@iapcm.ac.cn>
  • Loading branch information
wanghan-iapcm and Han Wang committed Oct 14, 2022
1 parent 2f6643e commit c8bea40
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 46 deletions.
2 changes: 1 addition & 1 deletion dpgen2/entrypoint/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ def workflow_concurrent_learning(
incar_template_name = incar_file,
potcar_names = fp_pp_files,
)
fp_config['inputs'] = fp_inputs
init_data_prefix = config.get('init_data_prefix') if old_style else config['inputs']['init_data_prefix']
init_data = config['init_data_sys'] if old_style else config['inputs']['init_data_sys']
if init_data_prefix is not None:
Expand All @@ -374,7 +375,6 @@ def workflow_concurrent_learning(
"train_config" : train_config,
"lmp_config" : lmp_config,
"fp_config" : fp_config,
'fp_inputs' : fp_inputs,
"exploration_scheduler" : scheduler,
},
artifacts = {
Expand Down
5 changes: 0 additions & 5 deletions dpgen2/flow/dpgen_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ def __init__(
"fp_config" : InputParameter(),
"exploration_scheduler" : InputParameter(),
"lmp_task_grp" : InputParameter(),
"fp_inputs" : InputParameter(),
}
self._input_artifacts={
"init_models" : InputArtifact(optional=True),
Expand Down Expand Up @@ -220,7 +219,6 @@ def __init__(
"train_config" : InputParameter(),
"lmp_config" : InputParameter(),
"fp_config" : InputParameter(),
"fp_inputs" : InputParameter(),
"exploration_scheduler" : InputParameter(),
}
self._input_artifacts={
Expand Down Expand Up @@ -313,7 +311,6 @@ def _loop (
"lmp_config" : steps.inputs.parameters["lmp_config"],
"conf_selector" : steps.inputs.parameters["conf_selector"],
"fp_config" : steps.inputs.parameters["fp_config"],
"fp_inputs" : steps.inputs.parameters["fp_inputs"],
"lmp_task_grp" : steps.inputs.parameters["lmp_task_grp"],
},
artifacts={
Expand Down Expand Up @@ -375,7 +372,6 @@ def _loop (
"lmp_config" : steps.inputs.parameters["lmp_config"],
"conf_selector" : scheduler_step.outputs.parameters["conf_selector"],
"fp_config" : steps.inputs.parameters["fp_config"],
"fp_inputs" : steps.inputs.parameters["fp_inputs"],
"exploration_scheduler" : scheduler_step.outputs.parameters["exploration_scheduler"],
"lmp_task_grp" : scheduler_step.outputs.parameters["lmp_task_grp"],
},
Expand Down Expand Up @@ -473,7 +469,6 @@ def _dpgen(
"conf_selector" : scheduler_step.outputs.parameters['conf_selector'],
"lmp_config" : steps.inputs.parameters['lmp_config'],
"fp_config" : steps.inputs.parameters['fp_config'],
"fp_inputs" : steps.inputs.parameters['fp_inputs'],
"exploration_scheduler" : scheduler_step.outputs.parameters['exploration_scheduler'],
"lmp_task_grp" : scheduler_step.outputs.parameters['lmp_task_grp'],
},
Expand Down
6 changes: 3 additions & 3 deletions dpgen2/op/prep_vasp.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class PrepVasp(OP):
@classmethod
def get_input_sign(cls):
return OPIOSign({
"config" : BigParameter(dict),
"type_map": List[str],
"inputs": BigParameter(VaspInputs),
"confs" : Artifact(List[Path]),
})

Expand All @@ -66,7 +66,7 @@ def execute(
ip : dict
Input dict with components:
- `inputs` : (`VaspInputs`) Definitions for the VASP inputs
- `config` : (`dict`) Should have `config['inputs']`, which is of type `VaspInputs` and definites the VASP inputs
- `confs` : (`Artifact(List[Path])`) Configurations for the VASP tasks. Stored in folders as deepmd/npy format. Can be parsed as dpdata.MultiSystems.
Returns
Expand All @@ -78,7 +78,7 @@ def execute(
- `task_paths`: (`Artifact(List[Path])`) The parepared working paths of the tasks. Contains all input files needed to start the VASP. The order fo the Paths should be consistent with `op["task_names"]`
"""

inputs = ip['inputs']
inputs = ip['config']['inputs']
confs = ip['confs']
type_map = ip['type_map']

Expand Down
9 changes: 5 additions & 4 deletions dpgen2/op/run_vasp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Artifact,
TransientError,
FatalError,
BigParameter,
)
import os, json, dpdata
from pathlib import Path
Expand Down Expand Up @@ -44,7 +45,7 @@ class RunVasp(OP):
@classmethod
def get_input_sign(cls):
return OPIOSign({
"config" : dict,
"config" : BigParameter(dict),
"task_name": str,
"task_path" : Artifact(Path),
})
Expand Down Expand Up @@ -85,7 +86,7 @@ def execute(
On the failure of VASP execution.
"""
config = ip['config'] if ip['config'] is not None else {}
config = RunVasp.normalize_config(config)
config = RunVasp.normalize_config(config, strict=False)
command = config['command']
log_name = config['log']
out_name = config['out']
Expand Down Expand Up @@ -131,11 +132,11 @@ def vasp_args():
]

@staticmethod
def normalize_config(data = {}):
def normalize_config(data = {}, strict=True):
ta = RunVasp.vasp_args()
base = Argument("base", dict, ta)
data = base.normalize_value(data, trim_pattern="_*")
base.check_value(data, strict=True)
base.check_value(data, strict=strict)
return data


Expand Down
2 changes: 0 additions & 2 deletions dpgen2/superop/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def __init__(
"conf_selector" : InputParameter(),
"fp_config" : InputParameter(),
"lmp_task_grp" : InputParameter(),
"fp_inputs" : InputParameter(),
}
self._input_artifacts={
"init_models" : InputArtifact(optional=True),
Expand Down Expand Up @@ -214,7 +213,6 @@ def _block_cl(
parameters={
"block_id" : block_steps.inputs.parameters['block_id'],
"fp_config": block_steps.inputs.parameters['fp_config'],
"inputs": block_steps.inputs.parameters['fp_inputs'],
"type_map": block_steps.inputs.parameters["type_map"],
},
artifacts={
Expand Down
3 changes: 1 addition & 2 deletions dpgen2/superop/prep_run_fp.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def __init__(
"block_id" : InputParameter(type=str, value=""),
"fp_config" : InputParameter(),
"type_map" : InputParameter(),
"inputs": InputParameter(),
}
self._input_artifacts = {
"confs" : InputArtifact()
Expand Down Expand Up @@ -142,8 +141,8 @@ def _prep_run_fp(
**prep_template_config,
),
parameters={
"config" : prep_run_steps.inputs.parameters["fp_config"],
"type_map" : prep_run_steps.inputs.parameters['type_map'],
"inputs": prep_run_steps.inputs.parameters['inputs'],
},
artifacts={
"confs" : prep_run_steps.inputs.artifacts['confs'],
Expand Down
2 changes: 1 addition & 1 deletion tests/mocked_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def execute(
confs = ip['confs']
# incar_temp = ip['incar_temp']
# potcars = ip['potcars']
vasp_input = ip['inputs']
vasp_input = ip['config']['inputs']
type_map = ip['type_map']
if not (type_map == ['H', 'O']):
raise FatalError
Expand Down
2 changes: 1 addition & 1 deletion tests/op/test_prep_vasp.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test(self):
vi = VaspInputs(0.1, True, iincar, ipotcar)
op = PrepVasp()
opout = op.execute(OPIO({
'inputs': vi,
'config': {'inputs' : vi},
'confs' : self.confs,
'type_map' : self.type_map,
}))
Expand Down
3 changes: 1 addition & 2 deletions tests/test_block_cl.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,7 @@ def test(self):
"train_config" : {},
"lmp_config" : {},
"conf_selector" : self.conf_selector,
"fp_config" : {},
'fp_inputs' : self.vasp_inputs,
"fp_config" : {'inputs' : self.vasp_inputs},
"lmp_task_grp" : self.task_group_list,
},
artifacts = {
Expand Down
33 changes: 11 additions & 22 deletions tests/test_dpgen_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,7 @@ def test(self):
"template_script" : self.template_script,
"train_config" : {},
"lmp_config" : {},
"fp_config" : {},
'fp_inputs' : self.vasp_inputs,
"fp_config" : {'inputs' : self.vasp_inputs},
"exploration_scheduler" : self.scheduler,
},
artifacts = {
Expand Down Expand Up @@ -566,8 +565,7 @@ def test_update_artifact(self):
"template_script" : self.template_script,
"train_config" : {},
"lmp_config" : {},
"fp_config" : {},
'fp_inputs' : self.vasp_inputs,
"fp_config" : {'inputs' : self.vasp_inputs},
"exploration_scheduler" : self.scheduler_0,
},
artifacts = {
Expand Down Expand Up @@ -638,8 +636,7 @@ def test_update_artifact(self):
"template_script" : self.template_script,
"train_config" : {},
"lmp_config" : {},
"fp_config" : {},
'fp_inputs' : self.vasp_inputs,
"fp_config" : {'inputs' : self.vasp_inputs},
"exploration_scheduler" : self.scheduler_1,
},
artifacts = {
Expand Down Expand Up @@ -710,8 +707,7 @@ def test_update_artifact_scheduler(self):
"template_script" : self.template_script,
"train_config" : {},
"lmp_config" : {},
"fp_config" : {},
'fp_inputs' : self.vasp_inputs,
"fp_config" : {'inputs' : self.vasp_inputs},
"exploration_scheduler" : self.scheduler_0,
},
artifacts = {
Expand Down Expand Up @@ -791,8 +787,7 @@ def test_update_artifact_scheduler(self):
"template_script" : self.template_script,
"train_config" : {},
"lmp_config" : {},
"fp_config" : {},
'fp_inputs' : self.vasp_inputs,
"fp_config" : {'inputs' : self.vasp_inputs},
"exploration_scheduler" : self.scheduler_0,
},
artifacts = {
Expand Down Expand Up @@ -862,8 +857,7 @@ def test_update_slice_item_input(self):
"template_script" : self.template_script,
"train_config" : {},
"lmp_config" : {},
"fp_config" : {},
'fp_inputs' : self.vasp_inputs,
"fp_config" : {'inputs' : self.vasp_inputs},
"exploration_scheduler" : self.scheduler_0,
},
artifacts = {
Expand Down Expand Up @@ -930,8 +924,7 @@ def test_update_slice_item_input(self):
"template_script" : self.template_script,
"train_config" : {},
"lmp_config" : {},
"fp_config" : {},
'fp_inputs' : self.vasp_inputs,
"fp_config" : {'inputs' : self.vasp_inputs},
"exploration_scheduler" : self.scheduler_0,
},
artifacts = {
Expand Down Expand Up @@ -1013,8 +1006,7 @@ def test_update_slice_item_output(self):
"template_script" : self.template_script,
"train_config" : {},
"lmp_config" : {},
"fp_config" : {},
'fp_inputs' : self.vasp_inputs,
"fp_config" : {'inputs' : self.vasp_inputs},
"exploration_scheduler" : self.scheduler_0,
},
artifacts = {
Expand Down Expand Up @@ -1079,8 +1071,7 @@ def test_update_slice_item_output(self):
"template_script" : self.template_script,
"train_config" : {},
"lmp_config" : {},
"fp_config" : {},
'fp_inputs' : self.vasp_inputs,
"fp_config" : {'inputs' : self.vasp_inputs},
"exploration_scheduler" : self.scheduler_0,
},
artifacts = {
Expand Down Expand Up @@ -1164,8 +1155,7 @@ def test_update_slice_item_output_1(self):
"template_script" : self.template_script,
"train_config" : {},
"lmp_config" : {},
"fp_config" : {},
'fp_inputs' : self.vasp_inputs,
"fp_config" : {'inputs' : self.vasp_inputs},
"exploration_scheduler" : self.scheduler_0,
},
artifacts = {
Expand Down Expand Up @@ -1229,8 +1219,7 @@ def test_update_slice_item_output_1(self):
"template_script" : self.template_script,
"train_config" : {},
"lmp_config" : {},
"fp_config" : {},
'fp_inputs' : self.vasp_inputs,
"fp_config" : {'inputs' : self.vasp_inputs},
"exploration_scheduler" : self.scheduler_0,
},
artifacts = {
Expand Down
5 changes: 2 additions & 3 deletions tests/test_prep_run_vasp.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def test(self):
)
out = op.execute( OPIO({
'confs' : self.confs,
'inputs' : vasp_inputs,
'config' : {'inputs' : vasp_inputs},
'type_map' : self.type_map,
}) )
tdirs = check_vasp_tasks(self, self.ntasks)
Expand Down Expand Up @@ -234,9 +234,8 @@ def test(self):
'prep-run-step',
template = steps,
parameters = {
"fp_config": {},
'type_map' : self.type_map,
'inputs' : vasp_inputs,
'fp_config' : {'inputs' : vasp_inputs},
},
artifacts = {
"confs" : self.confs,
Expand Down

0 comments on commit c8bea40

Please sign in to comment.