Skip to main content
2025 Python Packaging Survey is now live!  Take the survey now

SLURM utilities for Python

Project description

pyslurmutils

SLURM utilities for Python.

Demo

Get an access token on rnice

export SLURM_TOKEN=$(scontrol token lifespan=3600)
export SLURM_URL=...
export SLURM_USER=...

Run any of the example scripts

python3 scripts/examples.py

Run the tests (CI or locally)

python3 -m pytest .

When SLURM_TOKEN, SLURM_URL or SLURM_USER is missing it will mock the SLURM clients.

Execute a python function on SLURM

Execute a function on SLURM with an API similar to python's concurrent.futures

from pyslurmutils.concurrent.futures import SlurmRestExecutor

with SlurmRestExecutor(
    url,
    user_name,
    token,
    log_directory=log_directory,  # for log files
    data_directory=data_directory,  # TCP when not provided
    pre_script="source /etc/profile\nmodule load ewoks",  # load environment
    python_cmd="python",
) as pool:

    future = pool.submit(sum, [1, 1])
    assert future.result() == 2

Supported by

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