feat: add /bootstrap snapshot, numeric UID 10001, CI gate

GET /bootstrap returns the 8 sensors, hourly series for all of them,
context, meta, and versions in the CONTRACT.md shape. Snapshot artifacts
are projected to contract fields once at boot; incomplete artifacts return
503. Adds tests for shape, sensor count, hourly alignment, and versions.

Dockerfile now creates UID/GID 10001, uses COPY --chown=10001:10001, and
runs as USER 10001:10001. Adds make check and a minimal Gitea Actions
workflow that runs the same local gate: uv sync --frozen, compileall, pytest.
This commit is contained in:
Noel Sabia committed 2026-11-14 06:00:14 +01:00
1 parent 7ec4fc8bb3
commit 8656d9bc8a
6 files changed
+210 -12

No files matched your search

+4 -2
View File
@@ -48,6 +48,7 @@ uv sync
make data # needs the raw CSV, first run also fetches Open-Meteo weather
make train # writes artifacts/model.joblib, metrics.json, forecasts.json
make test
make check # CI gate: uv sync --frozen, compileall, pytest
make serve # http://localhost:8000
```
@@ -84,6 +85,7 @@ Shapes follow `CONTRACT.md`. The service is internal; Go exposes it publicly.
| `GET` | `/healthz` | `{"ok":true}` |
| `GET` | `/readyz` | `{"ok":true,"model":true}`, 503 if no model |
| `GET` | `/meta` | Versions, coverage, metrics, features, holiday effect |
| `GET` | `/bootstrap` | Snapshot for Go: sensors, hourly series, context, meta |
| `POST` | `/predict` | `{sensor,horizon,scenario,weather?,is_holiday?}` → `points` |
| `POST` | `/simulate` | Scenario forecast for all or selected sensors |
| `POST` | `/train` | Control token; multipart CSV or JSON path; 202 job |
@@ -123,8 +125,8 @@ make docker
docker run --rm -p 8000:8000 -e CONTROL_TOKEN=change-me pulsecast-ml:local
```
Multi-stage `python:3.12-slim`, non-root user, model and artifacts baked in,
writable paths only under `/tmp`.
Multi-stage `python:3.12-slim`, numeric non-root user `10001:10001`, model and
artifacts baked in, writable paths only under `/tmp`.
## Configuration