Skip to content

xqute.schedulers.container_scheduler

module

xqute.schedulers.container_scheduler

The scheduler to run jobs via containers

Classes
class

xqute.schedulers.container_scheduler.ContainerScheduler(image, entrypoint='/bin/bash', bin='docker', volumes=None, envs=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.

Parameters
  • **kwargs Additional arguments passed to parent Scheduler
  • image (str) Container image to use for running jobs
  • entrypoint (Union, optional) Entrypoint command for the container
  • bin (str, optional) Path to container runtime binary (e.g. /path/to/docker)
  • volumes (Union, optional) host:container volume mapping string or strings
  • envs (Optional, optional) Environment variables to set in container
  • 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
Attributes
  • job_class The job class
  • jobcmd_wrapper_init The init script for the job command wrapper
  • jobcmd_wrapper_init (str) The init script for the job command wrapper</>
  • name The name of the scheduler
Methods
method

create_job(index, cmd)

Create a job

Parameters
  • index (int) The index of the job
  • cmd (Union) The command of the job
Returns (Job)

The job

Submit and update the status

  1. Check if the job is already submitted or running
  2. If not, run the hook
  3. If the hook is not cancelled, clean the job
  4. Submit the job, raising an exception if it fails
  5. If the job is submitted successfully, update the status
  6. If the job fails to submit, update the status and write stderr to the job file
Parameters
  • job (Job) The job
method

retry_job(job)

Retry a job

Parameters
  • job (Job) The job

Kill a job and update its status

Parameters
  • job (Job) The job
method

polling_jobs(jobs, on)

Check if all jobs are done or new jobs can submit

Parameters
  • jobs (List) The list of jobs
  • on (str) query on status: submittable or all_done
Returns (bool)

True if yes otherwise False.

method

kill_running_jobs(jobs)

Try to kill all running jobs

Parameters
  • jobs (List) The list of jobs

Check if a job is already submitted or running

Parameters
  • job (Job) The job
Returns (bool)

True if yes otherwise False.

method

jobcmd_init(job) → str

The job command init

method

jobcmd_prep(job) → str

The job command preparation

method

jobcmd_end(job) → str

The job command end

method

wrap_job_script(job)

Wrap the job script

Parameters
  • job (Job) The job
Returns (str)

The wrapped script

method

kill_job(job)

Kill a job asynchronously

Parameters
  • job (Job) The job
method

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.

Parameters
  • job (Job) The job
Returns (bool)

True if it is, otherwise False

method

wrapped_job_script(job)

Get the wrapped job script

Parameters
  • job (Job) The job
Returns (SpecPath)

The path of the wrapped job script

method

jobcmd_shebang(job) → str

The shebang of the wrapper script

method

submit_job(job)

Submit a job locally

Parameters
  • job (Job) The job
Returns (int)

The process id