libmuscle.planner.planner module

exception libmuscle.planner.planner.InsufficientResourcesAvailable[source]

Bases: RuntimeError

class libmuscle.planner.planner.ModelGraph(model: Model)[source]

Bases: object

Represents a yMMSL model as a graph.

component(name: Reference) Component[source]

Return a component by name.

Parameters:

name – Name of the component to look up

Returns:

The component with the given name

Raises:

KeyError – If no component could be found

components() Iterable[Component][source]

Return the components of the model (nodes).

macros(component: Component) Set[Tuple[Component, int]][source]

Return the macros of the given component.

These are components that are both before the component’s F_INIT and after its O_F.

Parameters:

component – The reference component

Returns:

The set of components that are both super-predecessor and super-successor of component.

micros(component: Component) Set[Tuple[Component, int]][source]

Return the micros of the given component.

These are components that are in between the component’s O_I and its S.

Parameters:

component – The reference component

Returns:

The set of components that are both sub-successor and sub-predecessor of component.

predecessors(component: Component) Set[Tuple[Component, int]][source]

Return the predecessors of the given component.

Parameters:

component – The reference component

Returns:

The set of components for which a path exists from their O_F to component’s F_INIT.

Raises:

KeyError – If the component is not in the model used to construct this object.

successors(component: Component) Set[Tuple[Component, int]][source]

Return the successors of the given component.

Parameters:

component – The reference component

Returns:

The set of components for which a path exists from component’s O_F to their F_INIT.

Raises:

KeyError – If the component is not in the model used to construct this object.

class libmuscle.planner.planner.Planner(all_resources: Resources)[source]

Bases: object

Allocates resources and keeps track of allocations.

allocate_all(configuration: Configuration, virtual: bool = False) Dict[Reference, Resources][source]

Allocates resources for the given components.

Allocation can occur either on a fixed set of available resources (virtual set to False), or on an elastic set of virtual resources (virtual set to True). Use the former inside of a (fixed) cluster allocation and the latter to determine how many nodes are needed to run a simulation without oversubscribing.

If virtual is True, additional nodes will be added as needed to obtain the resources needed to allocate all instances. Each additional node will have as many cores as a random existing one. The intended use is to pass a single node to __init__ when using this mode.

Parameters:
  • configuration – Configuration to allocate all components of

  • virtual – Allocate on virtual resources or not, see above

Returns:

Resources for each instance required by the model.

class libmuscle.planner.planner.Resources(cores: Dict[str, Set[int]] | None = None)[source]

Bases: object

Designates a (sub)set of resources.

Whether these resources are free or allocated in general or by something specific depends on the context, this just says which resources we’re talking about.

cores

A dictionary mapping designated nodes to designated cores on them.

isdisjoint(other: Resources) bool[source]

Returns whether we share resources with other.

nodes() Iterable[str][source]

Returns the nodes on which we designate resources.

total_cores() int[source]

Returns the total number of cores designated.

static union(resources: Iterable[Resources]) Resources[source]

Combines the resources into one.

Parameters:

resources – A collection of resources to merge.

Returns:

A Resources object referring to all the resources in the input.