The Component Manager System
The vivarium
component manager system is responsible for maintaining a
reference to all of the managers and components in a simulation, providing an
interface for adding additional components or managers, and applying default
configurations and initiating the setup
stage of the lifecycle. This module
provides the default implementation and interface.
The ComponentManager
is the first plugin loaded by the
SimulationContext
and managers and components are given to it by the context. It is called on to
setup everything it holds when the context itself is setup.
- exception vivarium.framework.components.manager.ComponentConfigError[source]
Error while interpreting configuration file or initializing components
- class vivarium.framework.components.manager.OrderedComponentSet(*args)[source]
A container for Vivarium components.
It preserves ordering, enforces uniqueness by name, and provides a subset of set-like semantics.
- class vivarium.framework.components.manager.ComponentManager[source]
Manages the initialization and setup of
vivarium
components.Maintains references to all components and managers in a
vivarium
simulation, applies their default configuration and initiates theirsetup
life-cycle stage.The component manager maintains a separate list of managers and components and provides methods for adding to these lists and getting members that correspond to a specific type. It also initiates the
setup
lifecycle phase for all components and managers it controls. This is done first for managers and then components, and involves applying default configurations and calling the object’ssetup
method.- property configuration: LayeredConfigTree
The configuration tree for the simulation.
- setup_manager(configuration, lifecycle_manager)[source]
Called by the simulation context.
- Return type:
- Parameters:
configuration (LayeredConfigTree)
lifecycle_manager (LifeCycleManager)
- add_managers(managers)[source]
Registers new managers with the component manager.
Managers are configured and setup before components.
- add_components(components)[source]
Register new components with the component manager.
Components are configured and setup after managers.
- get_components_by_type(component_type)[source]
Get all components that are an instance of
component_type
.
- get_component(name)[source]
Get the component with name
name
.Names are guaranteed to be unique.
- Return type:
- Parameters:
name (str) – A component name.
- Returns:
A component that has name
name
.- Raises:
ValueError – No component exists in the component manager with
name
.
- setup_components(builder)[source]
Separately configure and set up the managers and components held by the component manager, in that order.
The setup process involves applying default configurations and then calling the manager or component’s setup method. This can result in new components as a side effect of setup because components themselves have access to this interface through the builder in their setup method.
- class vivarium.framework.components.manager.ComponentInterface(manager)[source]
The builder interface for the component manager system.
This class defines component manager methods a
vivarium
component can access from the builder. It provides methods for querying and adding components to theComponentManager
.- Parameters:
manager (ComponentManager)
- get_component(name)[source]
Get the component that has
name
if presently held by the component manager. Names are guaranteed to be unique.