[Windows] Fix subfolder config.json silently skipped during download#14153
Open
Functionhx wants to merge 1 commit into
Open
[Windows] Fix subfolder config.json silently skipped during download#14153Functionhx wants to merge 1 commit into
Functionhx wants to merge 1 commit into
Conversation
…ckslash paths
On Windows, os.path.join(k, "config.json") produces paths with backslash
separators (e.g. text_encoder\config.json). These patterns are later passed
to fnmatch, which does not normalize path separators, causing the pattern
mismatch on Windows. The result: subfolder config.json files are silently
excluded from allow_patterns and never downloaded by snapshot_download on
Windows, but downloading works fine on Linux/macOS.
Fix: use an f-string (f"{k}/config.json") to always produce forward-slash
paths, consistent with how other patterns are already constructed in the
same function (f"{k}/*", f"{k}/{f}.py", etc.).
Same bug in FlaxDiffusionPipeline.download(): os.path.join(k, "*") on line
339 of pipeline_flax_utils.py. Fixed identically (f"{k}/*").
Test Plan:
No behavioral change on Linux/macOS (forward slash already used).
On Windows, subfolder config.json files and Flax subfolder wildcards will
now be included in allow_patterns and matched correctly.
Fixes huggingface#14142
Signed-off-by: Yuchen Fan <functionhx@gmail.com>
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.
What does this PR do?
Fixes #14142.
os.path.join produces backslash paths on Windows, but fnmatch patterns expect forward slashes. This causes subfolder config.json files to be silently excluded from download.
Fixed in both Diffus\ionPipeline.download() and FlaxDiffusionPipeline.download().
Before submitting
AI agent disclosure
Who can review?
Anyone in the community.