slurm
¶
SLURM submission settings, limit checks, and scheduler queries.
UNKNOWN_LIMIT
module-attribute
¶
What the limit lookups return when SLURM cannot say.
SlurmConfig
¶
Bases: MojoBaseModel
Everything a SLURM submission needs that the job itself doesn't already know.
The interactive wizard fills one in from its prompts, and Python code can build one directly and pass it to MojoRunner.submit_slurm; both use the same submission code, so a job submitted either way gets the same script.
- User Guide Workflow Running Jobs Running Jobs Execution Mode SLURM Mode (slurm) Submitting from Python
job_name
class-attribute
instance-attribute
¶
job_name: str | None = None
Name shown in the queue. Defaults to mojo-sim- followed by the job's id.
partition
class-attribute
instance-attribute
¶
partition: str | None = None
Partition to submit to. None leaves the choice to SLURM's default.
cpus_per_task
class-attribute
instance-attribute
¶
CPUs for each trial.
mem
class-attribute
instance-attribute
¶
mem: str | None = None
Memory for each trial as a SLURM size, decimals allowed (512M, 4G, 1.5G). None leaves it to the cluster default.
time_limit
class-attribute
instance-attribute
¶
time_limit: str = '01:00:00'
Time limit for each trial, in any format sbatch --time accepts.
max_concurrent
class-attribute
instance-attribute
¶
Most trials that may run at once. None lets SLURM decide.
SlurmJob
dataclass
¶
A job that is ready to be turned into a submission script.
SlurmSubmission
dataclass
¶
SlurmSubmission(
script_path: Path,
submitted: bool = False,
job_id: str | None = None,
message: str = "",
)
normalize_to_mb
¶
Converts SLURM memory strings (e.g., '1000', '1G', '1024M', '125.9G') to integer MB, or 0 if the string isn't a recognizable size. Decimal values are supported, and a bare number is MB like it is for SLURM.
Source code in src/mujoco_mojo/utils/slurm.py
slurm_time_to_seconds
¶
Converts a SLURM time limit to total seconds, or -1 for UNLIMITED. Accepts every format --time does: minutes, minutes:seconds, hours:minutes:seconds, days-hours, days-hours:minutes, and days-hours:minutes:seconds.
Source code in src/mujoco_mojo/utils/slurm.py
parse_job_id
¶
The job id from sbatch --parsable output (12345, or 12345;cluster on a federated setup), or None if there is none.
Source code in src/mujoco_mojo/utils/slurm.py
cpu_problem
¶
A description of how cpus exceeds the node CPU limit, or None if it fits or the limit is unknown.
Source code in src/mujoco_mojo/utils/slurm.py
mem_problem
¶
A description of how mem exceeds the node memory limit, or None if it fits, was not requested, or the limit is unknown.
Source code in src/mujoco_mojo/utils/slurm.py
time_problem
¶
A description of how time_limit exceeds the partition's MaxTime, or None if it fits or the limit is unknown or unlimited.
Source code in src/mujoco_mojo/utils/slurm.py
array_problem
¶
A description of how n_trials exceeds SLURM's MaxArraySize, or None if it fits.
Source code in src/mujoco_mojo/utils/slurm.py
build_submission_script
¶
build_submission_script(
*,
job_name: str,
array_range: str,
workdir: Path,
config: SlurmConfig,
worker_command: str,
extra_sbatch_lines: Sequence[str] = (),
extra_env_lines: Sequence[str] = (),
) -> str
The text of the sbatch script for a job array, one task per trial.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job_name
|
str
|
Name shown in the queue. |
required |
array_range
|
str
|
The trials to run as SLURM writes them ( |
required |
workdir
|
Path
|
The job's workdir, where the per-trial logs go. |
required |
config
|
SlurmConfig
|
The resources to ask for. |
required |
worker_command
|
str
|
What each array task runs. |
required |
extra_sbatch_lines
|
Sequence[str]
|
Extra |
()
|
extra_env_lines
|
Sequence[str]
|
Extra |
()
|
Source code in src/mujoco_mojo/utils/slurm.py
slurm_job_active
¶
Whether SLURM still has tasks of job_id queued or running.
Returns None when that can't be determined (no squeue on this machine, or it failed for another reason), so callers can carry on without the scheduler's opinion. A job SLURM has already forgotten counts as no longer active.