-
Notifications
You must be signed in to change notification settings - Fork 473
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
Harmonization of token Parameter Descriptions and Type Definitions in hf_api.py
#2251
Comments
Thanks for looking in this @lappemic! Totally agree with you this would benefit from some harmonization. For the record, ~2y ago tokens where not used by default, hence the boolean value. Now, tokens are always sent when the user is logged in (either via env variable or So if there is harmonization, it should be towards
About the attribute description. I would update it to mention that the recommended way to login is not by using this arg but rather login the machine itself. What do you think of:
? |
The description sounds reasonable and is clear 👍 I will open a PR for this the next days. |
Second version? (less verbose)
|
And thanks for raising this topic + propose your help on this one! It's something that always bothered me but never really addressed 😄 |
The second version is definitely less verbose. I just stumble across the "Finally" in the last sentence which is in my understanding like the last step in an "actionchain" (regardless the actions before). I do not want to make it picky, but what would you think about:
|
Haha, addressing every itch would just be too overwhelming 😅 Glad i can help out here! |
Thanks for the suggestion, let's use that! I'd just update it to set the url directly in the docstring. I think it's better for users reading the srouce code directly (so not rendered),
|
While working on issue #2209, I noticed inconsistencies in the type definitions and descriptions of the
token
parameter across different method signatures and their associated docstrings inhuggingface_hub.hf_api.py
. This could confuse external as well as internal developers.Variations in Type Definitions:
token: Optional[str] = None
token: Union[bool, str, None] = None
token: Optional[Union[str, bool]] = None
Variations in Docstring Descriptions:
token=False
if you don't want to send your token to the server."None
orTrue
and machine is logged in (throughhuggingface-cli login
or [~huggingface_hub.login
]), token will be retrieved from the cache. IfFalse
, token is not sent in the request header."user
is not passed to implicitly determine the current user name."Proposal for Standardization:
I propose a unified type definition and description for the
token
parameter. Here are the options to consider for the type definition:token: Optional[str] = None
token: Union[bool, str, None] = None
And for the description, a comprehensive version could be:
"A valid authentication token (see https://huggingface.co/settings/token). If
None
orTrue
and the machine is logged in (viahuggingface-cli login
orhuggingface_hub.login
), the token will be retrieved from the cache. PassFalse
if you do not want to send your token to the server."Would harmonizing these descriptions and type definitions be helpful? If so, which options do you think should we standardise?
The text was updated successfully, but these errors were encountered: