libmuscle.native_instantiator.agent_manager module

class libmuscle.native_instantiator.agent_manager.AgentManager(agent_dir: Path)[source]

Bases: IAgentManager

Manage the node agents.

Each node of our allocated resources gets an agent, which launches and monitors processes or that node. This class launches those agents across the nodes, and communicates with them.

The AgentManager sits in between the NativeInstantiator and the MAPServer. It gets called by NativeInstantiator with requests for resources and commands to start and cancel processes on nodes, and it gets called by MAPServer with requests from the agents.

cancel_all() None[source]

Cancel all processes.

This tells the agents to stop all running processes they’ve started.

Called by NativeInstantiator.

get_finished() List[Tuple[str, int]][source]

Returns names and exit codes of finished processes.

This returns all processes that have finished running since the previous call; each started process will be returned exactly once. The names are the ones passed to start().

Called by NativeInstantiator.

get_resources() Resources[source]

Return detected resources.

This returns a list of sets of logical hwthread ids per core, per node.

Called by NativeInstantiator.

report_resources(resources: OnNodeResources) None[source]

Report resources found on a node.

Called by MAPServer from a server thread.

Parameters:

resources – Description of a node’s resources

report_result(names_exit_codes: List[Tuple[str, int]]) None[source]

Report results of finished processes.

Called by MAPServer from a server thread.

Parameters:

names_exit_codes – A list of names and exit codes of finished processes.

shutdown() None[source]

Shut down the manager and its agents.

start(node_name: str, name: str, work_dir: Path, args: List[str], env: Dict[str, str], stdout: Path, stderr: Path) None[source]

Start a process on a node.

The files that the output is directed to will be overwritten if they already exist.

Parameters:
  • node_name – Name of the node to run the process on

  • name – Name under which this process will be known

  • work_dir – Working directory in which to start

  • args – Executable and arguments to run

  • env – Environment variables to set

  • stdout – File to redirect stdout to

  • stderr – File to redirect stderr to