Repository navigation
[Download] Warn when allow/ignore patterns match no files in snapshot_download - #5067
Merged
Merged
Conversation
Wauplin
reviewed
Oct 2, 2026
Wauplin
reviewed
Oct 2, 2026
Wauplin
approved these changes
Oct 2, 2026
Wauplin
left a comment
Collaborator
There was a problem hiding this comment.
Made some changes but overall looks good
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5067 +/- ##
==========================================
+ Coverage 75.00% 77.57% +2.56%
==========================================
Files 145 177 +32
Lines 13978 24787 +10809
==========================================
+ Hits 10484 19228 +8744
- Misses 3494 5559 +2065 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
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. |
Contributor
|
This PR has been shipped as part of the v2.2.0 release. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5064
What
snapshot_download(and thereforehf download) reported a normal successful download whenallow_patterns/ignore_patterns(--include/--exclude) matched zero files. A mistyped glob such as--include "*.safetensor"looked identical to a successful download.This adds a
logger.warningwhen patterns were provided, the repo has files, and none of them matched:No behavior change otherwise: no new exception, exit code unchanged, nothing is warned when the patterns match at least one file, when no patterns are given, or when the repo is empty.
Tests
Added
test_warn_when_patterns_match_no_files(parametrized: warns for no-matchallow_patternsas list/str,ignore_patterns=["*"], and allow+ignore cancelling out; stays quiet when files match or no patterns are given) andtest_no_warning_when_repo_is_empty. The four warning cases fail before the change and pass after.tests/test_snapshot_download.py,tests/test_cli.py: pass locallyruff check/ruff format --check,check_static_imports,check_all_variable,generate_async_inference_client,generate_cli_reference: passty check srcreports 2 errors incli/_output.py(invalid-type-form); they are identical onmainwithout this change.Note
Low Risk
Adds a log warning only on a zero-match pattern edge case; download success semantics and exit behavior are unchanged.
Overview
snapshot_download(andhf downloadvia--include/--exclude) now emits alogger.warningwhen the repo tree has files butallow_patterns/ignore_patternsfilter everything out—so a typo like*.safetensorno longer looks like a normal “fetch 0 files” success.The warning lists whichever pattern kwargs were set (e.g.
allow_patterns='*.safetensor'). It is skipped when no patterns are passed, when at least one file matches, or when the repo tree is empty. No new errors, exit codes, or download behavior otherwise.Reviewed by Cursor Bugbot for commit 7fda4f3. Bugbot is set up for automated code reviews on this repo. Configure here.