SIGN IN SIGN UP

[conftest] Fix EROFS fallback for kernel downloads (correct interception point) (#47794)

* [conftest] fix EROFS fallback for kernel downloads via HfApi

The CI read-only cache fallback wrapped `huggingface_hub.hf_hub_download`
but missed `huggingface_hub.hf_api.hf_hub_download` — the module-level
name that `HfApi.hf_hub_download` resolves at call time. Third-party
libraries such as `kernels` call `api.hf_hub_download(...)` (HfApi
instance), so their downloads bypassed the EROFS retry entirely.

Patch that reference explicitly; `snapshot_download` is unaffected
because it imports `hf_hub_download` from `file_download.py` directly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* [conftest] fix EROFS fallback: patch file_download not hf_api

Previous attempt patched `hf_api.hf_hub_download` (module-level), but
`HfApi.hf_hub_download` uses a *local* import inside the method body:
  `from .file_download import hf_hub_download`
so `getattr(hf_api_mod, "hf_hub_download")` returns None, the condition
was False, and the patch was silently never applied.

The correct interception point is `file_download.hf_hub_download`:
local imports read `file_download.__dict__` at call time, so they pick
up the wrapped version. `_snapshot_download.py` uses a module-level
import frozen before conftest runs, so it is unaffected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
Y
Yih-Dar committed
20edc892545ecce73cdae33d40cfdbcbe1dde0ee
Parent: e91f7ef
Committed by GitHub <noreply@github.com> on 8/5/2026, 10:04:13 AM