Spaces:
Runtime error
Runtime error
Update app/api/runs.py
Browse files- app/api/runs.py +9 -5
app/api/runs.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from fastapi import APIRouter, BackgroundTasks
|
| 2 |
from app.services.storage import (
|
| 3 |
create_run,
|
| 4 |
get_run,
|
|
@@ -10,14 +10,18 @@ from app.services.beeline_runner import execute_run
|
|
| 10 |
|
| 11 |
router = APIRouter(prefix="/runs", tags=["Runs"])
|
| 12 |
|
| 13 |
-
|
| 14 |
@router.post("/")
|
| 15 |
def start_run(payload: dict, background: BackgroundTasks):
|
| 16 |
-
dataset_id = payload
|
| 17 |
-
algorithms = payload
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
if not algorithms:
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
algorithm = algorithms[0]
|
| 23 |
params = payload.get("params", {})
|
|
|
|
| 1 |
+
from fastapi import APIRouter, BackgroundTasks, HTTPException
|
| 2 |
from app.services.storage import (
|
| 3 |
create_run,
|
| 4 |
get_run,
|
|
|
|
| 10 |
|
| 11 |
router = APIRouter(prefix="/runs", tags=["Runs"])
|
| 12 |
|
|
|
|
| 13 |
@router.post("/")
|
| 14 |
def start_run(payload: dict, background: BackgroundTasks):
|
| 15 |
+
dataset_id = payload.get("dataset_id")
|
| 16 |
+
algorithms = payload.get("algorithms", [])
|
| 17 |
+
|
| 18 |
+
if not dataset_id:
|
| 19 |
+
raise HTTPException(status_code=422, detail="dataset_id is required")
|
| 20 |
+
return {"error": "No Dataset selected"}
|
| 21 |
|
| 22 |
if not algorithms:
|
| 23 |
+
raise HTTPException(status_code=422, detail="algorithms must be a non-empty array")
|
| 24 |
+
return {"error": "No Algorithm selected"}
|
| 25 |
|
| 26 |
algorithm = algorithms[0]
|
| 27 |
params = payload.get("params", {})
|