enjoy_slurm.sbatch¶
- enjoy_slurm.sbatch(jobscript=None, dependency=None, dependency_type=None, kill_on_invalid_dep=None, verbose=False, **kwargs)[source]¶
Submit a batch script to Slurm
All of sbatch command line arguments that are not explicitly documented here can still be passed via
**kwargs. For example,partition="compute"would be translated into the--partion computecommand line argument for sbatch. For all available options, please consult the sbatch manpage. However, some of the most useful argument are also documented here.- Parameters:
jobscript (str) – Path to jobscript file. If no jobscript is provided, you can use the
wrapkeyword to directly pass shell commands.depdendency (str, tuple or list) – A list of jobids this job depends on. This can also be an original slurm command as a string, e.g.,
"afterok:1:2:3". The default dependency type will beafterokwhich means that this job will only start if all depedending jobs have exit code 0. To set the dependency type, use thedependency_typekeyword. See also the sbatch manpage for more details.depdendency_type (str) – The type of the dependency. This can be
afterok,afternotok,afterany,afterorsingleton. The default isafterok. Only applies ifdependencyis a list.kill_on_invalid_dep (bool or str) – If a job has an invalid dependency and it can never run, this parameter tells Slurm to terminate it or not. A terminated job state will be
JOB_CANCELLED. If this option is not specified, the system wide behavior applies. By default the job stays pending with reasonDependencyNeverSatisfiedor if the kill_invalid_depend is specified in slurm.conf the job is terminated.verbose (bool) – Print sbatch command.
- Returns:
jobid – Slurm jobid.
- Return type:
int
Examples
>>> from enjoy_slurm import sbatch >>> jobids = [slurm.sbatch(wrap=f"echo Hello World from job {i}") for in range(0,10)] >>> slurm.sbatch(wrap="All jobs finished", dependency=jobids)