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

Group cache files by repository #332

Merged
merged 1 commit into from
Feb 13, 2024
Merged

Group cache files by repository #332

merged 1 commit into from
Feb 13, 2024

Conversation

jonatanklosko
Copy link
Member

Currently our cache directory has flat structure, where for each cached file we have one .json file with metadata and another with file contents. The file names are URL hashes or etags, so they are not meaningful to the user.

The cache should be opaque to the user, however it's easy to accumulate a lot of models, but clearing the whole cache is not ideal, since the user may want to remove only the models they no longer plan to use. For this purpose, this PR groups all cache files related to a specific HF repository in a separate subdirectory with meaningful name.

As a result, the existing caches will be invalidated, but I think it's worth it and we can just mention in the changelog that users should clear the cache.

defp repository_id_to_cache_scope(repository_id) do
repository_id
|> String.replace("/", "--")
|> String.replace(~r/[^\w-]/, "")
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can Base.url_encode64 it instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

The idea is exactly to keep it readable, so we end up with subdirs like facebook--convnext-tiny-224 :)

@jonatanklosko jonatanklosko merged commit b68ad2b into main Feb 13, 2024
2 checks passed
@jonatanklosko jonatanklosko deleted the jk-cache-scope branch February 13, 2024 16:07
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.

2 participants