-
Notifications
You must be signed in to change notification settings - Fork 632
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
hf_hub_download and cached_download should read the token by default #926
Comments
we've discussed it in the past and decided against it for privacy protection reasons (especially in the case when it's used from third party libraries – the hf.co server will "know" what models user A is downloading without explicitly opting-in) But maybe it does make sense to revisit this |
That's the thing, a user A that wants to download a private model will need to explicitly opt-in. I'm not sure how the current setup guarantees more privacy protection that the other approach. My suggestion is to change if isinstance(use_auth_token, str):
headers["authorization"] = f"Bearer {use_auth_token}"
elif use_auth_token:
token = HfFolder.get_token()
if token is None:
raise EnvironmentError(
"You specified use_auth_token=True, but a huggingface token was not"
" found."
) to if isinstance(use_auth_token, str):
headers["authorization"] = f"Bearer {use_auth_token}"
token = HfFolder.get_token()
if token is None:
raise EnvironmentError(
"You specified use_auth_token=True, but a huggingface token was not"
" found."
) Note that the upload methods already do this automatically (as in huggingface_hub/src/huggingface_hub/hf_api.py Line 1792 in 6617550
|
Upload methods aren't expected by the user to even work w/o authentication, but download methods are (for public repos anyways) I will try to find the past discussions of this and link them here, for completeness. But note that I'm not opposed to changing this behavior, just need to be aware of privacy implications |
one example of internal convo but earlier discussions were probably more interesting |
@sgugger pointed me to this |
Describe the bug
Right now,
hf_hub_download
does not work for private repos unless you setuse_auth_token=True
. This is inconsistent with other methods in which the token is automatically retrieved if not specified. I think we should changehuggingface_hub/src/huggingface_hub/file_download.py
Lines 577 to 586 in 7e80140
WDYT @LysandreJik @julien-c?
Reproduction
No response
Logs
No response
System Info
The text was updated successfully, but these errors were encountered: