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

Add token and git credentials to login cli command #1372

Merged
merged 2 commits into from
Mar 2, 2023

Conversation

silvanocerza
Copy link
Contributor

As of now it's not possible to login in a non interactive shell using huggingface-cli login as it always prompt to input the token. This makes it hard to use the CLI for automation, for example in GitHub Actions.

This PR adds --token and --add-to-git-credential args to huggingface-cli login command.

$ huggingface-cli login --help
usage: huggingface-cli <command> [<args>] login [-h] [--token TOKEN] [--add-to-git-credential]

options:
  -h, --help            show this help message and exit
  --token TOKEN         Token generated from https://huggingface.co/settings/tokens
  --add-to-git-credential
                        Optional: Save token to git credential helper.

Example call:

$ huggingface-cli login --token $HUGGING_FACE_TOKEN --add-to-git-credential

Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

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

Nice PR @silvanocerza , thank you for your help!
I made some cosmetic changes but otherwise I think we are good to merge it as soon as the CI is green.

src/huggingface_hub/commands/user.py Outdated Show resolved Hide resolved
src/huggingface_hub/commands/user.py Outdated Show resolved Hide resolved
src/huggingface_hub/commands/user.py Outdated Show resolved Hide resolved
@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Mar 2, 2023

The documentation is not available anymore as the PR was closed or merged.

@Wauplin Wauplin merged commit 318f1be into huggingface:main Mar 2, 2023
@Wauplin
Copy link
Contributor

Wauplin commented Mar 2, 2023

And it's merged! Thanks for this contribution @silvanocerza. Clean and quick! :)

@silvanocerza silvanocerza deleted the login-args branch March 2, 2023 16:44
@julien-c
Copy link
Member

julien-c commented Mar 7, 2023

thanks a lot @silvanocerza!

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