TuneOS runs in two configurations from one codebase: a local Docker Compose stack for development, and two Hugging Face Spaces connected by an external Redis broker for cloud hosting.
The quickest path is Docker Compose, which starts Redis and a Celery worker alongside the application.
cp .env.example .env
# Add HF_TOKEN if you plan to use gated models (Llama 3, Mistral-instruct)
docker-compose upThe Reflex UI is available at http://localhost:3000 and the FastAPI service at
http://localhost:8000.
# terminal 1 — Redis broker
redis-server
# terminal 2 — Celery worker (runs the actual training)
celery -A workers.celery_app worker --loglevel=info
# terminal 3 — Reflex application
poetry run reflex runThe cloud topology uses two Spaces. The App Space runs nginx, Reflex, and FastAPI. The Worker Space runs the Celery worker. Both connect to a shared Upstash Redis instance.
Browser
--> App Space (port 7860)
nginx --> Reflex frontend (3000)
--> FastAPI /api (8000)
|
Upstash Redis (external)
|
Worker Space --> Celery worker --> trainer/
- Create a free account at upstash.com.
- Create a Redis database (any region).
- Copy the Redis URL — it looks like
rediss://default:PASSWORD@HOST:PORT.
Create a Space with the Docker SDK, then push the hf_spaces/ directory as the
Space repository root:
cd hf_spaces
git init
git remote add origin https://huggingface.co/spaces/<username>/TuneOS-Worker
git add .
git commit -m "init worker"
git push -u origin mainIn the Space settings add these repository secrets:
| Secret | Value |
|---|---|
REDIS_URL |
Your Upstash Redis URL |
HF_TOKEN |
Your Hugging Face token |
Create a second Space with the Docker SDK. The App Space needs the full repository so Reflex can build:
git remote add hf-app https://huggingface.co/spaces/<username>/TuneOS
git push hf-app mainAdd the same secrets in the App Space settings.
| Variable | Description | Required |
|---|---|---|
REDIS_URL |
Redis broker URL | Yes |
HF_TOKEN |
Hugging Face token for gated models and Hub push | Recommended |
OPENROUTER_API_KEY |
OpenRouter key for intent flow and synthetic data | Optional |
MODAL_TOKEN_ID |
Modal.com token ID for cloud GPU training | Optional |
MODAL_TOKEN_SECRET |
Modal.com token secret | Optional |
EXPERIMENTS_DB_URL |
PostgreSQL DSN; defaults to local SQLite | Optional |
OUTPUT_DIR |
Where adapter weights are stored | Optional |
If no local GPU is available, individual jobs can route to a free Modal.com T4.
- Sign up at modal.com and create an API token under Settings → Tokens.
- Install the optional dependency:
poetry install --with modal - Add credentials to
.env:
MODAL_TOKEN_ID=ak-...
MODAL_TOKEN_SECRET=as-...- In Step 4 (Configure), choose Modal under Compute backend before submitting.
The local Celery worker stays the orchestrator. It serializes the dataset, runs the training pipeline remotely on a T4, and streams the adapter and eval metrics back to local disk. Loss progress is published to the shared Redis broker so the loss chart updates live — identical to a local run.
Modal's free tier provides roughly $30/month of compute (~10-15 T4 hours). If credentials are absent when Modal is selected, the job fails fast with a clear message and nothing is queued.
When multiple worker machines share one experiment store, switch from SQLite to PostgreSQL:
EXPERIMENTS_DB_URL=postgresql://user:password@host:5432/tuneos
poetry install --with postgres # installs psycopg2-binaryAll upsert statements use portable ON CONFLICT ... DO UPDATE syntax compatible with
both SQLite 3.24+ and PostgreSQL.
The macOS desktop build packages the full stack into a native .app bundle.
poetry install --with desktop
poetry run python build_desktop.py
open dist/TuneOS.appThe PyQt6 shell starts Reflex, FastAPI, Redis, and the Celery worker automatically. When Docker is available it uses Docker Compose; otherwise services start as local subprocesses. Windows and Linux packaging is planned.