mirror of https://github.com/razor-ai/soup.git
ci: warm HF Hub cache before tests to fix tiny-model 429 flake
The test job loads sshleifer/tiny-gpt2 and hf-internal-testing/tiny-random-gpt2
from HF Hub. Under transient HF rate-limiting (429) a single matrix cell would
fail the model download (test_v07111.py::TestMiniLLM::test_anchor_term_with_file)
and drop coverage under the 77% gate — observed reding 3 commits today (~2/7
cells per run).
Add a best-effort pre-test step that snapshot_downloads both tiny models with
6 retries + backoff so the tests read from the warmed cache (verified locally:
the test passes with HF_HUB_OFFLINE=1 once the cache is warm). The step never
fails the job — it emits a :⚠️: if warming can't complete.
CI-only; no version bump.
This commit is contained in:
parent
a66e4b9ebe
commit
b46f22433c
|
|
@ -56,6 +56,30 @@ jobs:
|
|||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install dependencies
|
||||
run: pip install -e ".[dev]"
|
||||
- name: Warm HF Hub cache (tiny test models)
|
||||
# Pre-download the tiny models the unit tests load, with retries, so a
|
||||
# transient HF Hub 429 (Too Many Requests) on a single matrix cell does
|
||||
# not red the whole run. Observed: ~5/7 cells download fine and ~2/7 hit
|
||||
# a 429 — a retry loop reliably populates the cache so the tests then
|
||||
# read from disk (no network). Never fails the job: if warming can't
|
||||
# complete it emits a ::warning:: and lets the test step run as before.
|
||||
shell: python
|
||||
run: |
|
||||
import time
|
||||
from huggingface_hub import snapshot_download
|
||||
|
||||
models = ["sshleifer/tiny-gpt2", "hf-internal-testing/tiny-random-gpt2"]
|
||||
for repo in models:
|
||||
for attempt in range(1, 7):
|
||||
try:
|
||||
snapshot_download(repo)
|
||||
print(f"warmed {repo}")
|
||||
break
|
||||
except Exception as exc: # noqa: BLE001 — best effort, never fail the job
|
||||
print(f"attempt {attempt}/6 for {repo} failed: {type(exc).__name__}: {exc}")
|
||||
time.sleep(min(5 * attempt, 30))
|
||||
else:
|
||||
print(f"::warning title=HF cache::could not warm {repo} after 6 attempts")
|
||||
- name: Run unit tests with coverage
|
||||
run: pytest tests/ -v --tb=short --junitxml=report.xml --cov=soup_cli --cov-report=xml:coverage.xml --cov-report=term-missing:skip-covered
|
||||
- name: Upload coverage to Codecov
|
||||
|
|
|
|||
Loading…
Reference in New Issue