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
Suppress Deprecation Warning #566
Conversation
from pystiche.misc import (
suppress_deprecation_warnings as _suppress_deprecation_warnings,
)
def suppress_deprecation_warning(test_fn):
@functools.wraps(test_fn)
def wrapper(*args, **kwargs):
with _suppress_deprecation_warnings():
return test_fn(*args, **kwargs)
return wrapper
Even if there is, I wouldn't go for that. I think it is ok to be verbose here. Especially since we only need to do that once if something is deprecated. Afterwards the test should not change or there shouldn't be any new tests that check deprecated stuff. |
I opted with what you suggested since I don't have a strong opinion on this (both look good to me). This should be fixed in the recent commit. I took the freedom to remove
Right, for now, I added the decorator on the tests where this warning was raised. Does that sound good? Or should it go for all the tests? This PR should be ready for review, please take a look whenever you find the time. @pmeier Thanks! |
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.
Hey @krshrimali, thanks for the PR! I have a few comments inline. Apart from them two more general ones:
I took the freedom to remove
suppress_warnings
which isn't used anywhere in the code, please let me know if this should stay in case you plan to use it in the future.
As of pystiche==1.0.0
we have adopted semantic versioning. That means, we cannot introduce BC breaking changes on a non-major release (of course we can, but then we wouldn't follow the scheme anymore). The next release should be 1.1.0
so just a minor one. Thus, we cannot remove suppress_warnings
here. Still we can mark it as deprecated, so it can be removed with the 2.0.0
release.
Right, for now, I added the decorator on the tests where this warning was raised. Does that sound good? Or should it go for all the tests?
In this PR we should cover all tests where we actually test deprecated stuff. If there are failures in other tests, let's ignore them for now and fix this in follow-up PRs. To do that, I suggest we add the filterwarnings
option to the pytest.ini
. Example
Minor update: Thanks @pmeier for the review. Just a little caught up with PyTorch during the weekdays, will get back on this one with updates by the weekend or earlier. Hope that's fine. |
@krshrimali No worries, I'm happy for every contribution! |
Sure, I've brought it back to life but will have to mark it deprecated. This should be done in the next commit (after your inputs on existing implementation).
Unfortunately, using [pytest]
markers =
large_download
slow
slow_if_cuda_not_available
flaky
addopts =
-ra
-Wignore::UserWarning
-Wignore::pytest.PytestDeprecationWarning
-Werror
--tb=short Also as: [pytest]
markers =
large_download
slow
slow_if_cuda_not_available
flaky
filterwarnings=
ignore::UserWarning
ignore::pytest.PytestDeprecationWarning
addopts =
-ra
-Werror
--tb=short Do you have any suggestions on this? Thanks for the patience, @pmeier! |
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.
Hey @krshrimali, thanks a lot for the new commits.
Do you have any suggestions on this?
I meant what you suggested in #566 (comment) so we are almost good to go. Only minor suggestions inline.
Apart from them, I see one bigger issue: it seems our new decorator does not play nice with pytest-subtests
. We might encounter errors that read E pytest.PytestDeprecationWarning: A private pytest class or function was used.
I wanted to remove subtests for a while now and replace it with pytest.mark.parametrize
. We probably need to do that before we merge this PR. Thoughts?
Really good suggestions and questions, @pmeier - acknowledging that I've seen these comments. The suggestion looks good to fix #571, looks like @ankitaS11 is interested so this shouldn't be too late. :) I'll also send in the fixes from your comments tomorrow. Thank you for taking a look again! |
Co-authored-by: Philip Meier <github.pmeier@posteo.de>
Hey @krshrimali, with #571 now fixed, could you update your branch? After that the error messages should be a lot more clear. |
Hi, @pmeier - thanks for the update on #571. I've resolved the merge conflicts, and have updated my branch with the new changes. A few things to note:
Click to view failures=================================================================================================== FAILURES ===================================================================================================
_______________________________________________________________________________________ TestCosineSimilarity.test_shape ________________________________________________________________________________________
tests/integration/core/test_math.py:87: in test_shape
assert pystiche.cosine_similarity(input, target).size() == (2, 3, 3)
pystiche/core/_math.py:108: in cosine_similarity
warnings.warn(msg, UserWarning)
E UserWarning: The default value of batched_input has changed from False to True in version 1.0.0. To suppress this warning, pass the wanted behavior explicitly.
____________________________________________________________________________________________ TestMRFLoss.test_call _____________________________________________________________________________________________
tests/integration/loss/test_comparison.py:60: in test_call
desired = F.mrf_loss(
pystiche/loss/functional.py:44: in mrf_loss
warnings.warn(msg, UserWarning)
E UserWarning: The default value of batched_input has changed from False to True in version 1.0.0. To suppress this warning, pass the wanted behavior explicitly.
_________________________________________________________________________________________ TestMRFLoss.test_call_guided _________________________________________________________________________________________
tests/integration/loss/test_comparison.py:88: in test_call_guided
desired = F.mrf_loss(
pystiche/loss/functional.py:44: in mrf_loss
warnings.warn(msg, UserWarning)
E UserWarning: The default value of batched_input has changed from False to True in version 1.0.0. To suppress this warning, pass the wanted behavior explicitly.
____________________________________________________________________________________________ TestMRFLoss.test_main _____________________________________________________________________________________________
tests/integration/loss/test_functional.py:19: in test_main
actual = F.mrf_loss(input, target)
pystiche/loss/functional.py:44: in mrf_loss
warnings.warn(msg, UserWarning)
E UserWarning: The default value of batched_input has changed from False to True in version 1.0.0. To suppress this warning, pass the wanted behavior explicitly. |
Codecov Report
@@ Coverage Diff @@
## main #566 +/- ##
=====================================
Coverage 90.8% 90.8%
=====================================
Files 48 48
Lines 2574 2574
=====================================
Hits 2339 2339
Misses 235 235
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
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.
@krshrimali For the remaining failures, we only needed to explicitly set batched_input
. I've added this (and fixed one CLI test), and now the PR looks good. Thanks a lot!
This PR is in draft mode. Here is what it does so far:
suppress_depr_warnings
) which captures and ignoresDeprecationWarning
/UserWarning
.suppress_depr_warnings
) on tests present intests/integration/loss/*
andtests/integration/ops/test_comparison.py
files.pytest
to fail on warnings (pytest -Werror
)Testing with:
tox -e tests-integration
on the local system:Click to see skips/failures
With
tox -e tests-integration
, there are 20 failures - 242 passes - 9 skips with this branch while on theupstream/main
branch (after adding-Werror
totox.ini
), there were 36 failures - 252 passes - 9 skips.TODOs:
suppress_depr_warnings
with existing decorator:suppress_warnings
.pystiche
. (Since we explicitly usepystiche
in the deprecation message, I'm thinking of checking that keyword in the message for this.)Note:
See #511 for more context.
cc: @pmeier