fix(vision): CI has no numpy — the vehicle-stage tests need it without the alpr extra
Build & push images / images (push) Successful in 4m7s
Build & push images / images (push) Successful in 4m7s
CI syncs the service with `uv sync --frozen` (no extra), so test_vehicle.py's module-level numpy import broke collection in ci.yml and both build-images runs. numpy joins the dev group (the service imports it lazily); the one test that resizes with OpenCV skips when cv2 is absent. Reproduced locally in a CI-identical env: 13 passed, 1 skipped; ruff + mypy clean. Claude-Session: https://claude.ai/code/session_01FWncR69HgGPuei1dLrW3cU
This commit is contained in:
@@ -35,6 +35,9 @@ dev = [
|
||||
"pytest>=8.3",
|
||||
"httpx>=0.27", # FastAPI TestClient transport
|
||||
"mypy>=1.13",
|
||||
# The vehicle stage's post-processing tests run on synthetic tensors without the model
|
||||
# stack (CI syncs WITHOUT the alpr extra); the service itself imports numpy lazily.
|
||||
"numpy>=1.26",
|
||||
]
|
||||
|
||||
[tool.ruff]
|
||||
|
||||
@@ -6,6 +6,7 @@ from __future__ import annotations
|
||||
import os
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from vision_service.schemas import BBox, VehicleResult
|
||||
@@ -82,6 +83,7 @@ def test_pick_prefers_the_box_holding_the_plate_else_the_largest() -> None:
|
||||
|
||||
|
||||
def test_letterbox_keeps_aspect_and_pads_with_114() -> None:
|
||||
pytest.importorskip("cv2") # letterbox resizes with OpenCV — only present with the alpr extra
|
||||
frame = np.zeros((30, 60, 3), dtype=np.uint8)
|
||||
tensor, scale = letterbox(frame, 64)
|
||||
assert tensor.shape == (1, 3, 64, 64) and tensor.dtype == np.float32
|
||||
|
||||
Generated
+3
@@ -760,6 +760,8 @@ alpr = [
|
||||
dev = [
|
||||
{ name = "httpx" },
|
||||
{ name = "mypy" },
|
||||
{ name = "numpy", version = "2.2.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" },
|
||||
{ name = "numpy", version = "2.4.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" },
|
||||
{ name = "pytest" },
|
||||
{ name = "ruff" },
|
||||
]
|
||||
@@ -779,6 +781,7 @@ provides-extras = ["alpr"]
|
||||
dev = [
|
||||
{ name = "httpx", specifier = ">=0.27" },
|
||||
{ name = "mypy", specifier = ">=1.13" },
|
||||
{ name = "numpy", specifier = ">=1.26" },
|
||||
{ name = "pytest", specifier = ">=8.3" },
|
||||
{ name = "ruff", specifier = ">=0.8" },
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user