Metadata-Version: 2.4
Name: slurmray
Version: 5.3.0
Summary: SlurmRay is an official tool from DESI @ HEC UNIL for effortlessly distributing tasks on Slurm clusters (e.g., Curnagl) or standalone servers (e.g., ISIPOL09/Desi) using the Ray library.
License: Apache License
License-File: LICENSE
Keywords: ray,slurm,distributed-computing,hpc,desi,hec-unil
Author: Henri Jamet
Author-email: henri.jamet@unil.ch
Requires-Python: >=3.9,<4.0
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: dill (>=0.3.7,<0.4.0)
Requires-Dist: inquirer (>=3.1.3,<4.0.0)
Requires-Dist: paramiko (>=3.3.1,<4.0.0)
Requires-Dist: pdoc3 (>=0.10.0,<0.11.0)
Requires-Dist: pip-chill (>=1.0.3,<2.0.0)
Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
Requires-Dist: ray[data,serve,train,tune] (>=2.7.1,<3.0.0)
Requires-Dist: rich (>=14.2.0,<15.0.0)
Requires-Dist: setuptools (>=80.9.0,<81.0.0)
Project-URL: Documentation, https://henri-jamet.vercel.app/cards/documentation/slurm-ray/slurm-ray/
Project-URL: Homepage, https://henri-jamet.vercel.app/
Description-Content-Type: text/markdown

# SLURM_RAY

**SLURM_RAY** is a powerful tool designed to simplify the execution of Python code on remote clusters (Slurm) and standalone servers. It automates the complex process of dependency management, environment setup, and job submission, allowing you to run your local code on remote resources with a single command.

## Installation

Prerequisites:
- Python 3.8+
- SSH access to a Slurm cluster or remote server
- [Poetry](https://python-poetry.org/) (recommended for development) or pip

Installation via pip:
```bash
pip install slurmray
```
*Installs the package and its dependencies.*

Installation for development:
```bash
git clone https://github.com/lopilo/SLURM_RAY.git
cd SLURM_RAY
poetry install
```
*Clones the repository and installs dependencies in a virtual environment using Poetry.*

## Key Features

- **Automatic Dependency Management**: Generates optimized `requirements.txt` and handles virtual environment creation on the remote server.
- **Smart Code Synchronization**: Automatically detects and uploads only the necessary local code files based on your function's imports.
- **Incremental Uploads**: Uses file hashing to upload only modified files, saving bandwidth and time.
- **Robust Local Detection**: Distinguishes between installed libraries and local code regardless of virtual environment location or naming.
- **Multi-Backend Support**: Supports Slurm clusters (Curnagl) and standalone servers (Desi/ISIPOL).
- **Seamless Execution**: Serializes your function and arguments, executes them remotely, and retrieves the results.

## Usage Example

```python
from slurmray.RayLauncher import RayLauncher
import ray

def my_func(x):
    return x * x

# Initialize launcher
launcher = RayLauncher(
    project_name="my_project",
    cluster="desi",  # or 'curnagl', 'local', '192.168.1.10'
    use_gpu=True,
    retention_days=1  # Retain files and venv for 1 day before cleanup (1-30 days)
)

# Execute function remotely
result = launcher(my_func, args={"x": 5})
print(result) # 25
```

## Repository Structure

```
root/
├── slurmray/               # Main package source code
│   ├── backend/            # Backend implementations (Slurm, Desi, Local)
│   ├── assets/             # Static assets (scripts, templates)
│   ├── RayLauncher.py      # Main entry point class
│   ├── scanner.py          # Code analysis and dependency detection
│   └── file_sync.py        # File hashing and synchronization
├── tests/                  # Unit and integration tests
├── examples/               # Usage examples
├── documentation/          # Detailed documentation
└── pyproject.toml          # Project configuration and dependencies
```

## Main Entry Points (scripts/)

| Script | Description | Example |
|---|---|---|
| `slurmray/RayLauncher.py` | Main class for programmatic usage. Can be run directly for testing. | `python slurmray/RayLauncher.py` |

## Roadmap

| Task | Objective | State | Dependencies |
|---|---|---|---|
| **Robust Local Detection** | Detect local vs installed packages using `site.getsitepackages` instead of hardcoded paths. | ✅ Done | - |
| **Smart Requirements** | Filter local packages from `requirements.txt` based on installation path to avoid pip errors. | ✅ Done | Robust Local Detection |
| **Incremental Sync** | Implement hash-based file synchronization to upload only changed files. | ✅ Done | - |
| **Recursive Scan** | Detect dependencies by recursively scanning imports starting from the target function. | ✅ Done | - |

