Skip to content

fix: HuggingFace I/O has no retry or graceful degradation on transient failures (429 / network errors) #1198

Description

@planetf1

Observed behaviour

Several CI runs are failing intermittently with errors like:

huggingface_hub.errors.LocalEntryNotFoundError: An error happened while trying to locate the files on the Hub and we cannot find the appropriate snapshot folder for the specified revision on the local disk. Please check your internet connection and try again.

The root cause is HuggingFace Hub returning HTTP 429 (rate limit). Because there is no retry logic or graceful degradation anywhere in the call stack, the 429 propagates as a hard error, causing test fixtures to error rather than skip and leaving production users with an unintelligible traceback.

The problem is not limited to a single call site — an audit of the codebase found it at every layer.

Affected call sites

Production code — no retry, raw error surfaces to user

File Line(s) Call Notes
mellea/backends/adapters/adapter.py 451 snapshot_download() Downloads adapter index/config
mellea/formatters/granite/intrinsics/util.py 179 snapshot_download() Downloads LoRA/aLoRA weights
mellea/backends/huggingface.py 298, 301 AutoModelForCausalLM.from_pretrained(), AutoTokenizer.from_pretrained() Called in LocalHFBackend.__init__ on cache miss
mellea/formatters/granite/base/util.py 113–115 from_pretrained() × 3 Downloads base model + aLoRA weights
mellea/formatters/granite/retrievers/util.py 47 urlretrieve() Downloads MTRAG corpus from GitHub

CLI — no retry; mid-upload 429 aborts the whole transfer

File Line(s) Call
cli/alora/upload.py 44, 52 create_repo(), upload_folder()
cli/alora/intrinsic_uploader.py 79, 109, 120 create_repo(), upload_folder(), upload_file()
cli/alora/commands.py 251, 252 create_repo(), upload_file()

Tests — module-scoped fixtures error rather than skip, taking down the entire module

File Description
test/stdlib/components/docs/test_richdocument.py:19–25 scope="module" fixture calls RichDocument.from_document_file(). Docling downloads HF layout/table models internally; a 429 errors all 4 dependent tests instead of skipping. Currently the main source of intermittent CI failures across multiple PRs.
test/stdlib/components/intrinsic/test_core.py, test_rag.py, test_guardian.py Module-scoped LocalHFBackend fixtures; no skip-on-download-error.
test/backends/test_huggingface.py, test_huggingface_tools.py, test_mellea_tool.py, test_tool_calls.py Same pattern.
test/cli/test_alora_train_integration.py 189, 206, 211 — real from_pretrained calls in integration test, no skip guard.

Expected behaviour

  • Production paths: a transient 429 or timeout should trigger a short retry with exponential backoff (3 attempts, ~2/4/8 s) before propagating the error.
  • Test fixtures: if the HF Hub is unreachable or rate-limiting, module-scoped fixtures should call pytest.skip(reason="HF unavailable — skipping", allow_module_level=True) rather than erroring. The skip pattern is already used for Ollama and Watsonx fixtures in this codebase; this brings HF-dependent fixtures in line.

Not in scope

Retry/resilience for OpenAI and Bedrock backends is already handled by the OpenAI SDK's default max_retries. Ollama server-probe fixtures already use try/except + pytest.skip. The test_intrinsics_formatters.py HfApi call already degrades gracefully.

Related

Activity

  1. added
    bug
    area/alora
    area/backends
    area/adapter-functions
    on Jun 4, 2026
  2. added a commit that references this issue on Jun 4, 2026
    058ced3
  3. self-assigned this
    on Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/adapter-functionsarea/aloraarea/backendsbugtesting

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions