Expand Seg task coverage and coverage dashboard

This commit is contained in:
2026-06-30 12:54:25 +08:00
parent dd7b7384ec
commit 7a43303f15
18 changed files with 849 additions and 28 deletions

View File

@@ -10,6 +10,7 @@ from pathlib import Path
from ..catalog import get_catalog
from ..config import settings
from ..coverage import get_coverage_report
from ..modules.system.service import get_conda_envs, get_gpus
from ..modules.weights.service import load_manifest
@@ -28,10 +29,10 @@ def _run(command: list[str], cwd: Path | None = None, timeout: int = 60) -> dict
def _fetch(url: str, timeout: int = 5) -> dict:
try:
with urllib.request.urlopen(url, timeout=timeout) as response:
body = response.read(20000).decode("utf-8", errors="replace")
body = response.read(200000).decode("utf-8", errors="replace")
return {"url": url, "status": response.status, "body": body, "passed": 200 <= response.status < 300}
except urllib.error.HTTPError as exc:
body = exc.read(20000).decode("utf-8", errors="replace")
body = exc.read(200000).decode("utf-8", errors="replace")
return {"url": url, "status": exc.code, "body": body, "passed": False}
except Exception as exc:
return {"url": url, "error": str(exc), "passed": False}
@@ -42,9 +43,14 @@ def validate_project(run_build: bool = False) -> dict:
checks = []
catalog = get_catalog()
manifest = load_manifest()
coverage = get_coverage_report()
checks.append({"name": "catalog_has_yolo_heatmap", "passed": "yolo.heatmap" in catalog["task_types"]})
checks.append({"name": "catalog_has_mmseg_31_algs", "passed": len(catalog["mmseg_algorithms"]) >= 31})
checks.append({"name": "catalog_has_visual_tools", "passed": "visual.yolo11_heatmap_v2" in catalog["task_types"] and "visual.fps" in catalog["task_types"]})
checks.append({"name": "catalog_has_yolo_dataset_tools", "passed": "dataset.yolo_txt_sort" in catalog["task_types"] and "dataset.yolo_convert_png" in catalog["task_types"]})
checks.append({"name": "task_buildability", "passed": coverage["task_build_passed"], "detail": coverage["task_build_checks"]})
checks.append({"name": "script_coverage_user_facing", "passed": not coverage["unmapped_user_scripts"], "detail": coverage})
checks.append({"name": "weights_manifest_present", "passed": manifest.get("count", 0) >= 1})
checks.append({"name": "gpus_query", "passed": bool(get_gpus().get("available"))})
env_names = [item["name"] for item in get_conda_envs().get("envs", [])]
@@ -72,9 +78,11 @@ def validate_project(run_build: bool = False) -> dict:
frontend_url = os.getenv("SEG_VALIDATE_FRONTEND_URL", "http://127.0.0.1:5173")
health = _fetch(f"{backend_url}/api/health")
datasets = _fetch(f"{backend_url}/api/datasets")
live_coverage = _fetch(f"{backend_url}/api/coverage")
frontend = _fetch(frontend_url)
checks.append({"name": "live_backend_health", "passed": health["passed"] and '"ok":true' in health.get("body", "").replace(" ", ""), "detail": health})
checks.append({"name": "live_dataset_api", "passed": datasets["passed"] and datasets.get("body", "").lstrip().startswith("["), "detail": datasets})
checks.append({"name": "live_coverage_api", "passed": live_coverage["passed"] and '"task_build_passed":true' in live_coverage.get("body", "").replace(" ", ""), "detail": live_coverage})
checks.append({"name": "live_frontend_index", "passed": frontend["passed"] and "Seg Data Server" in frontend.get("body", ""), "detail": frontend})
if run_build: