hpc-runner
Unified HPC job submission across multiple schedulers
Write your jobs once, run them on any cluster - SGE, Slurm, PBS, or locally for testing.
Features
- Unified CLI - Same commands work across SGE, Slurm, PBS
- Python API - Programmatic job submission with dependencies and pipelines
- Auto-detection - Automatically finds your cluster's scheduler
- Interactive TUI - Monitor jobs with a terminal dashboard
- Job Dependencies - Chain jobs with afterok, afterany, afternotok
- Array Jobs - Batch processing with throttling support
- Virtual Environment Handling - Automatic venv activation on compute nodes
- Module Integration - Load environment modules in job scripts
- Dry-run Mode - Preview generated scripts before submission
Installation
pip install hpc-runner
Or with uv:
uv pip install hpc-runner
Quick Start
CLI
# Run interactively on the cluster (the default): output streams here, hpc waits
hpc run xterm
hpc run -t xcelium make sim
# Submit as a batch job and return immediately
hpc run --batch --cpu 4 --mem 16G --time 4:00:00 make sim
# Batch job, then block until it finishes
hpc run --batch --wait python long_job.py
# Preview the generated script without submitting
hpc run --dry-run --cpu 8 make -j8
# Array job (always batch)
hpc run --array 1-100 "python process.py --task-id \$SGE_TASK_ID"
# Raw scheduler flags go before --, the command after
hpc run -q gpu.q -l gpu=1 -- python train.py
Python API
from hpc_runner import Job
# Create and submit a job
job = Job(
command="python train.py",
cpu=4,
mem="16G",
time="4:00:00",
queue="gpu",
)
result = job.submit()
# Wait for completion
status = result.wait()
print(f"Exit code: {result.returncode}")
# Read output
print(result.read_stdout())
Job Dependencies
from hpc_runner import Job
# First job
preprocess = Job(command="python preprocess.py", cpu=8, mem="32G")
result1 = preprocess.submit()
# Second job runs after first succeeds
train = Job(command="python train.py", cpu=4, mem="48G", queue="gpu")
train.after(result1, type="afterok")
result2 = train.submit()
Pipelines
from hpc_runner import Pipeline
with Pipeline("ml_workflow") as p:
p.add("python preprocess.py", name="preprocess", cpu=8)
p.add("python train.py", name="train", depends_on=["preprocess"], queue="gpu")
p.add("python evaluate.py", name="evaluate", depends_on=["train"])
# Auto-submitted when the with-block exits.
# Results are accessible on the pipeline object.
for name, result in p.results.items():
print(name, result.job_id, result.status)
p.wait()
Scheduler Support
| Scheduler | Status | Notes |
|---|---|---|
| SGE | Fully implemented | qsub, qstat, qdel, qrsh |
| Local | Fully implemented | Run as subprocess (for testing) |
| Slurm | Planned | sbatch, squeue, scancel |
| PBS | Planned | qsub, qstat, qdel |
Auto-detection Priority
HPC_SCHEDULERenvironment variable- SGE (
SGE_ROOTorqstatavailable) - Slurm (
sbatchavailable) - PBS (
qsubwith PBS) - Local fallback
Configuration
hpc-runner uses TOML configuration files. Discovery uses a two-level model:
- Project config:
$HPC_RUNNER_CONFIGenv var (if set), otherwise<git-root>/hpc-runner.toml - Local override:
./hpc-runner.tomlin cwd (when different from level 1)
Both levels are deep-merged (local override wins). You can bypass discovery with --config /path/to/file.toml.
Example Configuration
[defaults]
cpu = 1
mem = "4G"
time = "1:00:00"
inherit_env = true
[schedulers.sge]
parallel_environment = "smp"
memory_resource = "mem_free"
purge_modules = true
[types.gpu]
queue = "gpu"
resources = [{name = "gpu", value = 1}]
[types.interactive]
queue = "interactive"
time = "8:00:00"
Use named job types:
hpc run -t gpu python train.py
SGE Configuration
SGE clusters vary widely in how resources are named. The [schedulers.sge]
section lets you match your site's conventions without touching job definitions.
How job fields map to SGE flags:
| Job Field | SGE Flag | Configurable Via |
|---|---|---|
cpu |
-pe <pe_name> <slots> |
parallel_environment |
mem |
-l <resource>=<value> |
memory_resource |
time |
-l <resource>=<value> |
time_resource |
queue |
-q <queue> |
direct |
resources |
-l <name>=<value> |
direct |
Full [schedulers.sge] reference:
[schedulers.sge]
# Resource naming -- these must match your site's SGE configuration
parallel_environment = "smp" # PE name for CPU slots (some sites use "mpi", "threaded", etc.)
memory_resource = "mem_free" # Memory resource name (common alternatives: "h_vmem", "virtual_free")
time_resource = "h_rt" # Time limit resource name (commonly "h_rt")
# Output handling
merge_output = true # Merge stderr into stdout (-j y)
# Module system
purge_modules = true # Run 'module purge' before loading job modules
silent_modules = false # Suppress module command output (-s flag)
module_init_script = "" # Path to module init script (auto-detected if empty)
# Environment
expand_makeflags = true # Expand $NSLOTS in MAKEFLAGS for parallel make
unset_vars = [] # Environment variables to unset in jobs
# e.g. ["https_proxy", "http_proxy"]
Fully populated config example:
[defaults]
scheduler = "auto"
cpu = 1
mem = "4G"
time = "1:00:00"
queue = "batch.q"
use_cwd = true
inherit_env = true
stdout = "hpc.%N.%J.out"
modules = ["gcc/12.2", "python/3.11"]
modules_path = ["/site/modulefiles"] # module use <path>, searched first
modules_path_append = ["$HOME/modulefiles"] # module use --append <path>, searched last
resources = [
{ name = "scratch", value = "20G" }
]
[schedulers.sge]
parallel_environment = "smp"
memory_resource = "mem_free"
time_resource = "h_rt"
merge_output = true
purge_modules = true
silent_modules = false
expand_makeflags = true
unset_vars = ["https_proxy", "http_proxy"]
[tools.python]
cpu = 4
mem = "16G"
time = "4:00:00"
queue = "short.q"
modules = ["-", "python/3.11"] # leading "-" replaces the list instead of merging
modules = ["$XCELIUM_MODULE"] # $VAR / ${VAR} expanded on the submit host; unset or
# empty is an error, never a silent bare "module load"
resources = [
{ name = "tmpfs", value = "8G" }
]
[types.interactive]
queue = "interactive.q"
time = "8:00:00"
cpu = 2
mem = "8G"
[types.gpu]
queue = "gpu.q"
cpu = 8
mem = "64G"
time = "12:00:00"
resources = [
{ name = "gpu", value = 1 }
]
TUI Monitor
Launch the interactive job monitor:
hpc monitor
Key bindings:
q- Quitr- Refreshu- Toggle user filter (my jobs / all)/- SearchEnter- View job detailsTab- Switch tabs
CLI Reference
hpc run [OPTIONS] [SCHEDULER_FLAGS --] COMMAND...
Runs interactively by default; --batch submits and returns.
Options:
--name TEXT Job name
--cpu INTEGER Number of CPUs
--mem TEXT Memory (e.g., 16G, 4096M)
--time TEXT Time limit (e.g., 4:00:00)
--queue TEXT Queue/partition name
--nodes INTEGER Number of nodes (MPI jobs)
--ntasks INTEGER Number of tasks (MPI jobs)
--directory PATH Working directory
-t, --type TEXT Job type from config
--extra-module TEXT Extra module to load on top of config (repeatable)
--stdout TEXT Stdout file path pattern
--stderr TEXT Separate stderr file (default: merged)
--array TEXT Array spec (e.g., 1-100, 1-100%5)
--depend TEXT Job dependencies
-b, --batch Submit as a batch job (default: interactive via qrsh/srun)
--local Run locally (no scheduler)
--dry-run Show script without submitting
--wait Block until a batch job completes
--keep-script Keep job script for debugging
-h, --help Show help
Other commands:
hpc status [JOB_ID] Check job status (--history, --watch, --json)
hpc cancel JOB_ID Cancel a job
hpc monitor Interactive TUI
hpc config show Show active configuration
hpc config init Create starter config
Development
# Setup environment
source sourceme
source sourceme --clean # Clean rebuild
# Run tests
pytest
pytest -v
pytest -k "test_job"
# Type checking
mypy src/hpc_runner
# Linting
ruff check src/hpc_runner
ruff format src/hpc_runner
License
MIT License - see LICENSE file for details.
Metadata
Release files for hpc-runner 0.13.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hpc_runner-0.13.0.tar.gz | 126.9 kB | With provenance | Details for hpc_runner-0.13.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hpc_runner-0.13.0-py3-none-any.whl | Python 3 | none | any | Details for hpc_runner-0.13.0-py3-none-any.whl |
Total release size: 218.6 kB
Release files / hpc_runner-0.13.0.tar.gz
| Download URL | hpc_runner-0.13.0.tar.gz |
|---|---|
| Size | 126.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b9d34573c92a4c152ecacb2c9bff1a1f25c40cbfc61268847e4478aa9463cc26
|
|
BLAKE2b-256 checksum How to use checksums |
f6d2970edc4efdba8a7503b20954ce4ef8cd2b32e9b6c62e151563796d9f206d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logRelease files / hpc_runner-0.13.0-py3-none-any.whl
| Download URL | hpc_runner-0.13.0-py3-none-any.whl |
|---|---|
| Size | 91.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4cab79a116bcb5d82b0c5023de49e5932fa3082f386d08ca36e8731e5e4004f3
|
|
BLAKE2b-256 checksum How to use checksums |
d5182d7ccc7446e94e73f884420222ce276d39a27c126691c6e9af59bb554d49
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logSecurity for hpc-runner 0.13.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for hpc_runner-0.13.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.