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

Implemented CLI download functionality #1617

Merged
merged 16 commits into from
Sep 6, 2023

Conversation

martinbrose
Copy link
Contributor

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Aug 30, 2023

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

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.

Hi @martinbrose, thanks a ton for working on this PR! It is a quite expected feature that will drastically simplify how some users are downloading weights from the Hub. The goal is to kinda replace git clone-like commands by this one 🚀 🤗

I started to try the CLI locally and got opinionated on how the command should look like which lead to me making changes directly on your PR. I hope you didn't find it offensive :) Here is how the command looks like now:

# Download file
huggingface-cli download gpt2 config.json

# Download entire repo
huggingface-cli download fffiloni/zeroscope --repo-type=space --revision=refs/pr/78

# Download repo with filters
huggingface-cli download gpt2 --include="*.safetensors"

# Download with token
huggingface-cli download Wauplin/private-model --token=hf_***

# Download quietly (no progress bar, no warnings, only the returned path)
huggingface-cli download gpt2 config.json --quiet

EDIT: I have also added some content in the download guide to make sure it's documented somewhere.

@martinbrose
Copy link
Contributor Author

Thanks @Wauplin,

I've reviewed your changes with interest and they made sense to me.
Of course, feel free to change how you see fit.

Cheers

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.

@LysandreJik @julien-c Would you mind having a look to this PR as it adds a quite important command IMO (also cc @osanseviero). Might be interesting to showcase this command in the "Clone this model repository" pop-up on the Hub. Before doing so, we would need the --to-local-dir option to be implemented but that can be done in a future PR.

cc @stevhliu I have added a small section in the docs if you can have a look at it 🙏

EDIT: implemented --to-local-dir in 874b70e

@severo
Copy link
Collaborator

severo commented Sep 4, 2023

Do you think we could have a shorter command (huggingface-cli is long). Maybe hf-cli, or hf?

@Wauplin
Copy link
Contributor

Wauplin commented Sep 4, 2023

Do you think we could have a shorter command (huggingface-cli is long). Maybe hf-cli, or hf?

I'm definitely in favor of a simple hf download ...!
I often thought about it but never made the change. We would still keep both hf and huggingface-cli for backward compatibility. We can do it in a future PR (also I don't know how much @julien-c or @LysandreJik are opinionated on the subject 😄 )

@Wauplin Wauplin requested a review from stevhliu September 4, 2023 12:46
@julien-c
Copy link
Member

julien-c commented Sep 4, 2023

re shorter command name, i wouldn't recommend because:

  • users have auto-complete in their shells?
  • let's not fragment usage as huggingface-cli already exists and is widely documented
  • there's even system packages (brew etc) with that name

Copy link
Member

@julien-c julien-c left a comment

Choose a reason for hiding this comment

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

API-wise, looks great to me!

and i liked the detailed pre-spec in #1105 (comment) cc @Wauplin

I think this will be quite a useful feature!

Copy link
Member

@stevhliu stevhliu left a comment

Choose a reason for hiding this comment

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

Super cool! 🤩

docs/source/en/guides/download.md Outdated Show resolved Hide resolved
docs/source/en/guides/download.md Outdated Show resolved Hide resolved
docs/source/en/guides/download.md Outdated Show resolved Hide resolved
docs/source/en/guides/download.md Outdated Show resolved Hide resolved
docs/source/en/guides/download.md Outdated Show resolved Hide resolved
docs/source/en/guides/download.md Outdated Show resolved Hide resolved
docs/source/en/guides/download.md Outdated Show resolved Hide resolved
Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>
Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

Played with it, works well! I like the API. Thanks for working on it @Wauplin

@Wauplin Wauplin merged commit 9e71350 into huggingface:main Sep 6, 2023
@martinbrose martinbrose deleted the 1105-CLI-download branch September 6, 2023 08:38
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.

7 participants