libmuscle.native_instantiator.slurm module
- class libmuscle.native_instantiator.slurm.NCEVisitor[source]
Bases:
NodeVisitorProcesses a parsed NCE and produces a list of cpu counts per node.
Nodes cores expressions are used by SLURM to describe cores on a collection of nodes. See parse_slurm_nodes_cores() below.
- generic_visit(node: Node, visited_children: Sequence[Any]) Sequence[Any][source]
Default visitor method
- Parameters:
node – The node we’re visiting
visited_children – The results of visiting the children of that node, in a list
I’m not sure there’s an implementation of this that makes sense across all (or even most) use cases, so we leave it to subclasses to implement for now.
- visit_nce(node: Node, visited_children: tuple[list[int], Sequence[tuple[Any, list[int]]]]) list[int][source]
Return a list of nodes corresponding to the NRE.
- class libmuscle.native_instantiator.slurm.NREVisitor[source]
Bases:
NodeVisitorProcesses a parsed NRE and produces a list of nodes.
Node range expressions are used by SLURM to describe collections of nodes. See parse_slurm_nodelist() below.
- generic_visit(node: Node, visited_children: Sequence[Any]) Sequence[Any][source]
Default visitor method
- Parameters:
node – The node we’re visiting
visited_children – The results of visiting the children of that node, in a list
I’m not sure there’s an implementation of this that makes sense across all (or even most) use cases, so we leave it to subclasses to implement for now.
- visit_index_range(node: Node, visited_children: tuple[tuple[int, int], Sequence[tuple[Any, tuple[int, int]]]]) list[str][source]
Return a list of indexes corresponding to the range.
- visit_index_set(node: Node, visited_children: tuple[list[str], Sequence[tuple[Any, list[str]]]]) list[str][source]
Return a list of indexes corresponding to the set.
- visit_int(node: Node, _: Sequence[Any]) tuple[int, int][source]
Returns the value and a field width of -1.
- visit_integer(node: Node, visited_children: Sequence[tuple[int, int]]) tuple[int, int][source]
Returns the value of the int, and a field width or -1.
- visit_nre(node: Node, visited_children: tuple[list[str], Sequence[tuple[Any, list[str]]]]) list[str][source]
Return a list of nodes corresponding to the NRE.
- visit_nre_part(node: Node, visited_children: tuple[str, Sequence[tuple[Any, list[str], Any]]]) tuple[str, list[str]][source]
Return the identifier part and a list of indexes for the set.
- class libmuscle.native_instantiator.slurm.SlurmInfo[source]
Bases:
objectDetects and holds information about the present SLURM scheduler.
- agent_launch_command(agent_cmd: list[str], nnodes: int) list[str][source]
Return a command for launching one agent on each node.
- Parameters:
agent_cmd – A command that will start the agent.
- get_logical_cpus_per_node() list[int][source]
Return the number of logical CPU cores per node.
This returns a list with the number of cores of each node in the result of get_nodes(), which gets read from SLURM_JOB_CPUS_PER_NODE.
- class libmuscle.native_instantiator.slurm.SlurmQuirks[source]
Bases:
objectCollects features of the present SLURM.
- libmuscle.native_instantiator.slurm.parse_slurm_nodelist(s: str) list[str][source]
Parse a SLURM node range expression and produce node names.
Exactly what the syntax is for a “node range expression” isn’t entirely clear. Some examples are given throughout the documentation:
linux[00-17] lx[10-20] tux[2,1-2] tux[1-2,2] tux[1-3] linux[0-64,128] alpha,beta,gamma lx[15,18,32-33] linux[0000-1023] rack[0-63]_blade[0-41]
unit[0-31]rack is invalid
If a range uses leading zeros, then so should the generated indexes. See _node_range_expression_grammar above for my best guess at the correct grammar.
This function takes a string containing an NRE and returns the corresponding list of node names.
- libmuscle.native_instantiator.slurm.parse_slurm_nodes_cores(s: str) list[int][source]
Parse a SLURM nodes cores expression and produce node names.
The sbatch documentation page describes the format under SLURM_JOB_CPUS_PER_NODE as CPU_count[(xnumber_of_nodes)][,CPU_count [(xnumber_of_nodes)] …]. and gives the example of ‘72(x2),36’ describing a set of three nodes, the first two with 72 cores and the third with 36.
See _nodes_cores_expression_grammar above for the corresponding grammar.
This function takes a string containing an NCE and returns the corresponding list of node names.