Add YOLO preflight runtime diagnostics
This commit is contained in:
@@ -54,7 +54,9 @@ def _manifest(tmp_path: Path, tile_count: int = 1) -> Path:
|
||||
return manifest_path
|
||||
|
||||
|
||||
def test_yolo_preflight_reports_disabled_without_loading_model(tmp_path: Path) -> None:
|
||||
def test_yolo_preflight_reports_disabled_without_loading_model(tmp_path: Path, monkeypatch) -> None:
|
||||
monkeypatch.setenv("YOLO_CONFIG_DIR", str(tmp_path / "ultralytics"))
|
||||
|
||||
result = YoloPreflightService.run(
|
||||
settings=Settings(yolo_enabled=False, yolo_model_path=str(tmp_path / "missing.pt")),
|
||||
tile_manifest_path=str(tmp_path / "missing-manifest.json"),
|
||||
@@ -66,6 +68,12 @@ def test_yolo_preflight_reports_disabled_without_loading_model(tmp_path: Path) -
|
||||
assert result["checks"]["dependencies_available"] is None
|
||||
assert result["checks"]["model_file_exists"] is None
|
||||
assert result["checks"]["manifest_valid"] is None
|
||||
assert result["runtime"]["dependencies_assumed"] is False
|
||||
assert result["runtime"]["model_directory"] == str(tmp_path)
|
||||
assert result["runtime"]["yolo_config_dir"] == str(tmp_path / "ultralytics")
|
||||
assert "torch_version" in result["runtime"]
|
||||
assert "ultralytics_version" in result["runtime"]
|
||||
assert "cuda_available" in result["runtime"]
|
||||
|
||||
|
||||
def test_yolo_preflight_distinguishes_missing_dependencies_from_missing_model(tmp_path: Path) -> None:
|
||||
@@ -102,6 +110,25 @@ def test_yolo_preflight_validates_model_and_manifest_without_importing_yolo(tmp_
|
||||
assert result["tile_count"] == 2
|
||||
assert result["will_download_models"] is False
|
||||
assert result["will_run_inference"] is False
|
||||
assert result["runtime"]["dependencies_assumed"] is False
|
||||
|
||||
|
||||
def test_yolo_preflight_marks_assumed_dependencies_in_runtime_details(tmp_path: Path) -> None:
|
||||
model_path = tmp_path / "model.pt"
|
||||
model_path.write_bytes(b"weights")
|
||||
manifest_path = _manifest(tmp_path, tile_count=1)
|
||||
|
||||
result = YoloPreflightService.run(
|
||||
settings=Settings(yolo_enabled=True, yolo_model_path=str(model_path), yolo_max_tiles=4),
|
||||
tile_manifest_path=str(manifest_path),
|
||||
yolo_adapter_class=MissingDependencyAdapter,
|
||||
assume_dependencies=True,
|
||||
)
|
||||
|
||||
assert result["status"] == "ready"
|
||||
assert result["checks"]["dependencies_available"] is True
|
||||
assert result["runtime"]["dependencies_assumed"] is True
|
||||
assert result["runtime"]["model_directory"] == str(tmp_path)
|
||||
|
||||
|
||||
def test_yolo_preflight_can_explicitly_smoke_load_local_model(tmp_path: Path) -> None:
|
||||
|
||||
Reference in New Issue
Block a user