-
Notifications
You must be signed in to change notification settings - Fork 430
feat(hub): adding downloadFileToCacheDir
#1034
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
feat(hub): adding downloadFileToCacheDir
#1034
Conversation
downloadFileToCacheDir
Thanks a lot, probably a |
Should be good now :) ! |
Can you find a way to skip the test in browser environment? (I can look into it otherwise) |
Yes, I excluded it from |
Co-authored-by: Eliott C. <[email protected]>
Thanks!! |
## Description We can now create a `snapshotDownload` method similator to the `snapshot_download` of the PY lib[^1], clone to the cache (only cache supported for now) a repository (either model, space or dataset) [^1]: https://huggingface.co/docs/huggingface_hub/en/guides/download#download-an-entire-repository ## Related issues/PR With the amazing help of @coyotte508 we were able to merge the following changes - #1034 - #1031 - #999 Which allow this PR to provide a python compliant clone of a hugging face repository to the cache directory. ## Testing - [x] unit tests are covering the new feature **Manually** ```ts await snapshotDownload({ repo: { name: 'OuteAI/OuteTTS-0.1-350M', type: 'model', }, }); ``` assert using the `huggingface-cli` tool (python) ``` $: huggingface-cli scan-cache REPO ID REPO TYPE SIZE ON DISK NB FILES LAST_ACCESSED LAST_MODIFIED REFS LOCAL PATH ----------------------------------- --------- ------------ -------- ----------------- ----------------- ---- ---------------------------------------------------------------------------------- OuteAI/OuteTTS-0.1-350M model 731.6M 14 5 minutes ago 5 minutes ago main /home/axel7083/.cache/huggingface/hub/models--OuteAI--OuteTTS-0.1-350M ``` --------- Co-authored-by: Eliott C. <[email protected]>
Description
Following #1031 which added a
pathsInfo
method which can return the etag/commitHash for a given file. Allowing to be compliant with the_hf_hub_download_to_cache_dir
1 method from the python library.Potential issue
The JS implementation do not handle the .lock files as the python library does.. This could be a problem if using the JS and PY function.. ?
The JS could make a basic implementation of the lock file that the PY lib is doing if this is a hard requirement.
Testing
I wrote tests for the existing
downloadFile
function (no change to the implementation) and the new one addeddownloadFileToCacheDir
.Footnotes
huggingface_hub/file_download.py#L882 ↩