Values Manager
- class vivarium.engine.framework.values.manager.ValuesManager[source]
Manager for the dynamic value system.
Notes
This is the only manager for the values system; different methods exist for working with generic value
PipelinesandAttributePipelines.- setup(builder)[source]
Defines custom actions this manager needs to run during the setup lifecycle phase.
This method is intended to be overridden by subclasses to perform any necessary setup operations specific to the manager. By default, it does nothing.
- register_value_producer(value_name, source, required_resources=(), preferred_combiner=<function replace_combiner>, preferred_post_processor=())[source]
Registers a
Pipelineas the producer of a named value.- Return type:
- Parameters:
value_name (str) – The name of the new dynamic value pipeline.
source (Callable[[...], Any]) – A callable source for the dynamic value pipeline.
required_resources (Iterable[str | Resource]) – A list of resources that the producer requires. A string represents a population attribute.
preferred_combiner (ValueCombiner) – A strategy for combining the source and the results of any calls to mutators in the pipeline.
vivariumprovides the strategiesreplace_combiner(the default) andlist_combiner, which are importable fromvivarium.engine.framework.values. Client code may define additional strategies as necessary.preferred_post_processor (PostProcessor | Sequence[PostProcessor]) – A strategy for processing the final output of the pipeline.
vivariumprovides the strategiesrescale_post_processorandunion_post_processorwhich are importable fromvivarium.engine.framework.values. Client code may define additional strategies as necessary. If a sequence of post processors is provided, they will be applied in the order they are provided.
- Returns:
The
Pipelinethat is registered as the producer of the named value.
- register_attribute_producer(value_name, source, required_resources=(), preferred_combiner=<function replace_combiner>, preferred_post_processor=(), source_is_private_column=False)[source]
Registers an
AttributePipelineas the producer of a named attribute.- Parameters:
value_name (str) – The name of the new dynamic attribute pipeline.
source (Callable[[pd.Index[int]], Any] | list[str]) – The source for the dynamic attribute pipeline. This can be a callable, a list containing a single name of a private column created by this component, or a list of population attributes. If a private column name is passed, source_is_private_column must also be set to True.
required_resources (Iterable[str | Resource]) – A list of resources that the producer requires. A string represents a population attribute.
preferred_combiner (ValueCombiner) – A strategy for combining the source and the results of any calls to mutators in the pipeline.
vivariumprovides the strategiesreplace_combiner(the default) andlist_combiner, which are importable fromvivarium.engine.framework.values. Client code may define additional strategies as necessary.preferred_post_processor (AttributePostProcessor | Sequence[AttributePostProcessor]) – A strategy for processing the final output of the pipeline.
vivariumprovides the strategiesrescale_post_processorandunion_post_processorwhich are importable fromvivarium.engine.framework.values. Client code may define additional strategies as necessary. If a sequence of post processors is provided, they will be applied in the order they are provided.source_is_private_column (bool) – Whether or not the source is the name of a private column created by this component.
- Return type:
None
- register_value_modifier(value_name, modifier, required_resources=())[source]
Marks a
Callableas the modifier of a named value.- Return type:
- Parameters:
value_name (str) – The name of the dynamic value
Pipelineto be modified.modifier (Callable[[...], Any]) – A function that modifies the source of the dynamic value
Pipelinewhen called. If the pipeline has areplace_combiner, the modifier must have the same arguments as the pipeline source with an additional last positional argument for the results of the previous stage in the pipeline. For thelist_combinerstrategy, the pipeline modifiers should have the same signature as the pipeline source.required_resources (Iterable[str | Resource]) – A list of resources that the producer requires. A string represents a population attribute.
- register_attribute_modifier(value_name, modifier, required_resources=())[source]
Marks a
Callableas the modifier of a named attribute.- Return type:
- Parameters:
value_name (str) – The name of the dynamic
AttributePipelineto be modified.modifier (Callable[[...], Any] | str) – A function that modifies the source of the dynamic
AttributePipelinewhen called. If a string is passed, it refers to the name of anAttributePipeline. If the pipeline has areplace_combiner, the modifier should accept the same arguments as the pipeline source with an additional last positional argument for the results of the previous stage in the pipeline. For thelist_combinerstrategy, the pipeline modifiers should have the same signature as the pipeline source.required_resources (Iterable[str | Resource]) – A list of resources that need to be properly sourced before the pipeline modifier is called. This is a list of attribute names, pipelines, or randomness streams.
- get_value(name)[source]
Retrieves the
Pipelinerepresenting the named value.- Return type:
- Parameters:
name (str) – Name of the
Pipelineto return.- Returns:
The requested
Pipeline.
Notes
This will create a new
Pipelineif one does not already exist.
- get_value_pipelines()[source]
Retrieves a dictionary of all registered value
Pipelines.To get all
AttributePipelines, useget_attribute_pipelines().
- get_attribute(name)[source]
Retrieves the
AttributePipelinerepresenting the named attribute.To get a value
Pipeline, useget_value().- Return type:
- Parameters:
name (str) – Name of the
AttributePipelineto return.- Returns:
The requested
AttributePipeline.
Notes
This will create a new
AttributePipelineif one does not already exist.
- get_attribute_pipelines()[source]
Returns a dictionary of
AttributePipelines.- Return type:
- Returns:
A dictionary mapping all registered attribute names to their corresponding
AttributePipelines.
Notes
This is not the preferred access method to getting population attributes since it does not implement various features (e.g. querying, simulant tracking, etc); it exists for other managers to use if needed. Use
vivarium.engine.framework.population.population_view.PopulationView.get()orvivarium.engine.framework.population.population_view.PopulationView.get_frame()instead.