Skip to main content

A lightweight Python wrapper for Slurm sbatch/srun with robust subprocess handling and optional logging.

Project description

quickslurm

Build/Publish PyPI Python versions License

A lightweight Python wrapper around Slurm for:

  • Submitting batch jobs (sbatch)
  • Running commands (srun)
  • Cancelling jobs (scancel)

It focuses on safe subprocess handling, simple ergonomics, and sensible defaults.

Full documentation can be found here: Quickslurm Docs

Features

  • sbatch and srun helpers with consistent argument handling
  • Optional built-in logging (file and stderr)
  • Pass-through environment variables (base and per-call overrides)
  • Convenience for inline sbatch scripts
  • Optional wait for job completion after sbatch submission

Installation

  • Requires Python 3.8+
  • Requires Slurm 23.02+ be installed on the system
  • Assumes Slurm binaries (sbatch, srun, scancel, sacct if using wait) are on PATH
pip install quickslurm

Quick start

from quickslurm import Slurm, SlurmError

slurm = Slurm(enable_logging=True)

# Submit an existing script
submit = slurm.sbatch(
    script_path="train.sh",
    sbatch_options={
        "job-name": "trainA",
        "time": "00:30:00",
        "partition": "short",
        "cpus-per-task": 4,
        "mem": "8G",
        "output": "slurm-%j.out",
    },
    script_args=["--epochs", "10"],
)
print("Job ID:", submit.job_id)

# Submit an inline command (temp script will be generated)
submit2 = slurm.submit_inline(
    command=["python", "train.py", "--epochs", "5"],
    sbatch_options={"time": "00:10:00", "job-name": "quick-train"},
)
print("Inline Job ID:", submit2.job_id)

# Run something via srun (non-interactive)
res = slurm.run(["hostname"], srun_options={"ntasks": 1})
print("Hostname:", res.stdout.strip())

# Cancel a job
slurm.cancel(submit2.job_id)

Sample output:

Job ID: 12300008
Inline Job ID: 12300009
Hostname: testnode1

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quickslurm-0.2.5.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quickslurm-0.2.5-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file quickslurm-0.2.5.tar.gz.

File metadata

  • Download URL: quickslurm-0.2.5.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for quickslurm-0.2.5.tar.gz
Algorithm Hash digest
SHA256 210d2b819e54dd4a7d6c3e6490b627e1c24526f238e97c3fbcd654810521f1f5
MD5 5d52f7303f94fae5a5415aac4881958e
BLAKE2b-256 88d31189acdf47113014de0b931a8a2292aecba52df09ffba5d7a3dde505a0a9

See more details on using hashes here.

File details

Details for the file quickslurm-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: quickslurm-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for quickslurm-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1b43196106ddc30aea249649b24554d23391c2ebea266910f61466542f5f7399
MD5 37796e543117585583d55fd2fbdbe7fd
BLAKE2b-256 84d4dca18e14c5572a54702c6f9a4a428c5f4ef02aaf694ca57e731c260d62ec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page