-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds missing module_specs for usages of _LazyModule #15230
Adds missing module_specs for usages of _LazyModule #15230
Conversation
The documentation is not available anymore as the PR was closed or merged. |
😍 exactly what i need |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this. Note that it should be added in every _LazyModule
but I can take care of that in a separate PR.
tests/test_configuration_auto.py
Outdated
assert transformers.models.auto.__spec__ is not None | ||
assert importlib.util.find_spec("transformers.models.auto") is not None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use self.assertIsNotNone
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is not part of a unittest.TestCase I can't
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be in the AutoConfigTest
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can and will do that! I just oriented my changes on #13321 which also uses the pure pytest variant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I didn't catch the test was not up to our usual standards in that one :-) Thanks for fixing here!
I have just moved the test. I also have a local commit lying around that adds the module_spec to all occurences of the LazyModule, but I am not that sure on where to put the tests for that. Looking at the Can I just add a |
Oh that's great! If you want to include that commit in this PR and rename it that would be great. Regarding tests, I don't think we need more than the test for the auto submodule and the test of transformers (since it's the same thing everywhere). To answer your question however, it does not need to be under a To have the PR be perfectly complete, could you also add the change to the modeling template (if you don't have it in your commit already) as well as fix the test for transformers spec to be in a |
Okay, I figured that with the tests, but I wasn't sure. From my side this would now be mergeable, unless I made an error somewhere! Edit: We could also get rid of the |
Thank you so much for the wide fix! With the templates properly fixed, I don't think we will get new inits without the |
What does this PR do?
This PR adds a missing
__spec__
to the_LazyModule
instances of all models.When a module is missing a spec it could not be imported via
importlib.import_module
, which is what torchmetrics does, which is why I've found it in the first place.Related to #13321 (pr)
Fixes #15212 (issue)
Before submitting
This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).Pull Request section?
to it if that's the case.
Did you make sure to update the documentation with your changes? Here are thedocumentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.