Skip to content

Use get_token instead of deprecated HFFolder.get_token#654

Merged
wirthual merged 1 commit intomainfrom
rw/fix-new-huggingface-hub
Feb 5, 2026
Merged

Use get_token instead of deprecated HFFolder.get_token#654
wirthual merged 1 commit intomainfrom
rw/fix-new-huggingface-hub

Conversation

@wirthual
Copy link
Collaborator

@wirthual wirthual commented Feb 3, 2026

Only merge after updating huggingface_hub > 1

get token is already available in 0.34.1. See here

Tested locally:

poetry run python3 -c "import huggingface_hub;from huggingface_hub import get_token;print(huggingface_hub.__version__)"
0.34.4

Should address #653

@chatgpt-codex-connector
Copy link

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@gemini-code-assist
Copy link

Summary of Changes

Hello @wirthual, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request updates the infinity_emb library to maintain compatibility with huggingface_hub versions greater than 1. It modifies how authentication tokens are retrieved, adapting to the updated API of the huggingface_hub library. This is a crucial maintenance update to ensure the application continues to function correctly with modern dependency versions.

Highlights

  • Dependency Update: The huggingface_hub library import and usage have been updated to reflect changes in versions 1.x and above. Specifically, HfFolder().get_token() has been replaced with a direct call to huggingface_hub.get_token().
  • Compatibility Fix: This change ensures compatibility with newer versions of huggingface_hub, addressing potential breaking changes and resolving issue Incompatible with the latest transformers source code version #653.
Changelog
  • libs/infinity_emb/infinity_emb/transformer/utils_optimum.py
    • Replaced the import of HfFolder with get_token from huggingface_hub.
    • Updated the token retrieval logic from HfFolder().get_token() to get_token().
Activity
  • The pull request was created by wirthual.
  • No review comments or approvals have been recorded yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the code to be compatible with huggingface_hub version 1.0 and later. The changes correctly replace the deprecated HfFolder class and its get_token method with the recommended get_token function. This is done in infinity_emb/transformer/utils_optimum.py for fetching model files from the Hugging Face Hub. The changes are correct and necessary for the library to function with newer versions of its dependency. The implementation is straightforward and I see no issues with it.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 3, 2026

Greptile Overview

Greptile Summary

Migrates authentication token retrieval from deprecated HfFolder().get_token() to the new get_token() function, addressing compatibility with huggingface_hub>=1.0.0.

Key changes:

  • Import updated from HfFolder to get_token in utils_optimum.py:8
  • Token retrieval simplified from HfFolder().get_token() to get_token() in _list_all_repo_files() function

Important note:
The PR description mentions merging only after updating huggingface_hub > 1, but libs/infinity_emb/pyproject.toml still specifies huggingface_hub>=0.32.0. The dependency constraint should be updated to >=1.0.0 since get_token() was introduced in version 1.0.0. Without this update, users installing with huggingface_hub<1.0.0 will encounter import errors.

Confidence Score: 4/5

  • Safe to merge once the huggingface_hub dependency constraint is updated to >=1.0.0 in pyproject.toml
  • The code change is straightforward and correct - it properly migrates from the deprecated HfFolder API to the new get_token() function. The logic is functionally equivalent and maintains backward compatibility in behavior. However, the score is not 5 because the dependency constraint in pyproject.toml needs to be updated to prevent runtime errors with older versions of huggingface_hub.
  • No files in the changeset require special attention beyond the dependency update mentioned in the summary

Important Files Changed

Filename Overview
libs/infinity_emb/infinity_emb/transformer/utils_optimum.py Migrated from deprecated HfFolder().get_token() to get_token() for huggingface_hub v1+ compatibility

Sequence Diagram

sequenceDiagram
    participant App as Application
    participant Utils as utils_optimum._list_all_repo_files
    participant HF as huggingface_hub
    participant API as HfApi
    
    App->>Utils: _list_all_repo_files(model_name_or_path, use_auth_token)
    
    alt use_auth_token is bool
        Utils->>HF: get_token()
        Note over HF: Retrieves token from<br/>HF token storage
        HF-->>Utils: token or None
    else use_auth_token is string
        Note over Utils: Use provided token directly
    end
    
    Utils->>API: list_repo_files(model_name_or_path, revision, token)
    API-->>Utils: list of file paths
    Utils-->>App: List[Path]
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@wirthual wirthual changed the title add changes required for huggingface_hub >1 Use get_token instead of deprecated HFFolder.get_token Feb 3, 2026
@codecov-commenter
Copy link

codecov-commenter commented Feb 3, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.91%. Comparing base (c030718) to head (2ecb218).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #654   +/-   ##
=======================================
  Coverage   79.91%   79.91%           
=======================================
  Files          43       43           
  Lines        3495     3495           
=======================================
  Hits         2793     2793           
  Misses        702      702           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wirthual wirthual requested a review from michaelfeil February 4, 2026 20:18
@wirthual wirthual merged commit 12defd7 into main Feb 5, 2026
36 checks passed
@wirthual wirthual deleted the rw/fix-new-huggingface-hub branch February 5, 2026 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants