clusterlib.scheduler.submit

clusterlib.scheduler.submit(job_command, job_name='job', time='24:00:00', memory=4000, email=None, email_options=None, log_directory=None, backend='slurm', shell_script='#!/bin/bash')

Write the submission query (without script)

Parameters:

job_command : str,

Command associated to the job, e.g. ‘python main.py’.

job_name : str, optional (default=”job”)

Name of the job.

time : str, optional (default=”24:00:00”)

Maximum time format “HH:MM:SS”.

memory : str, optional (default=4000)

Maximum virtual memory in mega-bytes

email : str, optional (default=None)

Email where job information is sent. If None, no email is asked to be sent.

email_options : str, optional (default=None)

Specify email options:
  • SGE : Format char from beas (begin,end,abort,stop) for SGE.
  • SLURM : either BEGIN, END, FAIL, REQUEUE or ALL.

See the documenation for more information

log_directory : str, optional (default=None)

Specify the log directory. If None, no log directory is specified.

backend : {‘sge’, ‘slurm’}, optional (default=”slurm”)

Backend where the job will be submitted

shell_script : str, optional (default=”#!/bin/bash”)

Specify shell that is used by the script.

Returns:

submission_query : str,

Return the submission query in the appropriate format. The obtained query could be directly launch using os.subprocess. Further options could be appended at the end of the string.

Examples

First, let’s generate a command for SLURM to launch the program main.py.

>>> from clusterlib.scheduler import submit
>>> script = submit("python main.py --args 1")
>>> print(script)
echo '#!/bin/bash
python main.py --args 1' | sbatch --job-name=job --time=24:00:00 --mem=4000

The job can be latter launched using for instance os.system(script).