xqute.schedulers.container_scheduler
xqute.schedulers.container_scheduler
The scheduler to run jobs via containers
ContainerScheduler— Scheduler to run jobs via containers (Docker/Podman/Apptainer)</>
xqute.schedulers.container_scheduler.ContainerScheduler(image, entrypoint='/bin/bash', bin='docker', volumes=None, remove=True, user=None, bin_args=None, **kwargs)
Scheduler to run jobs via containers (Docker/Podman/Apptainer)
This scheduler can execute jobs inside containers using Docker, Podman, or Apptainer.
**kwargs— Additional arguments passed to parent Schedulerimage(str) — Container image to use for running jobsentrypoint(Union, optional) — Entrypoint command for the containerbin(str, optional) — Path to container runtime binary (e.g. /path/to/docker)volumes(Union, optional) — host:container volume mapping string or stringsor named volume mapping likeMOUNTED=/path/on/hostthen it will be mounted to/mnt/disks/MOUNTEDin the container. You can use environment variableMOUNTEDin your job scripts to refer to the mounted path.remove(bool, optional) — Whether to remove the container after execution.Only applies to Docker/Podman.user(str | none, optional) — User to run the container as (only for Docker/Podman)By default, it runs as the current user (os.getuid() and os.getgid())bin_args(Optional, optional) — Additional arguments to pass to the container runtime
job_class— The job classjobcmd_wrapper_init— The init script for the job command wrapperjobcmd_wrapper_init(str) — The init script for the job command wrapper</>name— The name of the scheduler
create_job(index,cmd,envs)(Job) — Create a job</>job_fails_before_running(job)(bool) — Check if a job fails before running.</>job_is_running(job)(bool) — Tell if a job is really running, not only the job.jid_file</>job_is_submitted_or_running(job)(bool) — Check if a job is already submitted or running</>jobcmd_end(job)(str) — The job command end</>jobcmd_init(job)(str) — The job command init</>jobcmd_prep(job)(str) — The job command preparation</>jobcmd_shebang(job)(str) — The shebang of the wrapper script</>kill_job(job)— Kill a job asynchronously</>kill_job_and_update_status(job)— Kill a job and update its status</>kill_running_jobs(jobs)— Try to kill all running jobs</>polling_jobs(jobs,on,polling_counter)(bool) — Check if all jobs are done or new jobs can submit</>retry_job(job)— Retry a job</>submit_job(job)(int) — Submit a job locally</>submit_job_and_update_status(job)— Submit and update the status</>wrap_job_script(job)(str) — Wrap the job script</>wrapped_job_script(job)(SpecPath) — Get the wrapped job script</>
create_job(index, cmd, envs=None)
Create a job
index(int) — The index of the jobcmd(Union) — The command of the job
The job
submit_job_and_update_status(job)
Submit and update the status
- Check if the job is already submitted or running
- If not, run the hook
- If the hook is not cancelled, clean the job
- Submit the job, raising an exception if it fails
- If the job is submitted successfully, update the status
- If the job fails to submit, update the status and write stderr to the job file
job(Job) — The job
kill_job_and_update_status(job)
Kill a job and update its status
job(Job) — The job
polling_jobs(jobs, on, polling_counter)
Check if all jobs are done or new jobs can submit
jobs(List) — The list of jobson(str) — query on status:submittableorall_donepolling_counter(int) — The polling counter, used to limit the number of polls orskip some polls if the scheduler is busy.
True if yes otherwise False.
kill_running_jobs(jobs)
Try to kill all running jobs
jobs(List) — The list of jobs
job_is_submitted_or_running(job)
Check if a job is already submitted or running
job(Job) — The job
True if yes otherwise False.
job_fails_before_running(job)
Check if a job fails before running.
For some schedulers, the job might fail before running (after submission). For example, the job might fail to allocate resources. In such a case, the wrapped script might not be executed, and the job status will not be updated (stays in SUBMITTED). We need to check such jobs and mark them as FAILED.
For the instant scheduler, for example, the local scheduler, the failure will be immediately reported when submitting the job, so we don't need to check such jobs.
job(Job) — The job to check
True if the job fails before running, otherwise False.
jobcmd_prep(job) → str
The job command preparation
jobcmd_end(job) → str
The job command end
wrap_job_script(job)
job_is_running(job)
Tell if a job is really running, not only the job.jid_file
In case where the jid file is not cleaned when job is done.
job(Job) — The job
True if it is, otherwise False
jobcmd_shebang(job) → str
The shebang of the wrapper script
jobcmd_init(job) → str
The job command init