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

Allow boolean values for force_filename in hf_hub_download #863

Closed
nateraw opened this issue May 5, 2022 · 4 comments
Closed

Allow boolean values for force_filename in hf_hub_download #863

nateraw opened this issue May 5, 2022 · 4 comments

Comments

@nateraw
Copy link
Contributor

nateraw commented May 5, 2022

Is your feature request related to a problem? Please describe.
If you want to force the filename of a given download with hf_hub_download, right now you have to specify the filename in two places. First, when you name the file you wish to download, and then again as you have to pass a string to the force_filename kwarg. It would be really nice if you could just say force_filename=True to use the same name as the one you already referenced.

Describe the solution you'd like

When I do:

from huggingface_hub import hf_hub_download

filepath = hf_hub_download('nateraw/rare-puppers', 'config.json', force_filename=True)

The filepath should be '<cache_dir>/config.json'.

If you set it to False, it should behave the same way it does for the default None, and use the hashed filename.

I can do this if this seems like a reasonable feature to add 😄

@osanseviero
Copy link
Contributor

WDYT @julien-c @adrinjalali @LysandreJik? I personally like this idea 👍

@adrinjalali
Copy link
Contributor

I don't think it has clear semantics. As a user, looking at the above code, I kinda except it to be saved in the current folder not in the cache_dir. Also, force_filename=True itself doesn't have clear semantics. What name are we forcing here?

The above result would be something I'd expect from such a call:

filepath = hf_hub_download('nateraw/rare-puppers', 'config.json', hash_names=False, overwrite=True)

@julien-c
Copy link
Member

julien-c commented May 6, 2022

i feel like this might be rendered a bit moot by #801 as all downloaded files will have their "correct" filename out of the box

I invite everyone to start reviewing #801 BTW when you have a change (still a bit WIP but nearing the "ready for review" status)

@Wauplin
Copy link
Contributor

Wauplin commented Sep 28, 2022

I'm closing this issue as #801 is closed and git-aware cache is now the default way to download files from the hub (and keeping correct filename).

@Wauplin Wauplin closed this as completed Sep 28, 2022
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

No branches or pull requests

5 participants