Skip to content

Commit efa2c64

Browse files
authored
Fix: Set common inputs to non_db (#339)
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.
1 parent 24a1819 commit efa2c64

File tree

7 files changed

+14
-15
lines changed

7 files changed

+14
-15
lines changed

src/aiida_common_workflows/cli/options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def convert(self, value, param, ctx):
107107

108108
duplicate = (
109109
QueryBuilder()
110-
.append(StructureData, filters={'extras._aiida_hash': structure.base.caching._get_hash()})
110+
.append(StructureData, filters={'extras._aiida_hash': structure.base.caching._compute_hash()})
111111
.first()
112112
)
113113

src/aiida_common_workflows/workflows/bands/generator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def define(cls, spec):
5252
spec.input(
5353
'engines.bands.options',
5454
valid_type=dict,
55+
non_db=True,
5556
required=False,
5657
help='Options for the bands calculation jobs.',
5758
)

src/aiida_common_workflows/workflows/relax/castep/generator.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,8 @@ def define(cls, spec):
4646
The ports defined on the specification are the inputs that will be accepted by the ``get_builder`` method.
4747
"""
4848
super().define(spec)
49-
spec.input(
50-
'protocol',
51-
valid_type=ChoiceType(('fast', 'moderate', 'precise', 'verification-PBE-v1', 'verification-PBE-v1-a0')),
52-
default='moderate',
53-
help='The protocol to use for the automated input generation. This value indicates the level of precision '
54-
'of the results and computational cost that the input parameters will be selected for.',
49+
spec.inputs['protocol'].valid_type = ChoiceType(
50+
('fast', 'moderate', 'precise', 'verification-PBE-v1', 'verification-PBE-v1-a0')
5551
)
5652
spec.inputs['spin_type'].valid_type = ChoiceType((SpinType.NONE, SpinType.COLLINEAR, SpinType.NON_COLLINEAR))
5753
spec.inputs['relax_type'].valid_type = ChoiceType(tuple(RelaxType))

src/aiida_common_workflows/workflows/relax/cp2k/generator.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,8 @@ def define(cls, spec):
157157
The ports defined on the specification are the inputs that will be accepted by the ``get_builder`` method.
158158
"""
159159
super().define(spec)
160-
spec.input(
161-
'protocol',
162-
valid_type=ChoiceType(('fast', 'moderate', 'precise', 'verification-PBE-v1', 'verification-PBE-v1-sirius')),
163-
default='moderate',
164-
help='The protocol to use for the automated input generation. This value indicates the level of precision '
165-
'of the results and computational cost that the input parameters will be selected for.',
160+
spec.inputs['protocol'].valid_type = ChoiceType(
161+
('fast', 'moderate', 'precise', 'verification-PBE-v1', 'verification-PBE-v1-sirius')
166162
)
167163
spec.inputs['spin_type'].valid_type = ChoiceType((SpinType.NONE, SpinType.COLLINEAR))
168164
spec.inputs['relax_type'].valid_type = ChoiceType(

src/aiida_common_workflows/workflows/relax/fleur/generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def define(cls, spec):
5757
('fast', 'moderate', 'precise', 'oxides_validation', 'verification-PBE-v1')
5858
)
5959
spec.input('engines.inpgen.code', valid_type=orm.Code, serializer=orm.load_code)
60-
spec.input('engines.inpgen.options', valid_type=dict, required=False)
60+
spec.input('engines.inpgen.options', non_db=True, valid_type=dict, required=False)
6161
spec.inputs['engines']['relax']['code'].valid_type = CodeType('fleur.fleur')
6262
spec.inputs['engines']['inpgen']['code'].valid_type = CodeType('fleur.inpgen')
6363

src/aiida_common_workflows/workflows/relax/generator.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def define(cls, spec):
3333
'protocol',
3434
valid_type=ChoiceType(('fast', 'moderate', 'precise')),
3535
default='moderate',
36+
non_db=True,
3637
help='The protocol to use for the automated input generation. This value indicates the level of precision '
3738
'of the results and computational cost that the input parameters will be selected for.',
3839
)
@@ -61,6 +62,7 @@ def define(cls, spec):
6162
'magnetization_per_site',
6263
valid_type=list,
6364
required=False,
65+
non_db=True,
6466
help='The initial magnetization of the system. Should be a list of floats, where each float represents the '
6567
'spin polarization in units of electrons, meaning the difference between spin up and spin down '
6668
'electrons, for the site. This also corresponds to the magnetization of the site in Bohr magnetons '
@@ -70,19 +72,22 @@ def define(cls, spec):
7072
'threshold_forces',
7173
valid_type=float,
7274
required=False,
75+
non_db=True,
7376
help='A real positive number indicating the target threshold for the forces in eV/Å. If not specified, '
7477
'the protocol specification will select an appropriate value.',
7578
)
7679
spec.input(
7780
'threshold_stress',
7881
valid_type=float,
7982
required=False,
83+
non_db=True,
8084
help='A real positive number indicating the target threshold for the stress in eV/Å^3. If not specified, '
8185
'the protocol specification will select an appropriate value.',
8286
)
8387
spec.input(
8488
'reference_workchain',
8589
valid_type=orm.WorkChainNode,
90+
non_db=True,
8691
required=False,
8792
help='The node of a previously completed process of the same type whose inputs should be taken into '
8893
'account when generating inputs. This is important for particular workflows where certain inputs have '
@@ -106,5 +111,6 @@ def define(cls, spec):
106111
'engines.relax.options',
107112
valid_type=dict,
108113
required=False,
114+
non_db=True,
109115
help='Options for the geometry optimization calculation jobs.',
110116
)

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def define(cls, spec):
8787

8888
if inputs_dict is not None:
8989
for k, val in inputs_dict.items():
90-
spec.input(k, valid_type=val)
90+
spec.input(k, valid_type=val, non_db=True)
9191

9292
def _construct_builder(self, **kwargs) -> engine.ProcessBuilder:
9393
builder = self.process_class.get_builder()

0 commit comments

Comments
 (0)