From 0411b71c2dbe9d23225002268b964bc3c6513ae4 Mon Sep 17 00:00:00 2001 From: Julian Cuni Date: Mon, 7 Sep 2026 08:51:53 +0200 Subject: [PATCH] =?UTF-8?q?fix(vision):=20CI=20has=20no=20numpy=20?= =?UTF-8?q?=E2=80=94=20the=20vehicle-stage=20tests=20need=20it=20without?= =?UTF-8?q?=20the=20alpr=20extra?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- apps/vision/pyproject.toml | 3 +++ apps/vision/tests/test_vehicle.py | 2 ++ apps/vision/uv.lock | 3 +++ 3 files changed, 8 insertions(+) diff --git a/apps/vision/pyproject.toml b/apps/vision/pyproject.toml index 2baa5e9..c81ee1e 100644 --- a/apps/vision/pyproject.toml +++ b/apps/vision/pyproject.toml @@ -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] diff --git a/apps/vision/tests/test_vehicle.py b/apps/vision/tests/test_vehicle.py index 042f995..ee4e0e6 100644 --- a/apps/vision/tests/test_vehicle.py +++ b/apps/vision/tests/test_vehicle.py @@ -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 diff --git a/apps/vision/uv.lock b/apps/vision/uv.lock index 49e4613..40d373e 100644 --- a/apps/vision/uv.lock +++ b/apps/vision/uv.lock @@ -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" }, ]