Skip to content

[Cache] Skip local-dir metadata when verifying checksums - #5257

Merged
hanouticelina merged 1 commit into
huggingface:mainfrom
alphasafal:fix/verify-local-dir-skip-metadata
Oct 27, 2026
Merged

hanouticelina merged 1 commit into
huggingface:mainfrom
alphasafal:fix/verify-local-dir-skip-metadata

Conversation

@alphasafal

@alphasafal alphasafal commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

hf cache verify --local-dir reports every file under .cache/huggingface/ as an "extra" file, so an intact --local-dir download always warns, and --fail-on-extra-files exits 1 even when every checksum matches. Fixes #5256.

  • collect_local_files (used by verify_repo_checksums) listed everything under the folder via root.rglob("*"), including the metadata a --local-dir download writes: .gitignore, CACHEDIR.TAG, download/<file>.metadata, download/<file>.lock.
  • Those files can never exist in the repo, so verify_maps placed all of them in extra_paths.
  • Fix: filter collect_local_files with DEFAULT_IGNORE_PATTERNS — the same patterns uploads already use to ignore .git/ and .cache/huggingface/.
  • Added test_collect_local_files_skips_local_dir_metadata; the existing test_collect_local_files_lists_all still passes.

Before

Repro from the issue (verify_maps on a clean config.json download) — res.extra_paths:

['.cache/huggingface/.gitignore',
 '.cache/huggingface/CACHEDIR.TAG',
 '.cache/huggingface/download/config.json.lock',
 '.cache/huggingface/download/config.json.metadata']

After

res.extra_paths == []

res.mismatches and res.missing_paths stay empty in both cases.


Note

Low Risk
Narrow change to local file enumeration for verification; reuses existing upload ignore patterns and adds a focused test.

Overview
collect_local_files (used by local-dir checksum verification) no longer treats Hugging Face download metadata as repo files. After building the full file map from rglob, paths are filtered with DEFAULT_IGNORE_PATTERNS and filter_repo_objects — the same rules uploads use to skip .git/ and .cache/huggingface/ (e.g. .gitignore, CACHEDIR.TAG, download/*.metadata).

That stops hf cache verify --local-dir from filling extra_paths and failing --fail-on-extra-files on otherwise valid --local-dir trees. A regression test asserts metadata under .cache/huggingface/ is omitted while other files under .cache/ remain.

Reviewed by Cursor Bugbot for commit 9891153. Bugbot is set up for automated code reviews on this repo. Configure here.

collect_local_files listed everything under the folder, including the .cache/huggingface/ metadata that downloads to a local_dir write, so hf cache verify --local-dir reported those files as extra and --fail-on-extra-files failed on every clean download. Filter with DEFAULT_IGNORE_PATTERNS, the same patterns uploads use.
Copilot AI balanced review requested due to automatic review settings October 25, 2026 17:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@hanouticelina hanouticelina left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks a lot for fixing!

@codecov

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.67%. Comparing base (1daa48b) to head (9891153).
⚠️ Report is 825 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5257      +/-   ##
==========================================
+ Coverage   75.00%   77.67%   +2.67%     
==========================================
  Files         145      178      +33     
  Lines       13978    25332   +11354     
==========================================
+ Hits        10484    19677    +9193     
- Misses       3494     5655    +2161     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bot-ci-comment

Copy link
Copy Markdown

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.

@hanouticelina
hanouticelina merged commit e255f04 into huggingface:main Oct 27, 2026
24 of 27 checks passed
@huggingface-hub-bot

Copy link
Copy Markdown
Contributor

This PR has been shipped as part of the v2.4.0 release.

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.

hf cache verify --local-dir reports the .cache/huggingface/ download metadata as extra files

3 participants