From c200cf787ca9b46dd623726ab0ab56e865f101a6 Mon Sep 17 00:00:00 2001 From: "juancarlos.cavero" Date: Tue, 4 Aug 2026 00:07:29 +0200 Subject: [PATCH] =?UTF-8?q?fix(ci):=20collect=20every=20test=20again=20?= =?UTF-8?q?=E2=80=94=20gate-first=20imports=20+=20the=20deps=20tests=20act?= =?UTF-8?q?ually=20need?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI has been red since the July layout work: the workflow installed five light packages while the suite grew tests importing numpy, and the MCP endpoint tests added fastapi on top. Two fixes: - panel_layout/screencast_layout imported main (torch, mediapipe) BEFORE their ENABLED gate, so even the disabled path paid the heavy import. Move the import below the gate: the default path now imports nothing, which is what the gate was for. - The workflow installs exactly what the collected tests import at module level, still excluding the ML stack the lazy imports protect. List validated against a clean venv: 382 passed, 3 skipped, 0 import errors. --- .github/workflows/ci.yml | 16 ++++++++++------ panel_layout.py | 7 ++++--- screencast_layout.py | 7 ++++--- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee02e11..584b147 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,13 +13,17 @@ jobs: - uses: actions/setup-python@v5 with: python-version: "3.11" - # Tests only touch light modules (subtitles/hooks/translate/edit_builder - # and the cloud metering helpers), so we install just what they import - # instead of the full requirements.txt (faster-whisper/ultralytics/ - # mediapipe are too heavy for CI). sqlalchemy is needed because - # tests/test_metering_free_plan.py imports cloud.metering. + # Everything the collected tests import at module level, WITHOUT the + # heavy ML stack (torch/ultralytics/mediapipe/faster-whisper) — the + # pipeline modules import those lazily behind their feature gates, and + # the tests exercise the gated-off paths. numpy+opencv cover the layout + # modules, fastapi/boto3/PyJWT/python-multipart cover importing app.py + # for the MCP endpoint tests, google-genai covers gemini_worker. - name: Install test dependencies - run: pip install pytest pillow httpx pydantic sqlalchemy + run: > + pip install pytest pillow httpx pydantic sqlalchemy numpy + opencv-python-headless python-dotenv google-genai fastapi boto3 + PyJWT email-validator python-multipart - name: Run tests run: pytest tests/ -v diff --git a/panel_layout.py b/panel_layout.py index 2c23639..c04f286 100644 --- a/panel_layout.py +++ b/panel_layout.py @@ -218,11 +218,12 @@ def detect_panel_scenes(video_path, scenes, strategies, samples=None): same reason SPLIT does it: GENERAL already means "more than one face", and single-speaker material is most of the corpus and must not be touched. """ - import cv2 - import main as m - if not ENABLED: return {} + # Below the gate on purpose: main pulls torch/mediapipe, and the disabled + # path (the default, and what CI exercises) must not pay that import. + import cv2 + import main as m cap = cv2.VideoCapture(video_path) if not cap.isOpened(): diff --git a/screencast_layout.py b/screencast_layout.py index 19b17f9..ad7d2fa 100644 --- a/screencast_layout.py +++ b/screencast_layout.py @@ -245,11 +245,12 @@ def detect_screencast_scenes(video_path, scenes, strategies, ranges, samples=6): - WIDE is the blurred layout with side-cropping disabled, for content that fills the frame, or that has no presenter to stack. """ - import cv2 - import main as m - if not ENABLED or not ranges: return {} + # Below the gate on purpose: main pulls torch/mediapipe, and the disabled + # path (the default, and what CI exercises) must not pay that import. + import cv2 + import main as m cap = cv2.VideoCapture(video_path) if not cap.isOpened():