TASK - Deployment (model + API serving)
Objective: serve inference/ behind a reproducible runtime on any host. Runtime: Dockerfile; serve path A: CLI, path B: API.
What the Dockerfile is (read before touching)
- Base
python:3.11-slim+ GDAL/system libs,pip install -r requirements.txt, defaultCMDrunspytest -m "not slow"- it is a CI/test image, not a serving image. Override CMD to serve. - Mac training/serving with MPS is host-only - Docker is for Linux CI and CUDA nodes, never for MPS.
Steps - serve the API
- Build:
docker build -t satquery-ai ./backend - Run (override test CMD, mount checkpoint in):
docker run -p 8000:8000 -v $(pwd)/checkpoints:/workspace/checkpoints \
-e SATQUERY_CHECKPOINT=/workspace/checkpoints/final \
satquery-ai python -m uvicorn app.backend.main:app --host 0.0.0.0 --port 8000
- Check:
curl localhost:8000/api/health→{"status":"ok"} - CUDA node: same image +
--gpus all; training uses the DeepSpeed commands inTASK_TRAINING.md, not this container's CMD.
Steps - CLI inference (no server)
python inference/generate.py --model checkpoints/final \
--image example.tif --prompt "Describe the land cover." --task caption
# two-image: --images im1.jpg im2.jpg --task change_detection --modality temporal
Defaults live in configs/inference.yaml (greedy decode, 256 tokens; checkpoint.path null until you set it).
Done criteria
-
/api/healthok from inside and outside the container - One real image → structured result (text and/or boxes/mask) via CLI and API with the same checkpoint
- No checkpoint baked into the image - always mounted via volume +
SATQUERY_CHECKPOINT
Debug
| Symptom | Cause → fix |
|---|---|
| Container exits after tests | you forgot to override CMD - pass the uvicorn command |
rasterio/GDAL import error | system GDAL missing - use the Dockerfile as-is, don't slim the apt list |
| Slow first request | model loads lazily on first request (app/backend/main.py:get_pipeline) - warm it with one call before demo |
| MPS requested in container | unsupported - serve Mac demos natively (source ../.venv/bin/activate), Docker is CPU/CUDA only |