Skip to content

Commit 1f25d7f

Browse files
fix(hooks): stop the pre-push gauntlet hanging on model-download tests
The hook ran the full suite, which includes tests that drive the real docling pipeline and reranker. On a cold cache those download HF models (figure classifier, CrossEncoder), stalling `git push` for minutes with no visible output (the hook redirects pytest to a logfile). Mark those tests slow and run the fast subset in the hook (-m "not slow and not integration"); slow and integration still run in full in CI.
1 parent 80162fe commit 1f25d7f

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

.githooks/pre-push

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ PYTEST="$VENV_DIR/pytest"
3939

4040
printf "pre-push gauntlet:\n"
4141

42-
# Match the gates in .github/workflows/ci.yml exactly — running a narrower
43-
# subset means CI fails at the runner level on things the hook should have
44-
# caught (which is exactly what we're trying to prevent).
42+
# Lint, format, and types match .github/workflows/ci.yml exactly. The pytest
43+
# step runs only the fast subset; slow / integration tests pull model downloads
44+
# or docker-compose services and run in CI, not in this quick local gate.
4545

4646
# 1. Ruff lint
4747
if "$RUFF" check . >/dev/null; then
@@ -67,8 +67,8 @@ else
6767
fail "mypy strict"
6868
fi
6969

70-
# 4. Full pytest
71-
if "$PYTEST" tests/ -q --no-header >/tmp/pre-push-pytest.log 2>&1; then
70+
# 4. Fast pytest subset (slow + integration run in CI, not here)
71+
if "$PYTEST" tests/ -m "not slow and not integration" -q --no-header >/tmp/pre-push-pytest.log 2>&1; then
7272
pass "pytest ($(grep -oE '[0-9]+ passed' /tmp/pre-push-pytest.log | head -1))"
7373
else
7474
cat /tmp/pre-push-pytest.log

tests/unit/test_ingestion_pipeline.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing import Any
77

88
import fitz
9+
import pytest
910

1011
from src.ingestion.pipeline import IngestedPaper, ingest_paper
1112
from src.llm.protocol import ChatResponse, Message
@@ -14,6 +15,10 @@
1415
from src.types import Paper
1516
from tests.fakes import FakeEmbedder
1617

18+
# Real docling conversion downloads/loads a HF figure-classifier model — too
19+
# heavy for the fast pre-push gauntlet. Runs in CI, skipped by the local hook.
20+
pytestmark = pytest.mark.slow
21+
1722

1823
class _StubLLM:
1924
def __init__(self, text: str = "blurb") -> None:

tests/unit/test_main_wiring.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ async def test_wire_populates_pipeline_retriever_from_qdrant() -> None:
148148

149149

150150
@pytest.mark.asyncio
151+
@pytest.mark.slow # real wiring reranks → CrossEncoder model download; CI only
151152
async def test_wired_retriever_can_serve_a_query() -> None:
152153
"""Sanity check beyond construction: the wired retriever actually returns
153154
chunks (so set_retriever didn't silently register a broken instance)."""
@@ -347,6 +348,7 @@ async def test_multimodal_on_without_visual_leg_degrades_to_text() -> None:
347348

348349

349350
@pytest.mark.asyncio
351+
@pytest.mark.slow # real wiring reranks → CrossEncoder model download; CI only
350352
async def test_multimodal_routing_actually_dispatches_figure_to_hybrid(
351353
monkeypatch: pytest.MonkeyPatch,
352354
) -> None:

0 commit comments

Comments
 (0)