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]

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 = {'initial_state': None, 'model_type': 'vivarium_public_health.disease.model.DiseaseModel'}

If a cause model configuration does not specify a model type or initial state, these default values will be used. The default model type is DiseaseModel and the default initial state is None. If the initial state is not 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}

If a state configuration does not specify cause_type, transient, allow_self_transition, side_effect, cleanup_function, or state_type, these default values will be used. The default cause type is ‘cause’, the default transient value is False, and the default allow_self_transition value is True.

DEFAULT_TRANSITION_CONFIG = {'triggered': 'NOT_TRIGGERED'}

If a transition configuration does not specify a triggered value, this default value will be used. The default triggered value is ‘NOT_TRIGGERED’.

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
        initial_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 (ConfigTree) – A ConfigTree defining the components to initialize.

Returns:

A list of initialized components.

Return type:

List

Raises:

CausesParsingErrors – If the cause model configuration is invalid