feat: add FastAPI model/load endpoint and all Next.js proxy routes (tasks 2-4)

This commit is contained in:
Marko Djordjevic 2026-02-17 18:47:04 +01:00
parent b8e649e333
commit 2a02669222
29 changed files with 1110 additions and 780 deletions

View file

@ -7,25 +7,25 @@
## 2. FastAPI Training Endpoints
- [ ] 2.1 Add `POST /training/start` endpoint that launches training in a background thread, returns `{run_id, status: "running"}`, and rejects concurrent runs with HTTP 409
- [ ] 2.2 Add `GET /training/runs` endpoint returning training run history from the `training_runs` table, sorted by date descending
- [ ] 2.3 Add `GET /training/dataset-info` endpoint returning labeled dataset file path, existence, size, and row count
- [ ] 2.4 Add background training thread management: track active run, update DB status on completion/failure
- [x] 2.1 Add `POST /training/start` endpoint that launches training in a background thread, returns `{run_id, status: "running"}`, and rejects concurrent runs with HTTP 409
- [x] 2.2 Add `GET /training/runs` endpoint returning training run history from the `training_runs` table, sorted by date descending
- [x] 2.3 Add `GET /training/dataset-info` endpoint returning labeled dataset file path, existence, size, and row count
- [x] 2.4 Add background training thread management: track active run, update DB status on completion/failure
## 3. FastAPI Model Loading Endpoint
- [ ] 3.1 Add `POST /model/load` endpoint accepting `{run_id}`, looking up the training run, loading the model artifact, and replacing the active model in `AppState`
- [ ] 3.2 Add thread-safe model swap with locking to prevent conflicts with in-flight prediction requests
- [x] 3.1 Add `POST /model/load` endpoint accepting `{run_id}`, looking up the training run, loading the model artifact, and replacing the active model in `AppState`
- [x] 3.2 Add thread-safe model swap with locking to prevent conflicts with in-flight prediction requests
## 4. Next.js Proxy Routes
- [ ] 4.1 Add `GET /api/patterns/available` proxy route
- [ ] 4.2 Add `POST /api/patterns/detect` proxy route
- [ ] 4.3 Add `POST /api/training/start` proxy route
- [ ] 4.4 Add `GET /api/training/runs` proxy route
- [ ] 4.5 Add `GET /api/training/dataset-info` proxy route
- [ ] 4.6 Add `POST /api/model/load` proxy route
- [ ] 4.7 Extend `DELETE /api/span-annotations` to support `source` and `label` query parameters for bulk deletion
- [x] 4.1 Add `GET /api/patterns/available` proxy route
- [x] 4.2 Add `POST /api/patterns/detect` proxy route
- [x] 4.3 Add `POST /api/training/start` proxy route
- [x] 4.4 Add `GET /api/training/runs` proxy route
- [x] 4.5 Add `GET /api/training/dataset-info` proxy route
- [x] 4.6 Add `POST /api/model/load` proxy route
- [x] 4.7 Extend `DELETE /api/span-annotations` to support `source` and `label` query parameters for bulk deletion
## 5. TA-Lib Pattern UI Panel