Component Configuration Parsers

Component Configuration Parsers in this module are specialized implementations of ComponentConfigurationParser that can parse configurations of components specific to the Vivarium Public Health package.

exception vivarium_public_health.plugins.parser.CausesParsingErrors(messages)[source]

Error raised when there are any errors parsing a cause model configuration.

Parameters:

messages (list[str])

class vivarium_public_health.plugins.parser.CausesConfigurationParser[source]

Parser for cause model configurations.

Component configuration parser that acts the same as the standard vivarium ComponentConfigurationParser but adds the additional ability to parse a configuration to create DiseaseModel components. These DiseaseModel configurations can either be specified directly in the configuration in a causes key or in external configuration files that are specified in the external_configuration key.

DEFAULT_MODEL_CONFIG = {'model_type': 'vivarium_public_health.disease.model.DiseaseModel', 'residual_state': None}

Default cause model configuration if it’s not explicitly specified.

Initial state and residual state cannot both be provided. If neither initial state nor residual state has been specified, the cause model must have a state named ‘susceptible’.

DEFAULT_STATE_CONFIG = {'allow_self_transition': True, 'cause_type': 'cause', 'cleanup_function': None, 'side_effect': None, 'state_type': None, 'transient': False}

Default state configuration if it’s not explicitly specified.

DEFAULT_TRANSITION_CONFIG = {'triggered': 'NOT_TRIGGERED'}

Default triggered value.

This value is used if the transition configuration does not explicity specify it.

parse_component_config(component_config)[source]

Parses the component configuration and returns a list of components.

In particular, this method looks for an external_configuration key and/or a causes key.

The external_configuration key should have names of packages that contain cause model configuration files. Within that key should be a list of paths to cause model configuration files relative to the package.

external_configuration:
    some_package:
        - some/path/cause_model_1.yaml
        - some/path/cause_model_2.yaml

The causes key should contain configuration information for cause models.

causes:
    cause_1:
        model_type: vivarium_public_health.disease.DiseaseModel
        residual_state: susceptible
        states:
            susceptible:
                cause_type: cause
                data_sources: {}
            infected:
                cause_type: cause
                transient: false
                allow_self_transition: true
                data_sources: {}
        transitions:
            transition_1:
                source: susceptible
                sink: infected
                transition_type: rate
                data_sources: {}

# todo add information about the data_sources configuration

Note that this method modifies the simulation’s component configuration by adding the contents of external configuration files to the model_override layer and adding default cause model configuration values for all cause models to the component_config layer.

Parameters:

component_config (LayeredConfigTree) – A LayeredConfigTree defining the components to initialize.

Return type:

list[Component]

Returns:

A list of initialized components.

Raises:

CausesParsingErrors – If the cause model configuration is invalid