Fix test for model with dotted name and relative imports #41343
+3
−2
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?
The test
test_model_with_dotted_name_and_relative_imports
added in #40745 is not working as expected becausemodel_id = "hf-internal-testing/remote_code_model_with_dots"
does not include.
in the name.If this PR change looks good, could you create this new remote model? (I didn't create it myself because relying on an external user's resource is risky, as you mentioned in #40745 (review)).
Below is a detailed explanation of why
test_model_with_dotted_name_and_relative_imports
is not working. The explanation is a bit long, so feel free to skip it if you understand the problem from the above explanation.If we remove the
_sanitize_module_name
process simply by changing the method like below:The test should raise an error, but it actually passes:
pytest tests/models/auto/test_modeling_auto.py::AutoModelTest::test_model_with_dotted_name_and_relative_imports ================================================================================== test session starts =================================================================================== platform linux -- Python 3.12.11, pytest-8.4.1, pluggy-1.6.0 rootdir: /home/shutotakahashi/projects/transformers-uv/transformers configfile: pyproject.toml plugins: anyio-4.11.0, xdist-3.8.0 collected 1 item tests/models/auto/test_modeling_auto.py::AutoModelTest::test_model_with_dotted_name_and_relative_imports PASSED [100%]
The reason the test passes is that the current
model_id = "hf-internal-testing/remote_code_model_with_dots"
does not include.
in the name, as reported in the original issue #40496.If we replace
model_id
withAugust4293/test-model_v1.0
, which includes.
in the name (this model was uploaded by the original PR contributor in #40745 (comment)), the test raises the expected error:Fixes #40496
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@Rocketknight1