emodelrunner.configuration.validator

Configuration validation.

Functions

determine_package_type(config_path)

Returns the package type from the config file.

get_validated_config(config_path)

Returns the validated config for the specified package type.

Classes

ConfigValidator()

Validates the config through a validation schema.

SSCXConfigValidator()

Validates the SSCX config through a validation schema.

SynplasConfigValidator()

Validates the Synplas config through a validation schema.

ThalamusConfigValidator()

Validates the Thalamus config through a validation schema.

class emodelrunner.configuration.validator.ConfigValidator[source]

Bases: ABC

Validates the config through a validation schema.

Schema validation rules usage:
  • int: checks if the value is int.

  • Or(“python”, “neuron”): allows either “python” or “neuron”.

  • And(str, len): string with length > 0

  • Any named function or lambda expression that evaluates to True is valid.

static boolean_expression(bool_input)[source]

Checks if the expression has an expected boolean value.

configparser.ConfigParser.getboolean() method evaluates this value.

Parameters:

bool_input (str) – string containing boolean input.

Returns:

True if the input is in the list of expected inputs.

Return type:

bool

static evaluates_to(n, data_type)[source]

Checks if the expression n evaluates to the data_type.

Parameters:
  • n (str) – the parameter value to be evaluated

  • data_type (type) – the datatype e.g. int, float, str, list

Returns:

true n evaluates to the input data type, false otherwise.

Return type:

bool

classmethod float_or_int_expression(n)[source]

Check if n evaluates to a float or an integer literal.

Parameters:

n (str) – the parameter value to be evaluated

Returns:

true if the expression n evaluates to float, false otherwise

Return type:

bool

classmethod int_expression(n)[source]

Check if n evaluates to an int literal.

Parameters:

n (str) – the parameter value to be evaluated

Returns:

true if the expression n evaluates to int, false otherwise

Return type:

bool

static list_of_nonempty_str(list_instance)[source]

Check if the input is a list of nonempty strings.

The list itself can be empty but it cannot contain an empty string.

Parameters:

list_instance (str) – a string that evaluates to list.

Returns:

true if the expression evaluates to list of non-empty strings.

Return type:

bool

validate_from_file(config_path)[source]

Validates the config at the given path and returns it.

Parameters:

config_path (str or Path) – path to the .ini configuration file.

Returns:

the validated config.

Return type:

configparser.ConfigParser

Raises:

FileNotFoundError – if config_path does not exist.

class emodelrunner.configuration.validator.SSCXConfigValidator[source]

Bases: ConfigValidator

Validates the SSCX config through a validation schema.

class emodelrunner.configuration.validator.SynplasConfigValidator[source]

Bases: ConfigValidator

Validates the Synplas config through a validation schema.

class emodelrunner.configuration.validator.ThalamusConfigValidator[source]

Bases: ConfigValidator

Validates the Thalamus config through a validation schema.

emodelrunner.configuration.validator.determine_package_type(config_path)[source]

Returns the package type from the config file.

Supports old synplas config files without the Package type.

Parameters:

config_path (str or Path) – path to the configuration file.

Returns:

package type

Return type:

str

emodelrunner.configuration.validator.get_validated_config(config_path)[source]

Returns the validated config for the specified package type.

Parameters:

config_path (str or Path) – path to the configuration file.

Returns:

loaded config object

Return type:

configparser.ConfigParser