Skip to content

Fix huggingface_hub imports for compatibility with newer versions#325

Merged
entrpn merged 1 commit intoAI-Hypercomputer:mainfrom
rxu183:richard/hf_hub_download
Feb 5, 2026
Merged

Fix huggingface_hub imports for compatibility with newer versions#325
entrpn merged 1 commit intoAI-Hypercomputer:mainfrom
rxu183:richard/hf_hub_download

Conversation

@rxu183
Copy link
Contributor

@rxu183 rxu183 commented Feb 4, 2026

Changes:

  • Fixes cached_download deprecated in huggingface_hub 26.0 #124
  • Replaced cached_download with urllib.request on community pipeline logic (let me know if there's a better solution, this was just a simple thing I could think of), and removed associated version checking logic that was no longer needed.
  • Replaced HfFolder.get_token with get_token (import error on HfFolder)
  • Replaced deprecated use_auth_token parameter with token in hf_hub_download calls
  • Replaced hf_cache_home with HF_HOME in constants.py
Relevant HF code for HF_HOME
https://github.com/huggingface/huggingface_hub/commit/a1b90fa3c445a9be4438a259f1e4a25ec79db66a
(v0.20.0)
HF_HOME = os.path.expanduser(
    os.getenv(
        "HF_HOME",
        os.path.join(os.getenv("XDG_CACHE_HOME", default_home), "huggingface"),
    )
)
hf_cache_home = HF_HOME  # for backward compatibility. TODO: remove this in 1.0.0

Should be compatible with requirement of hugging_face_hub >= 0.30.2, tested on oldest and newest versions.
Previously, was getting errors on newer versions of hugging_face_hub.

Testing:

  • Tested on Google Colab v5e1
Logs/Setup
import os
!git clone https://github.com/rxu183/maxdiffusion.git
!git checkout richard/hf_hub_download
os.chdir('/content/maxdiffusion')
!pip install -r requirements.txt
!pip install .
!pip install huggingface_hub==0.30.2 # comment out for new version test
from maxdiffusion.utils.dynamic_modules_utils import get_cached_module_file
# Success Test
result = get_cached_module_file("clip_guided_stable_diffusion", "clip_guided_stable_diffusion.py")
print(f"Resolved to: {result}", flush=True)

# Failure Test
try:
    get_cached_module_file("fake_input", "xyz.py")
except EnvironmentError as e:
    print(f"{e}")

............ pip setup logs ............

Resolved to: diffusers_modules/git/clip_guided_stable_diffusion.py
Could not locate the xyz.py inside fake_input.
Failed to download community pipeline from https://raw.githubusercontent.com/huggingface/diffusers/v0.22.0/examples/community/fake_input.py. Please check if the url is correct.

@rxu183
Copy link
Contributor Author

rxu183 commented Feb 5, 2026

Hi Juan! I don't think gemini-review works unfortunately... I asked gemini about the github actions/workflow code, and it said that because I'm on an external fork, to avoid revealing secrets/API keys there's a rule to instantly skip gemini-review. It mentioned potentially pulling the branch in and then creating the PR yourself and then using the gemini-label as a workaround, though.

@entrpn
Copy link
Collaborator

entrpn commented Feb 5, 2026

All good, I went ahead and reviewed it and approved it. Thanks again!

@entrpn entrpn merged commit 5d16f16 into AI-Hypercomputer:main Feb 5, 2026
10 checks passed
@rxu183 rxu183 deleted the richard/hf_hub_download branch February 5, 2026 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cached_download deprecated in huggingface_hub 26.0

2 participants