You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: backend/ARCHITECTURE.md
+14-10Lines changed: 14 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ What happens behind each step:
23
23
| Step | What the backend does | Output |
24
24
| --- | --- | --- |
25
25
|**1. AOI**| Validates polygon, stores in postgres. | Row in `datasets_aoi`. |
26
-
|**2. Build dataset**| Async worker downloads OAM tiles + OSM labels for the AOI, uploads chips + `labels.geojson` to MinIO, registers a STAC item under `datasets/`. |Published STAC dataset. Poll `GET /datasets/{id}/` until `build_status=published`. |
26
+
|**2. Build dataset**| Async worker downloads OAM tiles + OSM labels for the AOI, uploads chips + `labels.geojson` to MinIO, registers a STAC item under `datasets/`. |Built STAC dataset. Poll `GET /datasets/{id}/` until `status=built`. |
27
27
|**3. Submit training**| Async worker submits a ZenML pipeline. ZenML schedules an orchestrator + step pods on the autoscaling ml pool (`split -> train -> eval -> onnx`). Worker polls ZenML status into the DB every 30s. | Trained `weights.pt` + `model.onnx` in MinIO. Poll `GET /trainings/{id}/` until `status=completed`. Tail with `GET /trainings/runs/{run_id}/logs/`. |
28
28
|**4. Promote**| API builds a versioned STAC `local-models/` item from the run's hyperparameters + asset URLs, validates against the base-model's `fair:hyperparameters_spec`, publishes. |`local_model_stac_id`. |
29
29
|**5. Predict**| Async worker downloads chips for the requested bbox, submits an inference pipeline, then post-processes the geojson into `.fgb` + `.pmtiles` via tippecanoe. | Three presigned URLs at `GET /predictions/{id}/result/` once `results_ready=true`. |
All endpoints live under `/api/v1/`and require `Authorization: Bearer <token>`. The token is `FAIR_DEV_TOKEN` when `AUTH_PROVIDER=dev`, or a Hanko-issued JWT when `AUTH_PROVIDER=hanko`. Swagger UI: `/api/docs/`. OpenAPI: `/api/schema/`.
135
+
All endpoints live under `/api/v1/`. Writes and owner-scoped reads require `Authorization: Bearer <token>`. The token is `FAIR_DEV_TOKEN` when `AUTH_PROVIDER=dev`, or a Hanko-issued JWT when `AUTH_PROVIDER=hanko`. `GET` on datasets, local-models, and predictions is open anonymously for rows with `visibility="public"`. Private rows are invisible to anonymous callers (404, not 401). Swagger UI: `/api/docs/`. OpenAPI: `/api/schema/`.
134
136
135
137
### Core flow
136
138
@@ -140,9 +142,11 @@ All endpoints live under `/api/v1/` and require `Authorization: Bearer <token>`.
140
142
| POST |`/aois/`| Create an AOI polygon (GeoJSON Feature) |
| GET |`/datasets/{id}/?expand=stac`| Inspect dataset, with STAC metadata + presigned `chips`/`labels` URLs once published |
144
-
| GET |`/local-models/`| List published local models (the *family*; STAC has per-version detail) |
145
+
| GET |`/datasets/{id}/?expand=stac`| Inspect dataset, with STAC metadata + presigned `chips`/`labels` URLs once `status=built`|
146
+
| POST |`/datasets/{id}/{publish,unpublish}/`| Toggle dataset `visibility` (anonymous read) |
147
+
| GET |`/local-models/`| List local models (filterable by `status`, `visibility`, `user`) |
145
148
| GET |`/local-models/{id}/runs/`| List ZenML pipeline runs that produced this model |
149
+
| POST |`/local-models/{id}/{publish,unpublish}/`| Toggle local-model `visibility` (anonymous read) |
146
150
| POST |`/trainings/submit/`| Enqueue a finetune. `base_model_stac_id`, `dataset_stac_id`, `model_name`, `overrides` (must match base-model's `fair:hyperparameters_spec`) |
147
151
| GET |`/trainings/{id}/`| Run state including `zenml_run_id`|
148
152
| GET |`/trainings/runs/{run_id}/status/`| Force-poll ZenML; refreshes the DB row |
@@ -153,7 +157,7 @@ All endpoints live under `/api/v1/` and require `Authorization: Bearer <token>`.
153
157
| GET |`/predictions/{id}/`| Status + assets (presigned) once `results_ready=true`|
154
158
| GET |`/predictions/{id}/result/`| Just the three presigned URLs (geojson / fgb / pmtiles); 409 until `results_ready`|
155
159
| GET |`/predictions/runs/{run_id}/{status,logs}/`| Same shape as trainings |
156
-
| POST |`/predictions/{id}/{publish,unpublish}/`| Toggle `is_public` (anonymous read of result) |
160
+
| POST |`/predictions/{id}/{publish,unpublish}/`| Toggle prediction `visibility` (anonymous read of result) |
**3. Wait for the build** : `GET /api/v1/datasets/{DATASET_ID}/`
209
213
210
-
Poll until `build_status == "published"` (~2 min for this AOI).
214
+
Poll until `status == "built"` (~2 min for this AOI). To make it readable by anonymous users, follow up with `POST /api/v1/datasets/{DATASET_ID}/publish/`.
211
215
212
216
**4. Submit the fine-tune** : `POST /api/v1/trainings/submit/`
Copy file name to clipboardExpand all lines: backend/README.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,8 @@ OpenAPI schema at `/api/schema/`, Swagger UI at `/api/docs/`, ReDoc at `/api/red
42
42
43
43
`AUTH_PROVIDER` selects the auth backend. Both share one contract: `Authorization: Bearer <token>`. `hanko` (production) validates a per-user JWT issued by Hanko (sent via Bearer header or `hanko` cookie). `dev` (local only) compares the Bearer token against the static `FAIR_DEV_TOKEN`; anyone with the token gets full dev-user access. Same header in dev and prod, only the issuer differs.
44
44
45
+
`GET` on datasets, local-models, and predictions is open to anonymous callers for rows with `visibility="public"`. Owner-scoped lifecycle data (AOIs, trainings, feedback, notifications) and every write require Bearer auth.
46
+
45
47
| Name | Required | Default | Description |
46
48
|------|----------|---------|-------------|
47
49
|`AUTH_PROVIDER`| no |`hanko`| One of `hanko`, `dev`. |
0 commit comments