Component Interface

This module provides an interface to the ComponentManager.

class vivarium.framework.components.interface.ComponentInterface(manager)[source]

The builder interface for the component manager system.

Parameters:

manager (ComponentManager)

get_component(name)[source]

Get the component or manager that has name if presently held by the component manager. Names are guaranteed to be unique.

Return type:

Component | Manager

Parameters:

name (str) – A component or manager name.

Returns:

A component or manager that has name name.

get_components_by_type(component_type)[source]

Get all components that are an instance of component_type.

Return type:

list[TypeVar(C, bound= Component)]

Parameters:

component_type (type[C] | Sequence[type[C]]) – A component type to retrieve, compared against internal components using isinstance().

Returns:

A list of components of type component_type.

list_components()[source]

Get a mapping of names to components or managers held by the manager.

Return type:

dict[str, Component | Manager]

Returns:

A dictionary mapping names to components or managers.

get_current_component()[source]

Get the component currently being set up, if any.

This method is primarily used internally by the framework to support automatic component injection in interface methods.

Return type:

Component

Returns:

The component currently being set up.

Raises:

LifeCycleError – If there is no component currently being set up.

get_current_component_or_manager()[source]

Get the component or manager currently being set up, if any.

This method exists to allow for cases where a manager is needed during setup, such as if a manager creates a Value Pipeline.

Return type:

Component | Manager

Returns:

The component or manager currently being set up.

Raises:

LifeCycleError – If there is no component or manager currently being set up.