Metadata-Version: 2.4
Name: sleap-rtc
Version: 0.0.7
Summary: Real-time communication layer for remote SLEAP training and inference
License-File: LICENSE
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.11
Requires-Dist: aiohttp>=3.9.0
Requires-Dist: aiortc
Requires-Dist: boto3
Requires-Dist: cryptography>=41.0.0
Requires-Dist: jsonpickle
Requires-Dist: loguru
Requires-Dist: opencv-python-headless>=4.12.0.88
Requires-Dist: prompt-toolkit>=3.0.0
Requires-Dist: pycrdt>=0.8.0
Requires-Dist: pyjwt>=2.8.0
Requires-Dist: pyotp>=2.9.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: pyzmq
Requires-Dist: requests
Requires-Dist: rich-click>=1.7.0
Requires-Dist: textual>=0.50.0
Requires-Dist: tomli-w>=1.2.0
Requires-Dist: websockets
Provides-Extra: dev
Requires-Dist: black; extra == 'dev'
Requires-Dist: pyqt5; (sys_platform != 'win32') and extra == 'dev'
Requires-Dist: pyqt6; (sys_platform == 'win32') and extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: pytest-asyncio; extra == 'dev'
Requires-Dist: pytest-timeout; extra == 'dev'
Requires-Dist: pyyaml; extra == 'dev'
Requires-Dist: qtpy; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Requires-Dist: sleap-io; extra == 'dev'
Description-Content-Type: text/markdown

# sleap-rtc (SLEAP Connect)

Remote training and inference for [SLEAP](https://sleap.ai) — run `sleap-nn` on a GPU worker from your local machine.

## Quick Start

### Option 1: Dashboard

1. **Login** — Go to the [dashboard](https://talmolab.github.io/sleap-rtc/dashboard/index.html) and log in with GitHub.
2. **Create a room** — Click **Rooms** → **Create Room**.
3. **Generate an account key** — Go to **Account Keys** and create one. Copy it for the worker.
4. **Deploy a worker** — On your GPU machine, install and start a worker:

   ```bash
   # Install sleap-rtc with sleap-nn (auto-detects GPU)
   uv tool install --python 3.11 sleap-rtc \
     --with "sleap-nn[torch]" \
     --with-executables-from sleap-nn \
     --torch-backend auto

   # Login and start the worker
   sleap-rtc login
   sleap-rtc config add-mount /path/to/your/data
   sleap-rtc worker --room <room-id>
   ```

5. **Submit a job** — In the dashboard, click **Submit Job** on your room card, select the worker, upload a config, and submit.

### Option 2: CLI

```bash
# Install on the GPU machine (auto-detects GPU)
uv tool install --python 3.11 sleap-rtc \
  --with "sleap-nn[torch]" \
  --with-executables-from sleap-nn \
  --torch-backend auto

# Login with GitHub (opens browser)
sleap-rtc login

# Configure data mounts
sleap-rtc config add-mount /path/to/your/data

# Start the worker in a room
sleap-rtc worker --room <room-id>
```

Then submit jobs from:
- The [dashboard](https://talmolab.github.io/sleap-rtc/dashboard/index.html) web UI
- The SLEAP GUI (Remote Training dialog under **Predict → Run Training**)

### Docker

```bash
# Pull and run the worker image
docker run --gpus all \
  -e SLEAP_RTC_ACCOUNT_KEY=<your-account-key> \
  -v /path/to/data:/app/shared_data \
  ghcr.io/talmolab/sleap-rtc:latest \
  worker --room <room-id>
```

## Installation

**Worker (GPU machine):**

```bash
# Auto-detect GPU (recommended)
uv tool install --python 3.11 sleap-rtc \
  --with "sleap-nn[torch]" \
  --with-executables-from sleap-nn \
  --torch-backend auto
```

Or specify a backend explicitly:

```bash
# CUDA GPU
uv tool install --python 3.11 sleap-rtc \
  --with "sleap-nn[torch-cuda130]" \
  --with-executables-from sleap-nn

# CPU only
uv tool install --python 3.11 sleap-rtc \
  --with "sleap-nn[torch-cpu]" \
  --with-executables-from sleap-nn
```

**Pre-flight check:**

```bash
sleap-rtc doctor
```

## How It Works

1. Workers connect to a signaling server via WebSocket and join a room.
2. Clients (dashboard, SLEAP GUI, or sleap-app) connect to the same room.
3. WebRTC peer connections are established for direct communication.
4. Jobs are submitted as structured specs (training or inference) and executed on the worker's GPU.
5. Progress streams back in real-time. Results are saved to shared storage.

## Links

- [SLEAP](https://sleap.ai) — Pose estimation framework
- [sleap-nn](https://nn.sleap.ai) — Neural network backend
- [Dashboard](https://talmolab.github.io/sleap-rtc/dashboard/index.html) — Web UI for room and job management
- [sleap-app](https://app.sleap.ai) — Modern SLEAP labeling GUI
