Conversation
…om modules get_cached_module_file recurses into relative imports of a remote custom_generate/modeling module, building the child module path with Path(module_file).parent / module_needed. On Windows that yields a backslash path (e.g. 'custom_generate\beam_search.py') which the Hub lookup then cannot find: OSError: transformers-community/group-beam-search does not appear to have a file named custom_generate\beam_search.py Normalize with as_posix() so the Hub-relative path keeps forward slashes. Local filesystem uses of the same value are unaffected (Windows accepts forward slashes). Co-Authored-By: Claude Code <noreply@anthropic.com>
Contributor
CI recapDashboard: View test results in Grafana |
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
When a Hub repo's
custom_generate/generate.pyrelative-imports a sibling module (e.g.beam_search.pyintransformers-community/group-beam-searchandconstrained-beam-search),get_cached_module_filerecurses to fetch it and builds the child path like this:f"{Path(module_file).parent / module_needed}.py"On Windows,
Path("custom_generate/generate.py").parent / "beam_search"renders ascustom_generate\beam_search, and that backslash path is then looked up on the Hub, where file names always use forward slashes:So
custom_generatestrategies whose code spans several files cannot be loaded at all on Windows. (Sibling repos whosegenerate.pyis self-contained, likedolaandcontrastive-search, are unaffected — this only triggers on relative imports.)Fix
Normalize the Hub-relative path with
as_posix()before the recursive lookup. Local filesystem uses of the same value are unaffected (Windows accepts forward slashes), and on POSIX systems the rendered path is unchanged.Verification
Windows 11, Python 3.14:
GenerationIntegrationTests::test_hub_gen_strategies_2_transformers_community_group_beam_searchand..._3_transformers_community_constrained_beam_search: fail without the fix with theOSErrorabove; pass with it.tests/utils/test_dynamic_module_utils.py: 16 passed.🤖 Generated with Claude Code