Metadata-Version: 2.4
Name: s2r
Version: 0.3.2
Summary: Convert SLURM submit scripts to Run.ai configurations using AI
Author: slurm2runai contributors
License: MIT
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.31.0
Provides-Extra: iam-auth
Requires-Dist: boto3>=1.28.0; extra == "iam-auth"
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Requires-Dist: boto3>=1.28.0; extra == "dev"
Dynamic: license-file

# s2r - SLURM to Run.ai Converter

Convert SLURM batch scripts to Run.ai configurations using AI.

## Installation

```bash
pip install s2r
```

No AWS account or credentials required — the public hosted endpoint is rate-limited to 100 requests per IP per day. If you self-host and want to keep the Lambda behind IAM auth, install with the optional dependency:

```bash
pip install 's2r[iam-auth]'
```

## Quick Start

### CLI Usage

```bash
# Convert file: saves job.yaml, prints runai CLI command to stdout
s2r job.slurm

# Convert file: saves output.yaml only (no CLI output)
s2r job.slurm output.yaml

# Convert from stdin: prints runai CLI command to stdout (no file)
s2r < my_slurm_script.sh
```

### Library Usage

```python
from s2r import convert_slurm_to_runai

slurm_script = """
#!/bin/bash
#SBATCH --job-name=my-job
#SBATCH --gres=gpu:2
#SBATCH --mem=32G

python train.py
"""

runai_config = convert_slurm_to_runai(slurm_script)
print(runai_config)
```

## How It Works

1. **Client**: The `s2r` library signs your SLURM script with HMAC-SHA256 (no AWS credentials needed)
2. **API**: Sends the signed request to an AWS API Gateway HTTP endpoint
3. **AI**: An AWS Lambda behind the API calls Bedrock (Claude Sonnet 4.6) to perform the conversion
4. **Response**: Returns the Run.ai YAML configuration or CLI commands

## Features

- **Free to use**: The service is provided at no cost (rate-limited)
- **Secure**: Signed requests prevent unauthorized API usage
- **Rate-limited**: 100 requests per IP per day
- **Simple**: Works with stdin, files, or as a library

## Configuration

By default, the tool uses a public API endpoint. If you're deploying your own:

```bash
export S2R_API_ENDPOINT=https://your-api-id.execute-api.us-west-2.amazonaws.com/
```

If you self-host with IAM auth on the endpoint, install the IAM extra and enable signing:

```bash
pip install 's2r[iam-auth]'
export S2R_USE_IAM_AUTH=true
export S2R_AWS_REGION=us-west-2
```

## Example

Given this SLURM script:

```bash
#!/bin/bash
#SBATCH --job-name=pytorch-training
#SBATCH --nodes=1
#SBATCH --cpus-per-task=8
#SBATCH --mem=32G
#SBATCH --gres=gpu:2
#SBATCH --time=24:00:00

python train.py --epochs 100
```

The tool will generate an equivalent Run.ai configuration with:
- GPU resource requests (2 GPUs)
- CPU and memory allocations
- Job name and command
- Appropriate container/image specifications

## Documentation

- **[API Reference](https://github.com/dirkpetersen/slurm2runai/blob/main/docs/api.md)**: Complete API documentation for library and CLI
- **[Architecture](https://github.com/dirkpetersen/slurm2runai/blob/main/docs/architecture.md)**: System design and component details
- **[Deployment Guide](https://github.com/dirkpetersen/slurm2runai/blob/main/docs/deployment.md)**: AWS Lambda deployment instructions
- **[Troubleshooting](https://github.com/dirkpetersen/slurm2runai/blob/main/docs/troubleshooting.md)**: Common issues and solutions
- **[CLAUDE.md](https://github.com/dirkpetersen/slurm2runai/blob/main/CLAUDE.md)**: Quick reference for Claude Code

## Current Deployment Status

**Deployed in us-west-2:**
- API Gateway HTTP API → Lambda `s2r-converter` → Bedrock
- Model: Claude Sonnet 4.6 (`us.anthropic.claude-sonnet-4-6` cross-region inference profile)
- Rate Limit: 100 requests/IP/day (DynamoDB-backed)
- Public endpoint, no AWS credentials required to use the client

## Development

See [CLAUDE.md](https://github.com/dirkpetersen/slurm2runai/blob/main/CLAUDE.md) for development commands and quick reference.

For detailed architecture and deployment information, see the [docs/](https://github.com/dirkpetersen/slurm2runai/tree/main/docs) directory.

## Self-Hosting

To deploy your own instance with API Gateway + Lambda:

```bash
git clone https://github.com/dirkpetersen/slurm2runai.git
cd slurm2runai/lambda

# Deploy with SAM (creates API Gateway, Lambda, DynamoDB)
sam deploy --guided

# Point your client at the new endpoint
export S2R_API_ENDPOINT=https://<api-id>.execute-api.<region>.amazonaws.com/
```

See [docs/deployment.md](https://github.com/dirkpetersen/slurm2runai/blob/main/docs/deployment.md) for full instructions.

## License

MIT License - see [LICENSE](https://github.com/dirkpetersen/slurm2runai/blob/main/LICENSE) file for details.

## Contributing

Contributions welcome! Please:
1. Open an issue to discuss changes
2. Follow the code style (ruff)
3. Add tests for new features
4. Update documentation
