(payload: TrainRequest)
| 1289 | |
| 1290 | @app.post("/api/train") |
| 1291 | def api_train(payload: TrainRequest) -> dict[str, Any]: |
| 1292 | script, env_overrides = _train_script_and_env(payload) |
| 1293 | raw_output = "".join( |
| 1294 | _stream_python_script( |
| 1295 | script, |
| 1296 | "Training completed.", |
| 1297 | "Training failed.", |
| 1298 | env_overrides=env_overrides, |
| 1299 | ) |
| 1300 | ) |
| 1301 | output, status = _split_stream_result(raw_output) |
| 1302 | if not status or status.get("ok") is False: |
| 1303 | raise HTTPException( |
| 1304 | status_code=500, |
| 1305 | detail={"message": (status or {}).get("message", "Training failed."), "output": output}, |
| 1306 | ) |
| 1307 | _invalidate_system_meta_cache() |
| 1308 | return {"ok": True, "message": status.get("message", "Training completed."), "output": output} |
| 1309 | |
| 1310 | |
| 1311 | @app.post("/api/train/stream") |
nothing calls this directly
no test coverage detected