Harden YOLO compatibility preflight
GeoIntel CI / docs-smoke (push) Has been cancelled
GeoIntel CI / contract-smoke (push) Has been cancelled

This commit is contained in:
Codex
2026-06-17 01:59:00 +02:00
parent 794f1cd51e
commit 3f1a686bef
11 changed files with 170 additions and 3 deletions
+25 -1
View File
@@ -17,6 +17,7 @@ class YoloPreflightService:
tile_manifest_path: str | None = None,
yolo_adapter_class: Type[YoloDetectionAdapter] = YoloDetectionAdapter,
assume_dependencies: bool = False,
check_model_load: bool = False,
) -> dict[str, Any]:
resolved_settings = settings or get_settings()
result: dict[str, Any] = {
@@ -30,6 +31,8 @@ class YoloPreflightService:
"dependencies_available": None,
"model_path_set": None,
"model_file_exists": None,
"model_load_requested": check_model_load,
"model_load_ok": None,
"manifest_path_set": None,
"manifest_valid": None,
"tile_paths_exist": None,
@@ -64,6 +67,24 @@ class YoloPreflightService:
result["message"] = "YOLO_MODEL_PATH does not point to an existing local model file."
return result
if check_model_load:
try:
yolo_adapter_class(resolved_settings).load_model(model_path)
except AppError as exc:
result["status"] = "model_load_failed"
result["message"] = exc.message
result["error_code"] = exc.code
result["checks"]["model_load_ok"] = False
return result
except Exception as exc:
result["status"] = "model_load_failed"
result["message"] = "Configured YOLO model could not be loaded during compatibility smoke."
result["error_code"] = "DETECTION_MODEL_LOAD_FAILED"
result["details"] = {"error": str(exc)}
result["checks"]["model_load_ok"] = False
return result
result["checks"]["model_load_ok"] = True
result["checks"]["manifest_path_set"] = bool(tile_manifest_path)
if not tile_manifest_path:
result["status"] = "manifest_unavailable"
@@ -89,5 +110,8 @@ class YoloPreflightService:
result["checks"]["tile_limit_ok"] = len(tile_paths) <= resolved_settings.yolo_max_tiles
result["tile_count"] = len(tile_paths)
result["status"] = "ready"
result["message"] = "Configured YOLO preflight passed. No model was loaded and no inference was run."
if check_model_load:
result["message"] = "Configured YOLO preflight passed. Local model load smoke passed and no inference was run."
else:
result["message"] = "Configured YOLO preflight passed. No model was loaded and no inference was run."
return result