nanoslurm is a zero-dependency Python wrapper for SLURM job submission and monitoring.
It uses a tiny POSIX-compatible shell script to call sbatch and related commands, avoiding any heavy Python dependencies.
- Submit jobs from Python without
pyslurmor other packages - Monitor status (
PENDING,RUNNING,COMPLETED, etc.) - Cancel jobs
- Tail job logs
- Get detailed info via
scontrol - Respects working directory at runtime (
sbatch -D)
- SLURM cluster with
sbatch,squeue, and optionallysacct/scontrol - Python ≥ 3.11
- Linux operating system
import nanoslurm
job = nanoslurm.submit(
command=["python", "train.py", "--epochs", "10"],
name="my_job",
cluster="gpu22",
time="01:00:00",
cpus=4,
memory=16,
gpus=1, # optional; omit or set to 0 for CPU-only jobs
stdout_file="./slurm_logs/%j.txt",
stderr_file="./slurm_logs/%j.err",
signal="SIGUSR1@90",
workdir="."
)
print(job) # Job(id=123456, name='my_job_2025-08-08_09-12-33.123', ...)
print(job.status) # "PENDING", "RUNNING", ...
print(job.is_running()) # True / False
print(job.is_finished()) # True / False
print(job.info()) # Detailed dict from scontrol
job.tail(10) # Last 10 lines of stdout
job.wait(poll_interval=5) # Wait until completion
job.cancel() # Cancel jobFor CPU-only workloads simply omit the gpus argument (or set it to 0)
and nanoslurm will not add any --gres directives to the submission
script.
Bump the version in pyproject.toml and merge the change into main. A
workflow will tag the commit as vX.Y.Z and publish the package to PyPI.