Skip to main content

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, default CMD runs pytest -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​

  1. Build: docker build -t satquery-ai ./backend
  2. 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
  1. Check: curl localhost:8000/api/health → {"status":"ok"}
  2. CUDA node: same image + --gpus all; training uses the DeepSpeed commands in TASK_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/health ok 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​

SymptomCause → fix
Container exits after testsyou forgot to override CMD - pass the uvicorn command
rasterio/GDAL import errorsystem GDAL missing - use the Dockerfile as-is, don't slim the apt list
Slow first requestmodel loads lazily on first request (app/backend/main.py:get_pipeline) - warm it with one call before demo
MPS requested in containerunsupported - serve Mac demos natively (source ../.venv/bin/activate), Docker is CPU/CUDA only