feat(perception): qualify conservative static occupancy
This commit is contained in:
@@ -934,6 +934,13 @@ app.include_router(
|
||||
/ "m48"
|
||||
/ "small-static-passage-regression-results"
|
||||
),
|
||||
static_occupancy_result_root_provider=lambda: (
|
||||
REPOSITORY_ROOT
|
||||
/ ".runtime"
|
||||
/ "compute-experiments"
|
||||
/ "m48"
|
||||
/ "static-occupancy-qualification-results"
|
||||
),
|
||||
camera_frame_provider=(
|
||||
session_recorded_camera_frame_service.extract
|
||||
if session_recorded_camera_frame_service is not None
|
||||
|
||||
@@ -48,6 +48,11 @@ from k1link.laboratory.m48_small_static_regression import (
|
||||
M48SmallStaticRegressionResult,
|
||||
read_m48_small_static_passage_regression,
|
||||
)
|
||||
from k1link.laboratory.m48_static_occupancy_qualification import (
|
||||
M48StaticOccupancyQualificationError,
|
||||
M48StaticOccupancyQualificationResult,
|
||||
read_m48_static_occupancy_qualification,
|
||||
)
|
||||
from k1link.sessions import RecordedCameraPlaybackSource
|
||||
|
||||
_PACK_ID = re.compile(r"^m48-object-quality-pack-[a-f0-9]{64}$")
|
||||
@@ -57,6 +62,9 @@ _SMALL_STATIC_RESULT_ID = re.compile(
|
||||
r"^m48-small-static-passage-regression-[a-f0-9]{64}$"
|
||||
)
|
||||
_SMALL_STATIC_ANCHOR_ID = re.compile(r"^anchor-[a-f0-9]{24}$")
|
||||
_STATIC_OCCUPANCY_RESULT_ID = re.compile(
|
||||
r"^m48-static-occupancy-qualification-[a-f0-9]{64}$"
|
||||
)
|
||||
_M47_LAB_RESULT_ID = re.compile(r"^m47-reference-graph-lab-[a-f0-9]{64}$")
|
||||
_FAILURE_ID = re.compile(r"^m48-failure-[a-f0-9]{64}$")
|
||||
_REVIEW_SESSION_ID = re.compile(r"^m48-review-session-[a-f0-9]{64}$")
|
||||
@@ -93,6 +101,12 @@ _SMALL_STATIC_CASE_CATALOG_SCHEMA: Final = (
|
||||
_SMALL_STATIC_CASE_VIEW_SCHEMA: Final = (
|
||||
"missioncore.m48-small-static-passage-regression-case-view/v1"
|
||||
)
|
||||
_STATIC_OCCUPANCY_RESULT_VIEW_SCHEMA: Final = (
|
||||
"missioncore.m48-static-occupancy-qualification-result-view/v1"
|
||||
)
|
||||
_STATIC_OCCUPANCY_CASE_CATALOG_SCHEMA: Final = (
|
||||
"missioncore.m48-static-occupancy-case-catalog/v1"
|
||||
)
|
||||
_FAILURE_ATLAS_VIEW_SCHEMA: Final = "missioncore.m48-object-quality-failure-atlas-view/v1"
|
||||
_FAILURE_CASE_VIEW_SCHEMA: Final = "missioncore.m48-object-quality-failure-case-view/v1"
|
||||
_REVIEW_CAPABILITY_HEADER: Final = "X-M48-Review-Capability"
|
||||
@@ -438,6 +452,7 @@ def build_m48_object_quality_router(
|
||||
truth_root_provider: RootProvider = lambda: None,
|
||||
result_root_provider: RootProvider = lambda: None,
|
||||
small_static_result_root_provider: RootProvider = lambda: None,
|
||||
static_occupancy_result_root_provider: RootProvider = lambda: None,
|
||||
camera_frame_provider: CameraFrameProvider | None = None,
|
||||
camera_playback_provider: CameraPlaybackProvider | None = None,
|
||||
spatial_evidence_provider: SpatialEvidenceProvider | None = None,
|
||||
@@ -1593,6 +1608,56 @@ def build_m48_object_quality_router(
|
||||
"access": "assisted-development-regression-case-read-only",
|
||||
}
|
||||
|
||||
@router.get("/regressions/static-occupancy/{result_id}")
|
||||
def get_static_occupancy_qualification(
|
||||
result_id: Annotated[str, ApiPath(pattern=_STATIC_OCCUPANCY_RESULT_ID.pattern)],
|
||||
) -> dict[str, object]:
|
||||
result = _resolve_static_occupancy_result(
|
||||
static_occupancy_result_root_provider,
|
||||
result_id,
|
||||
)
|
||||
source = _object(result.report.get("source"), "M4.8R2 source")
|
||||
configuration = _object(
|
||||
result.report.get("configuration"),
|
||||
"M4.8R2 configuration",
|
||||
)
|
||||
return {
|
||||
"schema_version": _STATIC_OCCUPANCY_RESULT_VIEW_SCHEMA,
|
||||
"result_id": result.result_id,
|
||||
"created_at_utc": result.manifest.get("created_at_utc"),
|
||||
"reference_graph_lab_result_id": source.get("m47_lab_result_id"),
|
||||
"small_static_result_id": source.get("small_static_result_id"),
|
||||
"run_label": configuration.get("run_label"),
|
||||
"pipeline_id": configuration.get("pipeline_id"),
|
||||
"experiment_id": configuration.get("experiment_id"),
|
||||
"accepted": result.manifest.get("accepted"),
|
||||
"metrics": copy.deepcopy(result.report.get("metrics")),
|
||||
"gates": copy.deepcopy(result.report.get("gates")),
|
||||
"decision": copy.deepcopy(result.report.get("decision")),
|
||||
"ground_truth": False,
|
||||
"independent_truth": False,
|
||||
"authority": dict(_AUTHORITY),
|
||||
"access": "static-occupancy-qualification-read-only",
|
||||
}
|
||||
|
||||
@router.get("/regressions/static-occupancy/{result_id}/cases")
|
||||
def get_static_occupancy_qualification_cases(
|
||||
result_id: Annotated[str, ApiPath(pattern=_STATIC_OCCUPANCY_RESULT_ID.pattern)],
|
||||
) -> dict[str, object]:
|
||||
result = _resolve_static_occupancy_result(
|
||||
static_occupancy_result_root_provider,
|
||||
result_id,
|
||||
)
|
||||
return {
|
||||
"schema_version": _STATIC_OCCUPANCY_CASE_CATALOG_SCHEMA,
|
||||
"result_id": result.result_id,
|
||||
"cases": copy.deepcopy(result.cases),
|
||||
"case_count": len(result.cases),
|
||||
"ground_truth": False,
|
||||
"authority": dict(_AUTHORITY),
|
||||
"access": "static-occupancy-qualification-read-only",
|
||||
}
|
||||
|
||||
return router
|
||||
|
||||
|
||||
@@ -1691,6 +1756,27 @@ def _resolve_small_static_result(
|
||||
) from None
|
||||
|
||||
|
||||
def _resolve_static_occupancy_result(
|
||||
provider: RootProvider,
|
||||
result_id: str,
|
||||
) -> M48StaticOccupancyQualificationResult:
|
||||
if _STATIC_OCCUPANCY_RESULT_ID.fullmatch(result_id) is None:
|
||||
raise HTTPException(status_code=404, detail="M4.8R2 result was not found")
|
||||
root = _configured_root(provider)
|
||||
if root is None:
|
||||
raise HTTPException(status_code=404, detail="M4.8R2 result was not found")
|
||||
path = root / result_id
|
||||
if path.is_symlink() or not path.is_dir():
|
||||
raise HTTPException(status_code=404, detail="M4.8R2 result was not found")
|
||||
try:
|
||||
resolved = path.resolve(strict=True)
|
||||
if resolved.parent != root:
|
||||
raise OSError("M4.8R2 result escaped root")
|
||||
return read_m48_static_occupancy_qualification(resolved)
|
||||
except (M48StaticOccupancyQualificationError, OSError, TypeError, ValueError):
|
||||
raise HTTPException(status_code=404, detail="M4.8R2 result was not found") from None
|
||||
|
||||
|
||||
def _result_sources(
|
||||
result: M48ObjectQualityResult,
|
||||
*,
|
||||
|
||||
Reference in New Issue
Block a user