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

feat(@huggingface/hub): adding scanCacheDir #908

Merged
merged 15 commits into from
Sep 26, 2024

Conversation

axel7083
Copy link
Contributor

Description

Took https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/utils/_cache_manager.py as heavy inspiration for the implementation.

This is a very basic implementation, which do not cover the deletion.

Related issue

Fixes #905

Usage

import { scanCacheDir } from "@huggingface/hub";

const result = await scanCacheDir();
console.log(result);

Copy link
Member

@coyotte508 coyotte508 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

Just to be clear, is this PR intended to interact with the cache folder created by the python lib? (cc @Wauplin)

Because the JS lib does not (yet?) cache files locally

packages/hub/src/lib/cache-management.ts Outdated Show resolved Hide resolved
@axel7083
Copy link
Contributor Author

Just to be clear, is this PR intended to interact with the cache folder created by the python lib?

Yes, and hopefully the js library will allow to download model in the cache later

Copy link
Member

@coyotte508 coyotte508 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

Lots of comments but it's mostly on the exposed API, technically the PR is good :)

Also, a small section in packages/hub/README.md would be great, and a doc comment on the main functions

packages/hub/src/lib/cache-management.ts Outdated Show resolved Hide resolved
packages/hub/src/lib/cache-management.ts Show resolved Hide resolved
packages/hub/src/lib/cache-management.ts Outdated Show resolved Hide resolved
packages/hub/src/lib/cache-management.ts Outdated Show resolved Hide resolved
packages/hub/src/lib/cache-management.ts Outdated Show resolved Hide resolved
packages/hub/src/lib/cache-management.ts Outdated Show resolved Hide resolved
packages/hub/src/lib/cache-management.ts Outdated Show resolved Hide resolved
packages/hub/src/lib/cache-management.ts Outdated Show resolved Hide resolved
packages/hub/src/lib/cache-management.ts Outdated Show resolved Hide resolved
packages/hub/src/lib/cache-management.ts Outdated Show resolved Hide resolved
@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.

Copy link
Member

@coyotte508 coyotte508 left a comment

Choose a reason for hiding this comment

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

Thanks for the feature!

cc @julien-c @Wauplin if you have any input before merging

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.

Thanks @axel7083 for the work! The implementation looks good at first glance except a question related to paths. I would also add a warning in the docs to mention that the JS client doesn't use the cache system itself (should avoid some misunderstanding).

packages/hub/README.md Show resolved Hide resolved
packages/hub/src/lib/cache-management.ts Outdated Show resolved Hide resolved
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.

Looks good!

@coyotte508
Copy link
Member

Thanks!

@coyotte508 coyotte508 merged commit b049c77 into huggingface:main Sep 26, 2024
4 of 5 checks passed
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.

[@huggingface/hub] add scan_cache_dir capabilities
5 participants