diff --git a/cli/medperf/web_ui/datasets/routes.py b/cli/medperf/web_ui/datasets/routes.py index f1d0eb96a..e62f9fc2a 100644 --- a/cli/medperf/web_ui/datasets/routes.py +++ b/cli/medperf/web_ui/datasets/routes.py @@ -4,6 +4,7 @@ from typing import Dict, Optional import asyncio as aio +import yaml from fastapi import APIRouter, Form from fastapi.responses import HTMLResponse, JSONResponse, RedirectResponse, StreamingResponse from fastapi import Request @@ -226,7 +227,7 @@ def message_stream(): _drafts_operational: dict[int, DatasetSetOperational] = {} -@router.post("/operational_draft/generate") +@router.post("/operational_draft/generate", response_class=JSONResponse) async def set_operational(dataset_id: int): preparation = DatasetSetOperational(dataset_id, approved=False) _drafts_operational[dataset_id] = preparation @@ -235,18 +236,21 @@ async def set_operational(dataset_id: int): preparation.set_statistics() preparation.set_operational() body = preparation.todict() - statistics: str = dict_pretty_format(body) - return statistics + statistics = {k: v for (k, v) in body.items() if v is not None} + return {"yaml_statistics": yaml.dump(statistics)} -@router.post("/operational_draft/submit") +@router.post("/operational_draft/submit", response_class=JSONResponse) async def submit_operational(dataset_id: int): preparation = _drafts_operational[dataset_id] - preparation.approved = True - body = preparation.todict() - config.comms.update_dataset(preparation.dataset.id, body) - preparation.write() - return {"dataset_id": dataset_id} + try: + preparation.approved = True + body = preparation.todict() + config.comms.update_dataset(preparation.dataset.id, body) + preparation.write() + return {"dataset_id": dataset_id} + except Exception as e: + return JSONResponse({"error": str(e)}, 400) @router.get("/operational_draft/decline", response_class=JSONResponse) diff --git a/cli/medperf/web_ui/templates/dataset_detail.html b/cli/medperf/web_ui/templates/dataset_detail.html index 55b28414a..95297fb19 100644 --- a/cli/medperf/web_ui/templates/dataset_detail.html +++ b/cli/medperf/web_ui/templates/dataset_detail.html @@ -43,10 +43,26 @@
Details
- Prepare - {% if entity.is_ready() and entity.state == 'DEVELOPMENT' %} - - {% endif %} + + Prepare + + +
+ + + + + + +
@@ -59,6 +75,7 @@

Associated Benchmarks

+ -{% endblock %} \ No newline at end of file +{% endblock %}