noether.core.schemas.slurm

Classes

SlurmConfig

Configuration for SLURM job submission via sbatch.

Module Contents

class noether.core.schemas.slurm.SlurmConfig(/, **data)

Bases: pydantic.BaseModel

Configuration for SLURM job submission via sbatch.

All fields are optional and default to None, meaning the cluster default will be used. This schema covers all sbatch directives available in SLURM.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

data (Any)

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

job_name: str | None = None

Name of the job (–job-name).

partition: str | None = None

Partition to submit the job to (–partition). Multiple partitions can be comma-separated.

reservation: str | None = None

Reserve resources from a named reservation (–reservation).

nodes: int | str | None = None

Number of nodes to allocate (–nodes). Can be an integer or a range like ‘2-4’.

ntasks: int | None = None

Total number of tasks to launch (–ntasks).

ntasks_per_node: int | None = None

Number of tasks per allocated node (–ntasks-per-node).

cpus_per_task: int | None = None

Number of CPUs per task (–cpus-per-task).

mem: str | None = None

Memory per node (–mem), e.g. ‘4G’, ‘512M’, ‘0’ for all available memory.

gpus: str | int | None = None

count’, e.g. ‘v100:2’.

Type:

Total GPUs for the job (–gpus). Can be a count or ‘type

gpus_per_node: str | int | None = None

count’, e.g. ‘a100:4’.

Type:

GPUs per node (–gpus-per-node). Can be a count or ‘type

gres: str | None = None

2,shard:1’.

Type:

Generic consumable resources (–gres), e.g. ‘gpu

time: str | None = None

‘minutes’, ‘MM:SS’, ‘HH:MM:SS’, ‘D-HH’, ‘D-HH:MM’, ‘D-HH:MM:SS’.

Type:

Wall clock time limit (–time). Formats

begin: str | None = None

00:00’, ‘now+1hour’.

Type:

Defer job start until the specified time (–begin), e.g. ‘2024-01-15T10

output: str | None = None

%j (job ID), %x (job name), %A (array master ID), %a (array task ID), %N (node name), %u (user name).

Type:

File path for stdout (–output). Supports replacement symbols

error: str | None = None

File path for stderr (–error). Same replacement symbols as output.

array: str | None = None

Job array specification (–array), e.g. ‘0-15’, ‘1,3,5,7’, ‘1-7%2’ (max 2 concurrent).

kill_on_invalid_dep: bool | None = None

Kill the job if any dependency is invalid (–kill-on-invalid-dep).

nice: int | None = None

Scheduling priority adjustment (–nice). Positive values lower priority.

chdir: str | None = None

Working directory for the job (–chdir).

env_path: str | None = None

Shell command to source before running the job (e.g. for activating a virtual environment) which should be used as ‘source env_path’.

to_srun_args()

Return a string of srun arguments for all non-None SLURM fields.

Fields that are not actual srun directives (experiment_file, source) are excluded. Boolean fields are rendered as bare flags when True and omitted when False.

Return type:

str

classmethod validate_time_format(value)

Validate SLURM time format.

Parameters:

value (str | None)

Return type:

str | None

classmethod validate_memory_format(value)

Validate SLURM memory format (number with optional K/M/G/T suffix).

Parameters:

value (str | None)

Return type:

str | None

classmethod validate_array_format(value)

Validate SLURM array specification.

Parameters:

value (str | None)

Return type:

str | None

classmethod validate_gpu_spec(value)

Validate GPU specification (count or type:count).

Parameters:

value (str | int | None)

Return type:

str | int | None