executorlib.task_scheduler.interactive.spawner_slurm.SrunSpawner#
- class executorlib.task_scheduler.interactive.spawner_slurm.SrunSpawner(cwd: str | None = None, cores: int = 1, threads_per_core: int = 1, gpus_per_core: int = 0, num_nodes: int | None = None, worker_id: int = 0, exclusive: bool = False, openmpi_oversubscribe: bool = False, slurm_cmd_args: list[str] | None = None, pmi_mode: str | None = None, run_time_max: int | None = None)[source]#
Bases:
SubprocessSpawner- __init__(cwd: str | None = None, cores: int = 1, threads_per_core: int = 1, gpus_per_core: int = 0, num_nodes: int | None = None, worker_id: int = 0, exclusive: bool = False, openmpi_oversubscribe: bool = False, slurm_cmd_args: list[str] | None = None, pmi_mode: str | None = None, run_time_max: int | None = None)[source]#
Srun interface implementation.
- Parameters:
cwd (str, optional) – The current working directory. Defaults to None.
cores (int, optional) – The number of cores to use. Defaults to 1.
threads_per_core (int, optional) – The number of threads per core. Defaults to 1.
gpus_per_core (int, optional) – The number of GPUs per core. Defaults to 0.
num_nodes (int, optional) – The number of compute nodes to use for executing the task. Defaults to None.
worker_id (int) – The worker ID. Defaults to 0.
exclusive (bool) – Whether to exclusively reserve the compute nodes, or allow sharing compute notes. Defaults to False.
openmpi_oversubscribe (bool, optional) – Whether to oversubscribe the cores. Defaults to False.
slurm_cmd_args (list[str], optional) – Additional command line arguments. Defaults to [].
pmi_mode (str) – PMI interface to use (OpenMPI v5 requires pmix) default is None
run_time_max (int) – The maximum runtime in seconds for each task. Default: None
Methods
__init__([cwd, cores, threads_per_core, ...])Srun interface implementation.
bootup(command_lst[, stop_function])Method to start the subprocess interface.
generate_command(command_lst)Generate the command list for the Srun interface.
poll()Method to check if the subprocess interface is running.
shutdown([wait])Method to shutdown the subprocess interface.
- bootup(command_lst: list[str], stop_function: Callable | None = None) bool#
Method to start the subprocess interface.
- Parameters:
command_lst (list[str]) – The command list to execute.
stop_function (Callable) – Function to stop the interface.
- Returns:
Whether the interface was successfully started.
- Return type:
bool
- generate_command(command_lst: list[str]) list[str][source]#
Generate the command list for the Srun interface.
- Parameters:
command_lst (list[str]) – The command list.
- Returns:
The generated command list.
- Return type:
list[str]
- poll() bool#
Method to check if the subprocess interface is running.
- Returns:
True if the interface is running, False otherwise.
- Return type:
bool
- shutdown(wait: bool = True)#
Method to shutdown the subprocess interface.
- Parameters:
wait (bool, optional) – Whether to wait for the interface to shutdown. Defaults to True.