My workchain has inputs defined as:
class GeneticAlgorithmWorkChain(WorkChain):
"""WorkChain to run GA """
# the maximum number of the best individuals not updated
_MAX_THEBEST_COUNT = 10
@classmethod
def define(cls, spec):
"""Specify imputs and outputs"""
super().define(spec)
spec.input('ga_parameters', valid_type=orm.Dict, validator=validate_ga_parameters)
spec.input('evaluate_process', help='Process which produces the result to be optimized.',
**PROCESS_INPUT_KWARGS)
spec.input('variable_info', valid_type=orm.Dict, validator=validate_variable_info)
spec.input('result_key', valid_type=orm.Str)
spec.input_namespace('fixture_inputs', required=False, dynamic=True)
spec.input('local_optimization_process', help='Process which produces the result to be optimized.',
**PROCESS_INPUT_KWARGS)
spec.input('local_optimization_parameters', valid_type=orm.Dict)
The validators are defined for ga_parameters
and variable_info
separately, but these two inputs may conflict with each other if not set properly, how can I validate it with validator that accept two input ports to validate?
I also find the documentation in Usage — AiiDA 2.4.0.post0 documentation is outdated, I have my validator defined as:
def validate_ga_parameters(ga_parameters):
parameters = ga_parameters.get_dict()
num_individuals = parameters.get('num_individuals')
if num_individuals is None:
return 'num_individuals is not defined'
....
return None
But when I ran it, I got /home/jyu/micromamba/envs/aiida-opsp/lib/python3.9/site-packages/plumpy/ports.py:200: UserWarning: the validator
validate_ga_parameters has a signature that only takes a single argument.
.