Download app/api/dashboard_data.py from LeonardoMdSA/ML-Inference-Service-with-Drift-Detection: direct link, hf CLI and curl.
- Browser
- Download file 801 Bytes
-
https://huggingface.co/spaces/LeonardoMdSA/ML-Inference-Service-with-Drift-Detection/resolve/main/app/api/dashboard_data.py
- Command line
-
hf download hf://spaces/LeonardoMdSA/ML-Inference-Service-with-Drift-Detection/app/api/dashboard_data.py
-
curl -L -o dashboard_data.py https://huggingface.co/spaces/LeonardoMdSA/ML-Inference-Service-with-Drift-Detection/resolve/main/app/api/dashboard_data.py
801 Bytes
| # app/api/dashboard_data.py | |
| from fastapi import APIRouter | |
| from fastapi.responses import JSONResponse | |
| import json | |
| import os | |
| router = APIRouter() | |
| DATA_FILE = "reports/evidently/drift_report.json" # we will write drift info here | |
| def get_dashboard_data(): | |
| """ | |
| Return the latest drift and prediction summary for the frontend dashboard. | |
| """ | |
| if os.path.exists(DATA_FILE): | |
| try: | |
| with open(DATA_FILE, "r") as f: | |
| data = json.load(f) | |
| return JSONResponse({"status": "ok", "data": data}) | |
| except Exception as e: | |
| return JSONResponse({"status": "error", "message": str(e)}, status_code=500) | |
| else: | |
| return JSONResponse({"status": "error", "message": "No data available"}, status_code=404) | |