libmuscle.manager.instance_registry module

class libmuscle.manager.instance_registry.InstanceRegistry(expected_instances: List[str])[source]

Bases: object

Keeps track of running instances.

The InstanceRegistry is a simple in-memory database that stores information about running instances of compute elements.

Construct an empty InstanceRegistry.

Parameters

expected_instances – List of instance names expected to register.

add(name: Reference, locations: List[str], ports: List[Port]) None[source]

Add an instance to the registry.

Parameters
  • name – Name of the instance.

  • locations – Network locations where it can be reached.

  • ports – List of ports of this instance.

Raises

ValueError – If an instance with this name has already been registered.

get_locations(name: Reference) List[str][source]

Retrieves the locations of a registered instance.

Parameters

name – The name of the instance to get the location of.

Raises

KeyError – If no instance with this name was registered.

get_ports(name: Reference) List[Port][source]

Retrieves the ports of a registered instance.

Parameters

name – The name of the instance whose ports to retrieve.

Raises

KeyError – If no instance with this name was registered.

remove(name: Reference) None[source]

Remove an instance from the registry.

Parameters

name – Name of the instance to remove.

Raises

KeyError – If the instance does not exist.

wait() None[source]

Waits until all instance are deregistered.

This function blocks, and returns after each expected instance has been registered and deregistered again, signalling the end of the simulation run.