Spaces:
Sleeping
Sleeping
Download backend/app/api/runs.py from Adisri99/ClusterBuster-API: direct link, hf CLI and curl.
- Browser
- Download file 881 Bytes
-
https://huggingface.co/spaces/Adisri99/ClusterBuster-API/resolve/main/backend/app/api/runs.py
- Command line
-
hf download hf://spaces/Adisri99/ClusterBuster-API/backend/app/api/runs.py
-
curl -L -o runs.py https://huggingface.co/spaces/Adisri99/ClusterBuster-API/resolve/main/backend/app/api/runs.py
881 Bytes
| import json | |
| from fastapi import APIRouter, Depends | |
| from sqlalchemy.orm import Session | |
| from backend.app.db import get_db | |
| from backend.app.repositories.experiment_repo import list_experiments | |
| router = APIRouter(tags=["runs"]) | |
| def get_runs(db: Session = Depends(get_db)): | |
| experiments = list_experiments(db) | |
| return { | |
| "runs": [ | |
| { | |
| "experiment_id": exp.id, | |
| "dataset_id": exp.dataset_id, | |
| "algorithm": exp.algorithm, | |
| "status": exp.status, | |
| "metrics": json.loads(exp.metrics_json) if exp.metrics_json else {}, | |
| "summary": json.loads(exp.summary_json) if exp.summary_json else {}, | |
| "runtime_ms": exp.runtime_ms, | |
| "error_message": exp.error_message, | |
| } | |
| for exp in experiments | |
| ] | |
| } | |