Validator of algorithms config file¶
This module validates the results returned by an algorithm.
- class encore.validators.runners_config.AlgorithmConfig(*, enabled: bool, full_name: str, language: Literal['MATLAB', 'Python'], analysis_function: str, plot_function: str, ensemble_color: str, needed_data: List[str], source: str, figures: List[FigureConfig], parameters: Dict[str, ParameterConfig])¶
- analysis_function: str¶
- enabled: bool¶
- ensemble_color: str¶
- figures: List[FigureConfig]¶
- full_name: str¶
- language: Literal['MATLAB', 'Python']¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- needed_data: List[str]¶
- parameters: Dict[str, ParameterConfig]¶
- plot_function: str¶
- source: str¶
- classmethod validate_color(v: str) str¶
Validates that the value for ‘ensembles_color’ is a valid Matplotlib color.
- Parameters:
v (str) – Color to test
- Raises:
ValueError – If the string given is Matplotlib incompatible
- Returns:
The same color validated
- Return type:
str
- classmethod validate_needed_data(v: List[str])¶
Validates that there are data needed and the requested data is one of the available options.
- Parameters:
v (List[str]) – List of strings with the names of the requested variables
- Raises:
ValueError – If there’s no data in the needed_data field
ValueError – If requesting a non supported variable name
- Returns:
The same list of names validated
- Return type:
List[str]
- classmethod validate_parameter_keys(params: Dict[str, ParameterConfig])¶
Iterates over the parameter fields of an algorithm to validate them.
- Parameters:
params (Dict[str, ParameterConfig]) – Dictionary pairing dictionary name and config for that parameter.
- Returns:
Same dictionary validated
- Return type:
Dict[str, ParameterConfig]
- class encore.validators.runners_config.EncoreConfig(root: RootModelRootType = PydanticUndefined)¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- root: Dict[str, AlgorithmConfig]¶
- classmethod validate_algorithm_keys(algorithms: Dict[str, AlgorithmConfig])¶
Validates each algorithm in the config file.
- Parameters:
algorithms (Dict[str, AlgorithmConfig]) – Dictionary of algorithms to validate
- Returns:
Same dictionary validated
- Return type:
Dict[str, AlgorithmConfig]
- class encore.validators.runners_config.EncoreConfigFile(*, encore_runners: EncoreConfig)¶
- encore_runners: EncoreConfig¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class encore.validators.runners_config.FigureConfig(*, name: str, display_name: str)¶
- display_name: str¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str¶
- class encore.validators.runners_config.ParameterConfig(*, object_name: str, display_name: str, description: str, default_value: int | float | bool | str, type: str | None = None, options: List[ParameterOption] | None = None, min_value: int | float | Dict[str, int | float | str] | Literal['MIN_VAL', 'MAX_VAL'] | None = None, max_value: int | float | Dict[str, int | float | str] | Literal['MIN_VAL', 'MAX_VAL'] | None = None)¶
- default_value: int | float | bool | str¶
- description: str¶
- display_name: str¶
- max_value: int | float | Dict[str, int | float | str] | Literal['MIN_VAL', 'MAX_VAL'] | None¶
- min_value: int | float | Dict[str, int | float | str] | Literal['MIN_VAL', 'MAX_VAL'] | None¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- object_name: str¶
- options: List[ParameterOption] | None¶
- type: str | None¶
- validate_parameter_config()¶
- class encore.validators.runners_config.ParameterOption(*, value: str, label: str, description: str)¶
- description: str¶
- label: str¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- value: str¶
- encore.validators.runners_config.validate_algorithm_short_name(name: str) str¶
Validates that the name of an algorithm has no special characters.
- Parameters:
name (str) – Short name of the algorithm
- Raises:
ValueError – If the name contains other than letters, numbers or underscores
- Returns:
Same name validated
- Return type:
str
- encore.validators.runners_config.validate_encore_algorithm_config(config_dict: dict) EncoreConfigFile¶
Validates a single algorithm config.
- Parameters:
config_dict (dict) – Dictionary mapping an algorithm short name with its config.
- Raises:
RuntimeError – If the dictionary can’t be validated
- Returns:
Pydantic validated model
- Return type:
- encore.validators.runners_config.validate_encore_config(config_dict: dict) EncoreConfigFile¶
Validates the entire ENCORE config file for runners
- Parameters:
config_dict (dict) – Dictionary with encore runners objects
- Raises:
RuntimeError – If the dictionary can’t be validated
- Returns:
Validated structure
- Return type: