Skip to content

Commit

Permalink
Set common inputs to non_db
Browse files Browse the repository at this point in the history
Due to the updates in version 2.6 of `aiida-core`, the `to_aiida_type`
serializer is used as a default. Therefore, the validation fails for the
inputs defined in the common interfaces, as those are typically defined
as Python datatypes. Since these inputs are anyway not stored in the database, we fix it by explicitly setting `non_db = True` for those inputs.
  • Loading branch information
t-reents committed Nov 11, 2024
1 parent 24a1819 commit 7cf7d12
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/aiida_common_workflows/workflows/bands/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def define(cls, spec):
spec.input(
'engines.bands.options',
valid_type=dict,
non_db=True,
required=False,
help='Options for the bands calculation jobs.',
)
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,8 @@ def define(cls, spec):
The ports defined on the specification are the inputs that will be accepted by the ``get_builder`` method.
"""
super().define(spec)
spec.input(
'protocol',
valid_type=ChoiceType(('fast', 'moderate', 'precise', 'verification-PBE-v1', 'verification-PBE-v1-a0')),
default='moderate',
help='The protocol to use for the automated input generation. This value indicates the level of precision '
'of the results and computational cost that the input parameters will be selected for.',
spec.inputs['protocol'].valid_type = ChoiceType(
('fast', 'moderate', 'precise', 'verification-PBE-v1', 'verification-PBE-v1-a0')
)
spec.inputs['spin_type'].valid_type = ChoiceType((SpinType.NONE, SpinType.COLLINEAR, SpinType.NON_COLLINEAR))
spec.inputs['relax_type'].valid_type = ChoiceType(tuple(RelaxType))
Expand Down
8 changes: 2 additions & 6 deletions src/aiida_common_workflows/workflows/relax/cp2k/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,8 @@ def define(cls, spec):
The ports defined on the specification are the inputs that will be accepted by the ``get_builder`` method.
"""
super().define(spec)
spec.input(
'protocol',
valid_type=ChoiceType(('fast', 'moderate', 'precise', 'verification-PBE-v1', 'verification-PBE-v1-sirius')),
default='moderate',
help='The protocol to use for the automated input generation. This value indicates the level of precision '
'of the results and computational cost that the input parameters will be selected for.',
spec.inputs['protocol'].valid_type = ChoiceType(
('fast', 'moderate', 'precise', 'verification-PBE-v1', 'verification-PBE-v1-sirius')
)
spec.inputs['spin_type'].valid_type = ChoiceType((SpinType.NONE, SpinType.COLLINEAR))
spec.inputs['relax_type'].valid_type = ChoiceType(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def define(cls, spec):
('fast', 'moderate', 'precise', 'oxides_validation', 'verification-PBE-v1')
)
spec.input('engines.inpgen.code', valid_type=orm.Code, serializer=orm.load_code)
spec.input('engines.inpgen.options', valid_type=dict, required=False)
spec.input('engines.inpgen.options', non_db=True, valid_type=dict, required=False)
spec.inputs['engines']['relax']['code'].valid_type = CodeType('fleur.fleur')
spec.inputs['engines']['inpgen']['code'].valid_type = CodeType('fleur.inpgen')

Expand Down
6 changes: 6 additions & 0 deletions src/aiida_common_workflows/workflows/relax/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def define(cls, spec):
'protocol',
valid_type=ChoiceType(('fast', 'moderate', 'precise')),
default='moderate',
non_db=True,
help='The protocol to use for the automated input generation. This value indicates the level of precision '
'of the results and computational cost that the input parameters will be selected for.',
)
Expand Down Expand Up @@ -61,6 +62,7 @@ def define(cls, spec):
'magnetization_per_site',
valid_type=list,
required=False,
non_db=True,
help='The initial magnetization of the system. Should be a list of floats, where each float represents the '
'spin polarization in units of electrons, meaning the difference between spin up and spin down '
'electrons, for the site. This also corresponds to the magnetization of the site in Bohr magnetons '
Expand All @@ -70,19 +72,22 @@ def define(cls, spec):
'threshold_forces',
valid_type=float,
required=False,
non_db=True,
help='A real positive number indicating the target threshold for the forces in eV/Å. If not specified, '
'the protocol specification will select an appropriate value.',
)
spec.input(
'threshold_stress',
valid_type=float,
required=False,
non_db=True,
help='A real positive number indicating the target threshold for the stress in eV/Å^3. If not specified, '
'the protocol specification will select an appropriate value.',
)
spec.input(
'reference_workchain',
valid_type=orm.WorkChainNode,
non_db=True,
required=False,
help='The node of a previously completed process of the same type whose inputs should be taken into '
'account when generating inputs. This is important for particular workflows where certain inputs have '
Expand All @@ -106,5 +111,6 @@ def define(cls, spec):
'engines.relax.options',
valid_type=dict,
required=False,
non_db=True,
help='Options for the geometry optimization calculation jobs.',
)

0 comments on commit 7cf7d12

Please sign in to comment.