Resource Manager

class vivarium.framework.resource.manager.ResourceManager[source]

Manages all the resources needed for population initialization.

property name: str
get_graph()[source]

The networkx graph representation of the resource pool.

Return type:

DiGraph

property sorted_nodes: list[Resource]

Returns a topological sort of the resource graph.

Notes

Topological sorts are not stable. Be wary of depending on order where you shouldn’t.

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.

Return type:

None

Parameters:

builder (Builder) – The builder object used to set up the manager.

add_resource(resource)[source]

Adds managed resources to the resource pool.

Return type:

None

Parameters:

resource (Resource) – The resource being added

Raises:

ResourceError – If there are multiple producers of the same resource.

add_private_columns(initializer, columns, required_resources)[source]

Adds private column resources to the resource pool.

Return type:

None

Parameters:
  • initializer (Callable[[SimulantData], None]) – A method that will be called to initialize the state of new simulants.

  • columns (Iterable[str] | str) – The population state table private columns that the given initializer provides initial state information for.

  • required_resources (Iterable[str | Resource]) – The resources that the initializer requires to run. Strings are interpreted as attributes.

get_population_initializers()[source]

Returns a dependency-sorted list of population initializers.

We exclude all non-initializer dependencies. They were necessary in graph construction, but we only need the column producers at population creation time.

Return type:

list[Any]