Convert SLURM submit scripts to Run.ai configurations using AI
Project description
s2r - SLURM to Run:ai Converter
Convert SLURM batch scripts to Run:ai configurations using AI.
Installation
pip install s2r
No AWS account or credentials required — a public hosted endpoint handles conversion (rate-limited to 1000 requests per IP per day).
pip install 's2r[iam-auth]' # only needed if you self-host behind IAM auth
Quick Start
First run — setup wizard
On the first run with no arguments s2r detects your Run:ai environment and
saves the configuration to ~/.runai/runai.env:
$ s2r
s2r — SLURM to Run:ai converter
runai CLI detected in PATH.
Auto-detect project, cluster, and datasources from 'runai' CLI? [Y/n]:
Detected:
project = osu-default
datasources:
cache (HostPath)
my-bucket (S3)
Configure environment variables now? [Y/n]:
RUNAI_PROJECT [osu-default]:
RUNAI_BUCKET (optional, S3 datasource name or s3://uri) [my-bucket]:
RUNAI_CACHE (datasource name for cache) [cache]:
Saved to /home/user/.runai/runai.env:
RUNAI_PROJECT=osu-default
RUNAI_BUCKET=my-bucket
RUNAI_CACHE=cache
These will be loaded automatically next time you run s2r.
Run s2r --config at any time to update the configuration.
Converting scripts
# Convert file — prints the runai shell script to stdout
s2r job.slurm
# Convert and submit in one step (the printed script is pipe-safe)
s2r job.slurm | bash
# Convert from stdin
s2r < my_slurm_script.sh
cat job.slurm | s2r
# Print the assembled prompt that would be sent to the LLM (no LLM call,
# no rate-limit charge) — useful for debugging conversion behaviour
s2r --prompt job.slurm
Note: YAML manifest output (
runai workload submit --file) is not yet implemented — Run:ai 2.25 only accepts standard Kubernetes/Kubeflow kinds (Job, PyTorchJob, etc.) via that path. s2r currently emits the imperativerunai training standard submitshell command instead.
Library usage
from s2r import convert_slurm_to_runai
result = convert_slurm_to_runai("""
#!/bin/bash
#SBATCH --job-name=my-job
#SBATCH --gres=gpu:2
#SBATCH --mem=32G
python train.py
""")
print(result)
How It Works
s2rloads~/.runai/runai.envand injects your project/bucket/cache as context into the SLURM script- Signs the request with HMAC-SHA256 (no AWS credentials needed on the client)
- POSTs to an AWS API Gateway HTTP endpoint
- A Lambda behind the API calls Bedrock (Claude Opus 4.7) to convert the script
- Returns two fenced blocks: a
TrainingWorkloadYAML manifest + arunaishell script
Configuration
~/.runai/runai.env (auto-loaded on every run)
Created by s2r --config or on first run. Supports standard .env format.
Shell environment variables always take precedence.
| Variable | Effect |
|---|---|
RUNAI_PROJECT |
Fills --project and namespace: runai-<PROJECT> in output |
RUNAI_BUCKET |
S3 datasource name or s3://uri — mounted at /mnt/<name> |
RUNAI_CACHE |
HostPath datasource name for cache (e.g. cache) |
Other environment variables
export S2R_API_ENDPOINT=https://... # custom endpoint (self-hosted)
export S2R_AWS_REGION=us-west-2 # region for SigV4 (self-hosted IAM auth)
export S2R_USE_IAM_AUTH=true # enable IAM auth (requires s2r[iam-auth])
export S2R_VERBOSE=1 # show detection/API warnings
Example output
Given this SLURM script:
#!/bin/bash
#SBATCH --job-name=train
#SBATCH --cpus-per-task=8
#SBATCH --mem=32G
#SBATCH --gres=gpu:2
python train.py --epochs 100
s2r produces a train.yaml (TrainingWorkload CRD) and prints the equivalent
runai training standard submit command to stdout, with RUNAI_PROJECT,
--s3, and --datasource filled in from your saved configuration.
S3 datasource auto-provisioning
If you enter a bucket name that is not yet registered in Run:ai, the setup
wizard offers to create it automatically using your AWS credentials from
~/.aws/credentials (or AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY):
'my-new-bucket' is not yet registered as a Run:ai datasource.
Using AWS default profile (key: AKIAV44S...)
Create S3 datasource 'my-new-bucket' in Run:ai now? [Y/n]:
S3 endpoint URL [https://s3.amazonaws.com]:
Datasource 'my-new-bucket' created successfully.
Current deployment
| Resource | Value |
|---|---|
| Endpoint | AWS API Gateway HTTP API (zzk4zf48pi, us-west-2) |
| Model | Claude Opus 4.7 (us.anthropic.claude-opus-4-7) |
| Rate limit | 1000 requests / IP / day |
| Auth | HMAC-SHA256 (no AWS credentials required) |
Self-hosting
git clone https://github.com/dirkpetersen/slurm2runai.git
cd slurm2runai/lambda
sam deploy --guided # creates API Gateway + Lambda + DynamoDB
# then set S2R_API_ENDPOINT to the output URL
See CLAUDE.md and SETUP_JOURNEY.md for full deployment and architecture details.
Examples
See examples/ for reproduction-ready Run:ai job examples (GPU detection, R statistics, PyTorch training).
Development
pip install -e ".[dev]"
pytest
ruff check .
License
MIT — see LICENSE
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file s2r-0.4.3.tar.gz.
File metadata
- Download URL: s2r-0.4.3.tar.gz
- Upload date:
- Size: 19.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16591c17de6ce4fc37e2ce2f14808f9cad6efc4cd571a73b26d127e1c0f9925a
|
|
| MD5 |
9092af32bc4b2e69c1d3ae10a8a43bce
|
|
| BLAKE2b-256 |
2bb69eaa351972cc28a616d4e8c2a643bcbc7a91062dbf6d5b72cd5f3745014e
|
Provenance
The following attestation bundles were made for s2r-0.4.3.tar.gz:
Publisher:
publish-pypi.yml on dirkpetersen/slurm2runai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
s2r-0.4.3.tar.gz -
Subject digest:
16591c17de6ce4fc37e2ce2f14808f9cad6efc4cd571a73b26d127e1c0f9925a - Sigstore transparency entry: 1525130818
- Sigstore integration time:
-
Permalink:
dirkpetersen/slurm2runai@12eb96a1a3651eafa7b8de49f3ee8f4b522d9849 -
Branch / Tag:
refs/tags/v0.4.3 - Owner: https://github.com/dirkpetersen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@12eb96a1a3651eafa7b8de49f3ee8f4b522d9849 -
Trigger Event:
release
-
Statement type:
File details
Details for the file s2r-0.4.3-py3-none-any.whl.
File metadata
- Download URL: s2r-0.4.3-py3-none-any.whl
- Upload date:
- Size: 19.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cdba0a634634ed28a8514081efde52f6820f2c1be96603ba6ebeaac6cb9ab93
|
|
| MD5 |
3edf9d7c8707377da8bd93e1385e8a2a
|
|
| BLAKE2b-256 |
f5eb4717bfb09db8e71d26c07bd118eecb010cc2f51acedb64853d15c65bd9b5
|
Provenance
The following attestation bundles were made for s2r-0.4.3-py3-none-any.whl:
Publisher:
publish-pypi.yml on dirkpetersen/slurm2runai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
s2r-0.4.3-py3-none-any.whl -
Subject digest:
6cdba0a634634ed28a8514081efde52f6820f2c1be96603ba6ebeaac6cb9ab93 - Sigstore transparency entry: 1525130881
- Sigstore integration time:
-
Permalink:
dirkpetersen/slurm2runai@12eb96a1a3651eafa7b8de49f3ee8f4b522d9849 -
Branch / Tag:
refs/tags/v0.4.3 - Owner: https://github.com/dirkpetersen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@12eb96a1a3651eafa7b8de49f3ee8f4b522d9849 -
Trigger Event:
release
-
Statement type: