refactor(lab): canonize selected evidence reports
This commit is contained in:
@@ -57,6 +57,7 @@ from k1link.compute.e40_perception_product_gate import (
|
||||
)
|
||||
from k1link.laboratory import LaboratoryEvidenceDefinition, LaboratoryEvidenceRegistry
|
||||
from k1link.web.l3_pointpillars_visual_api import latest_l3_visual_identity
|
||||
from k1link.web.l31_pointpillars_ravnoves_api import latest_l31_identity
|
||||
from k1link.web.l32_pointpillars_camera_review_api import latest_l32_identity
|
||||
from k1link.web.l33_camera_first_detector_review_api import latest_l33_identity
|
||||
|
||||
@@ -917,6 +918,15 @@ def build_advanced_laboratory_router(
|
||||
"access": "read-only",
|
||||
}
|
||||
)
|
||||
l31_identity = latest_l31_identity(l31_ravnoves_root_provider)
|
||||
if l31_identity is not None:
|
||||
items.append(
|
||||
{
|
||||
"work_id": "l31-pointpillars-ravnoves",
|
||||
**l31_identity,
|
||||
"access": "read-only",
|
||||
}
|
||||
)
|
||||
l32_identity = latest_l32_identity(l32_camera_review_root_provider)
|
||||
if l32_identity is not None:
|
||||
items.append(
|
||||
|
||||
+19
-1
@@ -23,7 +23,11 @@ from k1link.compute import (
|
||||
RecordedPerceptionOverlayMux,
|
||||
RecordedPerceptionOverlayStore,
|
||||
)
|
||||
from k1link.laboratory import LaboratoryEvidenceRegistry
|
||||
from k1link.laboratory import (
|
||||
LaboratoryEvidenceRegistry,
|
||||
LaboratoryEvidenceReportService,
|
||||
LaboratoryValueReviewRegistry,
|
||||
)
|
||||
from k1link.sessions import (
|
||||
MaterializedRecording,
|
||||
RecordedMediaInspector,
|
||||
@@ -104,6 +108,7 @@ from k1link.web.l34e_self_review_diagnostic_api import (
|
||||
)
|
||||
from k1link.web.l34f_adjudication_api import build_l34f_adjudication_router
|
||||
from k1link.web.laboratory_api import build_laboratory_router
|
||||
from k1link.web.laboratory_report_api import build_laboratory_report_router
|
||||
from k1link.web.lidar_api import build_lidar_router
|
||||
from k1link.web.lidar_local_surface_service import K1LocalSurfaceReadService
|
||||
from k1link.web.map_api import (
|
||||
@@ -137,6 +142,13 @@ INVALID_REQUEST_DETAIL = "Некорректные параметры запро
|
||||
LABORATORY_EVIDENCE_REGISTRY = LaboratoryEvidenceRegistry.from_directory(
|
||||
REPOSITORY_ROOT / "config" / "laboratories"
|
||||
)
|
||||
LABORATORY_VALUE_REVIEW_REGISTRY = LaboratoryValueReviewRegistry.from_file(
|
||||
REPOSITORY_ROOT / "config" / "laboratory-value-review.json"
|
||||
)
|
||||
LABORATORY_EVIDENCE_REPORTS = LaboratoryEvidenceReportService(
|
||||
LABORATORY_EVIDENCE_REGISTRY,
|
||||
lambda: REPOSITORY_ROOT / ".runtime" / "compute-experiments",
|
||||
)
|
||||
|
||||
|
||||
def _resolve_media_tool(name: str) -> Path | None:
|
||||
@@ -559,6 +571,12 @@ app.include_router(
|
||||
),
|
||||
)
|
||||
)
|
||||
app.include_router(
|
||||
build_laboratory_report_router(
|
||||
LABORATORY_VALUE_REVIEW_REGISTRY,
|
||||
LABORATORY_EVIDENCE_REPORTS,
|
||||
)
|
||||
)
|
||||
app.include_router(
|
||||
build_advanced_laboratory_router(
|
||||
evidence_registry=LABORATORY_EVIDENCE_REGISTRY,
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
from k1link.laboratory import (
|
||||
LaboratoryEvidenceReportError,
|
||||
LaboratoryEvidenceReportNotFound,
|
||||
LaboratoryEvidenceReportService,
|
||||
LaboratoryValueReviewRegistry,
|
||||
)
|
||||
|
||||
|
||||
def build_laboratory_report_router(
|
||||
registry: LaboratoryValueReviewRegistry,
|
||||
evidence_reports: LaboratoryEvidenceReportService | None = None,
|
||||
) -> APIRouter:
|
||||
router = APIRouter(prefix="/api/v1/laboratory", tags=["laboratory"])
|
||||
|
||||
@router.get("/value-review-index")
|
||||
def get_value_review_index() -> dict[str, object]:
|
||||
return registry.as_payload()
|
||||
|
||||
@router.get("/evidence-reports/{work_id}/{result_id}")
|
||||
def get_evidence_report(work_id: str, result_id: str) -> dict[str, object]:
|
||||
if evidence_reports is None:
|
||||
raise HTTPException(status_code=404, detail="LAB evidence report is unavailable")
|
||||
try:
|
||||
return evidence_reports.read(work_id, result_id)
|
||||
except LaboratoryEvidenceReportNotFound as exc:
|
||||
raise HTTPException(status_code=404, detail=str(exc)) from exc
|
||||
except LaboratoryEvidenceReportError as exc:
|
||||
raise HTTPException(status_code=422, detail=str(exc)) from exc
|
||||
|
||||
return router
|
||||
Reference in New Issue
Block a user