hpcflow.sdk.submission.schedulers.slurm.SlurmPosix#
- class hpcflow.sdk.submission.schedulers.slurm.SlurmPosix(directives=None, options=None, submit_cmd=None, show_cmd=None, del_cmd=None, js_cmd=None, login_nodes_cmd=None, array_switch=None, array_item_var=None, *args, **kwargs)#
Bases:
QueuedSchedulerA scheduler that uses SLURM.
- Keyword Arguments:
directives (dict) – Scheduler directives. Each item is written verbatim in the jobscript as a scheduler directive, and is not processed in any way. If a value is None, the key is considered a flag-like directive. If a value is a list, multiple directives will be printed to the jobscript with the same key, but different values.
Notes
runs in current working directory by default [2]
References
[1] https://manpages.org/sbatch [2] https://ri.itservices.manchester.ac.uk/csf4/batch/sge-to-slurm/
Methods
Cancel submitted jobs.
Format the directives to the scheduler.
Format a particular switch to use the JS command.
Read one queue snapshot and optionally select the requested job IDs.
File name of combined standard output and error streams.
File name of the standard error stream file.
File name of the standard output stream file.
Get the command to use to submit a job to the scheduler.
Get the version of the scheduler.
Query if a jobscript is running/pending.
Test whether particular number of cores is supported in given range of cores.
Extract scheduler reference for a newly submitted jobscript
Perform scheduler-specific processing to the element resources.
Wait for jobscripts to update their state.
Attributes
Default shell variable with array ID.
Default prefix to enable array processing.
Default cancel command.
Default job control directive prefix.
Default command for logging into nodes.
Default pattern for matching the names of login nodes.
Default command to show the queue state.
Default submission command.
Maps scheduler state codes to
JobscriptElementStatevalues.Unique properties, for hashing.
- DEFAULT_ARRAY_ITEM_VAR: ClassVar[str] = 'SLURM_ARRAY_TASK_ID'#
Default shell variable with array ID.
- DEFAULT_LOGIN_NODES_CMD: ClassVar[Sequence[str] | None] = None#
Default command for logging into nodes.
- DEFAULT_LOGIN_NODE_MATCH: ClassVar[str] = '*login*'#
Default pattern for matching the names of login nodes.
- DEFAULT_SHOW_CMD: ClassVar[Sequence[str]] = ('squeue', '--me')#
Default command to show the queue state.
- cancel_jobs(js_refs, jobscripts=None, quiet=False)#
Cancel submitted jobs.
- format_directives(resources, num_elements, is_array, sub_idx, js_idx, *, std_dir=None)#
Format the directives to the scheduler.
- format_switch(switch)#
Format a particular switch to use the JS command.
- get_job_state_info(*, js_refs=None)#
Read one queue snapshot and optionally select the requested job IDs.
Query the configured queue command once, then filter locally before expanding array ranges, so unrelated large arrays do not allocate per-element states. Finished or unknown IDs are simply absent from the snapshot; they do not trigger Slurm’s invalid-ID error, a second discovery query, or retries. An explicitly empty reference list performs no query.
- Parameters:
js_refs (Sequence[str] | None)
- Return type:
Mapping[str, JobscriptElementState | Mapping[int, JobscriptElementState]]
- get_std_out_err_filename(js_idx, job_ID, array_idx=None)#
File name of combined standard output and error streams.
Notes
We use the standard output stream filename format for the combined output and error streams file.
- get_stderr_filename(js_idx, job_ID, array_idx=None)#
File name of the standard error stream file.
- get_stdout_filename(js_idx, job_ID, array_idx=None)#
File name of the standard output stream file.
- get_submit_command(shell, js_path, deps)#
Get the command to use to submit a job to the scheduler.
- get_version_info()#
Get the version of the scheduler.
- Return type:
VersionInfo
- is_jobscript_active(job_ID)#
Query if a jobscript is running/pending.
- static is_num_cores_supported(num_cores, core_range)#
Test whether particular number of cores is supported in given range of cores.
- parse_submission_output(stdout)#
Extract scheduler reference for a newly submitted jobscript
- classmethod process_resources(resources, scheduler_config)#
Perform scheduler-specific processing to the element resources.
Note
This mutates resources.
- Parameters:
resources (ElementResources)
scheduler_config (SchedulerConfigDescriptor)
- Return type:
None
- state_lookup: ClassVar[Mapping[str, JobscriptElementState]] = {'CANCELLED': JobscriptElementState.cancelled, 'COMPLETED': JobscriptElementState.finished, 'COMPLETING': JobscriptElementState.running, 'CONFIGURING': JobscriptElementState.configuring, 'FAILED': JobscriptElementState.errored, 'OUT_OF_MEMORY': JobscriptElementState.errored, 'PENDING': JobscriptElementState.pending, 'RUNNING': JobscriptElementState.running, 'TIMEOUT': JobscriptElementState.errored}#
Maps scheduler state codes to
JobscriptElementStatevalues.