Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align HfFolder.get_token with huggingface_hub.get_token #1966

Merged
merged 2 commits into from
Jan 11, 2024

Conversation

Wauplin
Copy link
Contributor

@Wauplin Wauplin commented Jan 11, 2024

Since 0.20.x release, HfFolder is planned to be deprecated in favor of get_token, login and logout. Deprecation warning is not thrown yet as HfFolder is still a widely used feature.

@Narsil made me realize that the implementation of HfFolder.get_token and get_token are slightly different. In particular, if HF_TOKEN environment variable is not set and a token is saved locally, then HfFolder.get_token will return None (which is a bug) while get_token returns the saved token. In order to avoid any discrepancies, this PR replaces HfFolder.get_token implementation by a call to the more robust get_token.

Note: this change brokes test_token_in_old_path mocked test. I decided to remove it completely as it's quite old stuff (13 months old) and by now we can assume all users have switched from the old path to the new one. The feature is still present, I just removed the test.

@Wauplin Wauplin requested review from Narsil and LysandreJik January 11, 2024 11:13
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link

codecov bot commented Jan 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b79882a) 82.55% compared to head (e718525) 82.47%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1966      +/-   ##
==========================================
- Coverage   82.55%   82.47%   -0.09%     
==========================================
  Files          66       66              
  Lines        8159     8147      -12     
==========================================
- Hits         6736     6719      -17     
- Misses       1423     1428       +5     

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

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

That's simpler 😄

@Wauplin
Copy link
Contributor Author

Wauplin commented Jan 11, 2024

Thanks for the review @LysandreJik!

@Wauplin Wauplin merged commit cca2882 into main Jan 11, 2024
16 checks passed
@Wauplin Wauplin deleted the fix-inconsistency-get-token branch January 11, 2024 15:23
Copy link
Member

@julien-c julien-c left a comment

Choose a reason for hiding this comment

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

👍

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.

4 participants