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.

This introduces some definitions:

  • Call conduits (from O_I to F_INIT) go from a direct superpredecessor to a direct subsuccessor.

  • Dispatch conduits (from O_F to F_INIT) go from a direct predecessor to a direct successor.

  • Release conduits (from O_F to S) go from a direct subpredecessor to a direct supersuccessor.

  • Supersuccessors are components that are reachable from the current component via dispatch and at least one release conduits.

  • Subsuccessors are components that are reachable from the current component via dispatch and at least one call conduit.

  • Successors are components that will start running after the current component finishes.

  • Superpredecessors are the inverse of subsuccessors.

  • Subpredecessors are the inverse of supersuccessors.

  • Predecessors are the inverse of successors.

  • Macros are components that are both a superpredecessor and a supersuccessor of the current component.

  • Micros are components that are both a subsuccessor and a subpredecessor of the current component.

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, ResourceAssignment][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:

Assigned resources for each instance required by the model.

class libmuscle.planner.planner.ResourceAssignment(by_rank: List[OnNodeResources])[source]

Bases: object

Assigned resources for each process of an instance.

Note that we use the classes from libmuscle.planner.resources to generically refer to collections of resources, either to describe the available hardware or to designate a subset of it that is occupied by a particular instance, or a subset that isn’t currently occupied.

This class has more detailed information, because it knows for each process (MPI rank) in the instance which subset of the overall resources for the instance it should be on, which we need to launch it in the right place.

by_rank

List of OnNodeResources objects containing assigned resources,

indexed by rank.
as_resources() Resources[source]

Return a Resources representing the combined assigned resources.