The Artifact Manager

This module contains the ArtifactManager, a vivarium plugin for handling complex data bound up in a data artifact.

class vivarium.framework.artifact.manager.ArtifactManager[source]

The controller plugin component for managing a data artifact.

CONFIGURATION_DEFAULTS: Dict[str, Any] = {'input_data': {'artifact_filter_term': None, 'artifact_path': None, 'input_draw_number': None}}

A dictionary containing the defaults for any configurations managed by this manager. An empty dictionary indicates no managed configurations.

property name
setup(builder)[source]

Performs this component’s simulation setup.

load(entity_key, **column_filters)[source]

Loads data associated with the given entity key.

Parameters:
  • entity_key (str) – The key associated with the expected data.

  • column_filters (str | int | Sequence[int] | Sequence[str]) – Filters that subset the data by a categorical column and then remove the column from the raw data. They are supplied as keyword arguments to the load method in the form “column=value”.

Returns:

The data associated with the given key, filtered down to the requested subset if the data is a dataframe.

Return type:

Any

class vivarium.framework.artifact.manager.ArtifactInterface(manager)[source]

The builder interface for accessing a data artifact.

Parameters:

manager (ArtifactManager) –

load(entity_key, **column_filters)[source]

Loads data associated with a formatted entity key.

The provided entity key must be of the form {entity_type}.{measure} or {entity_type}.{entity_name}.{measure}.

Here entity_type denotes the kind of entity being described. Examples include cause, risk, population, and covariates.

The entity_name is the name of the specific entity. For example, if we had entity_type as cause, we might have entity_name as diarrheal_diseases or ischemic_heart_disease.

Finally, measure is the name of the quantity the data describes. Examples of measures are incidence, disability_weight, relative_risk, and cost.

Parameters:
  • entity_key (str) – The key associated with the expected data.

  • column_filters (str | int | Sequence[int] | Sequence[str]) – Filters that subset the data by a categorical column and then remove the column from the raw data. They are supplied as keyword arguments to the load method in the form “column=value”.

Returns:

The data associated with the given key filtered down to the requested subset.

Return type:

pandas.DataFrame

vivarium.framework.artifact.manager.filter_data(data, config_filter_term=None, **column_filters)[source]

Uses the provided column filters and age_group conditions to subset the raw data.

Parameters:
Return type:

DataFrame

vivarium.framework.artifact.manager.validate_filter_term(config_filter_term)[source]
vivarium.framework.artifact.manager.get_base_filter_terms(configuration)[source]

Parses default filter terms from the artifact configuration.

Parameters:

configuration (ConfigTree) –

vivarium.framework.artifact.manager.parse_artifact_path_config(config)[source]

Gets the path to the data artifact from the simulation configuration.

The path specified in the configuration may be absolute or it may be relative to the location of the configuration file.

Parameters:

config (ConfigTree) – The configuration block of the simulation model specification containing the artifact path.

Returns:

The path to the data artifact.

Return type:

str