-
Notifications
You must be signed in to change notification settings - Fork 559
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
Always send the cached token when user is logged in #1064
Conversation
The documentation is not available anymore as the PR was closed or merged. |
Codecov ReportBase: 84.20% // Head: 84.16% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1064 +/- ##
==========================================
- Coverage 84.20% 84.16% -0.04%
==========================================
Files 38 40 +2
Lines 4121 4087 -34
==========================================
- Hits 3470 3440 -30
+ Misses 651 647 -4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Cool ! I guess |
@lhoestq Yes ! Best would be to handle all http calls in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very clean PR, thanks a lot for doing this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! The resulting use of build_hf_headers
is nice, much cleaner this way.
Thanks for working on it!
Co-authored-by: Omar Sanseviero <osanseviero@gmail.com>
Thanks @julien-c @LysandreJik @osanseviero for the reviews and comments. I made all the requested changes. |
TLDR; this works with this PR:
(cc @julien-c @osanseviero @LysandreJik @apolinario @patrickvonplaten @Pierrci)
Fix #926.
(related to this discussion (internal link), this discussion and this discussion as well (internal link))
The goal is to have a centralized way to handle tokens in
huggingface_hub
(and downstream libraries) that causes as low friction as possible for the users.The idea here is to keep the rule "if token is not explicitly set and is not required then do not pass it in header so that the user is cannot be tracked on public repos". This PR aims to solve that by making a HEAD call to the Hub (without auth) to check if a repo is public or private. In case of a private repo, the token is then automatically sent to the Hub in all subsequent calls (the "private" property of a repo is cached).EDIT: strategy has been revisited
The problem that has been formulated is that if a user wants to download files from a gated/private repos, they currently need to pass
use_auth_token=True
even though the user is logged in. This PR solves that by always sending the cached token if the user is logged in. This is a big change compared to the previous rule that was "don't send the token if not explicitly needed". Hope is to reduce as much friction as possible.This PR and the
build_hf_headers
helper aims also to harmonize how tokens are handled and validated across the platform.Examples:
(note: this PR also gets rid of the
datasets
dependency in the tests but that kinda unrelated. I got an issue with it that I reported in this PR)(edit: once that's reviewed and merged, implementing #1018 should be straightforward)