-
Notifications
You must be signed in to change notification settings - Fork 2.1k
TST Refactor (continued) of encoder tests #2478
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
TST Refactor (continued) of encoder tests #2478
Conversation
Follow up to huggingface#2462 using the same approach as there. Test coverage before vs after the refactor is 100% identical.
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. |
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.
Nice :)
One question, otherwise good to go.
tests/test_encoder_decoder_models.py
Outdated
r""" | ||
Test if the PeftModel behaves as expected. This includes: | ||
- test if the model has the expected methods | ||
# Note: Missing from this list are LoKr, LoHa, LN Tuning |
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.
Any particular reason? If so, this would be helpful to add.
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 think it was just forgotten or not considered important when those methods were added. My goal with the refactors was to replicate as close as possible the existing tests (hence I check the line coverage), modifying the test matrix would counteract that goal (and who knows if these methods pass). I agree though that eventually they should be added.
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.
Then this note should also state that they are supposed to be added when there's time. Without that the reader won't benefit from this note IMO
This is a follow up to huggingface#2462, huggingface#2478, and huggingface#2491. Finish the refactor from unittest-style tests to pytest-style tests to now also include the last big file to still use the old style, test_custom_models.py. This file was already mostly written with pytest in mind, so the changes were rather minimal. With this class refactored, we can finally remove ClassInstantier, which made understanding test parametrization much more difficult. There are still a few unittest.TestCase classes found throughout, but they are pretty isolated, so no big need to refactor them right now. Note that the test coverage is the same except for one difference. For some reason, I found that module level __getattr__ is no longer called when moving from unittest to pytest, such as here: https://github.com/huggingface/peft/blob/62c9cf30319ca219e1d6754626c17f510fc76441/src/peft/tuners/adalora/__init__.py#L32 This was pretty strange. I found out that these lines are invoked by usage of self.assertWarnsRegex, which is strange. The reason seems to be the unittest code here: https://github.com/python/cpython/blob/9258f3da9175134d03f2c8c7c7eed223802ad945/Lib/unittest/case.py#L296-L305 Therefore, I think it's safe to ignore this reduction in test coverage.
This is a follow up to #2462, #2478, and #2491. Finish the refactor from unittest-style tests to pytest-style tests to now also include the last big file to still use the old style, test_custom_models.py. This file was already mostly written with pytest in mind, so the changes were rather minimal. With this class refactored, we can finally remove ClassInstantier, which made understanding test parametrization much more difficult.
This is a follow up to huggingface#2462, huggingface#2478, and huggingface#2491. Finish the refactor from unittest-style tests to pytest-style tests to now also include the last big file to still use the old style, test_custom_models.py. This file was already mostly written with pytest in mind, so the changes were rather minimal. With this class refactored, we can finally remove ClassInstantier, which made understanding test parametrization much more difficult.
Follow up to #2462 using the same approach as there.
Test coverage before vs after the refactor is 100% identical.