Skip to main content

SSH-only Slurm cluster client library

Project description

slurmly

SSH-only Slurm client library for Python.

slurmly controls Slurm clusters by running the standard CLI (sbatch, squeue, sacct, scancel) over SSH against a login node. No REST API, no PySlurm, no C bindings — if you can ssh to the login node, you can drive jobs from Python.

  • Fully typed (Pydantic v2), async-first, framework-agnostic.
  • First-class support for job arrays, dependencies, batched status, artifacts, cleanup, and capability detection.
  • Observable via typed hooks; testable with an in-memory FakeTransport (no SSH or cluster required).

Installation

pip install slurmly

Requires Python 3.11+. Runtime dependencies: asyncssh>=2.14, pydantic>=2.5, PyYAML>=6.0.


Quickstart

import asyncio
from slurmly import SlurmSSHClient, JobSpec

async def main():
    async with SlurmSSHClient.connect(
        host="login.example.edu",
        username="myuser",
        key_path="~/.ssh/cluster_ed25519",       # absolute paths work too
        account="my_allocation",
    ) as client:
        job = await client.submit(JobSpec(
            name="hello",
            command_template="echo hi from $HOSTNAME",
            partition="shared",
            time_limit="00:01:00",
        ))
        info = await client.get_job(job.slurm_job_id, submitted_at=job.submitted_at)
        print(job.slurm_job_id, info.lifecycle)

asyncio.run(main())

That's the whole API. For polling loops, log tailing, arrays, dependencies, artifacts, and cleanup, see docs/cookbook.md.

Loading from a config file (optional)

If you'd rather keep configuration out of code, SlurmSSHClient.from_config(path) reads YAML, TOML, or JSON. See docs/configuration.md for the full schema. Minimal slurmly.yaml:

ssh:
  host: login.example.edu
  username: myuser
  key_path: ~/.ssh/cluster_ed25519   # private key (not .pub)

slurm:
  account: my_allocation
  # remote_base_dir defaults to ~/slurmly when omitted
async with SlurmSSHClient.from_config("slurmly.yaml") as client:
    ...

Features

Capability Entry point
Submit a job client.submit(spec)
Render-only (no SSH) client.render_only(spec)
Cancel / signal client.cancel(job_id, signal=...)
Tail stdout / stderr client.tail_stdout(job), client.tail_stderr(job)
Get a single status client.get_job(job_id, submitted_at=...)
Get many statuses (batched) client.get_jobs([id1, id2, ...])
Polling helpers client.poll_job(...), PollingPolicy, is_terminal(...)
Capability probe client.detect_capabilities()
Job arrays JobSpec(array="0-99%10", command_template=...)
Typed dependencies JobDependency(type="afterok", job_ids=[...])
List / download artifacts client.list_artifacts(job), client.download_artifact(job, ...)
Plan / execute remote cleanup client.plan_cleanup(...), client.cleanup(plan)
Observability hooks Subclass SlurmlyHooks, pass to constructor
In-memory testing from slurmly.testing import FakeTransport

Documentation

Topic File
API reference docs/api-reference.md
Configuration files (YAML/TOML/JSON) docs/configuration.md
Purdue Anvil guide docs/anvil.md
Cookbook (patterns & recipes) docs/cookbook.md

License

MIT.

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

slurmly-0.1.0.tar.gz (68.2 kB view details)

Uploaded Source

Built Distribution

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

slurmly-0.1.0-py3-none-any.whl (48.7 kB view details)

Uploaded Python 3

File details

Details for the file slurmly-0.1.0.tar.gz.

File metadata

  • Download URL: slurmly-0.1.0.tar.gz
  • Upload date:
  • Size: 68.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for slurmly-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2c27922d3af5d8687a372a935f51674362199f5ab336701beeb26a6580397312
MD5 7f19c0b054582ec618cd516df4b8e18f
BLAKE2b-256 23a3703e71d6d9b742d878203101ac34ee2b2b9085bf5ad8a4292403d7a063bb

See more details on using hashes here.

File details

Details for the file slurmly-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: slurmly-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 48.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for slurmly-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b55c247dab000b52b61008ea57856931824778a913878e40e04439ab3f775292
MD5 3d2e5e9d78d2818adaea8cf10e9b71c8
BLAKE2b-256 f7e2a6bad3f8a64c2f4c32174192adf40da9439182f67b21d22489f424c0ad0f

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