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

bugfix huggingface-cli command execution in python3.8 #2620

Merged

Conversation

PineApple777
Copy link
Contributor

@PineApple777 PineApple777 commented Oct 21, 2024

When I logged-in with huggingface-cli command in basic ubuntu 20.04 docker image which uses python 3.8, below error occurred.

  • command
Huggingface-cli login
huggingface-cli login --token hf_xxxx
  • error log
Traceback (most recent call last):
  File "/usr/local/bin/huggingface-cli", line 5, in <module>
    from huggingface_hub.commands.huggingface_cli import main
  File "/usr/local/lib/python3.8/dist-packages/huggingface_hub/commands/huggingface_cli.py", line 26, in <module>
    from huggingface_hub.commands.user import UserCommands
  File "/usr/local/lib/python3.8/dist-packages/huggingface_hub/commands/user.py", line 165, in <module>
    class AuthSwitchCommand(BaseUserCommand):
  File "/usr/local/lib/python3.8/dist-packages/huggingface_hub/commands/user.py", line 203, in AuthSwitchCommand
    def _select_token_name_tui(self, token_names: list[str]) -> Optional[str]:
TypeError: 'type' object is not subscriptable

I think that this issue occurred because python3.8 does not support generic types and this leads to bugs at below points. so, I modified the below code to use List type within a typing alias. Because huggingface-hub still officially supports Python 3.8, this bug should be resolved. (this issue occur in version 0.26.0)

@hanouticelina hanouticelina self-requested a review October 21, 2024 08:15
Copy link
Contributor

@hanouticelina hanouticelina left a comment

Choose a reason for hiding this comment

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

Hi @PineApple777! thanks a lot for spotting this! 🤗 Indeed, the use of built-in type annotations is not compatible with Python 3.8.
failing tests are unrelated.

@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.

@hanouticelina
Copy link
Contributor

@Wauplin the tests are failing now that https://github.com/huggingface-internal/moon-landing/pull/11077 has been deployed with the changes made to the "security" field in the API response. I doubt there are a lot of users that parse the "security" field but I guess it's still good to reflect these changes in huggingface_hub.

@Wauplin
Copy link
Contributor

Wauplin commented Oct 21, 2024

@hanouticelina correct yes, the failing CI is unrelated to this PR so it's fine to merge (+publish a hot-fix release with this single commit to fix Python 3.8 support). Thanks @PineApple777 for the PR!

(about the security field, let's discuss it in your other PR)

@hanouticelina hanouticelina merged commit 15d4d43 into huggingface:main Oct 21, 2024
12 of 15 checks passed
hanouticelina added a commit that referenced this pull request Oct 21, 2024
* bugfix generic type in python 3.8

* run style

---------

Co-authored-by: Celina Hanouti <hanouticelina@gmail.com>
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