Deprecated decorator's message does not appear
See original GitHub issueExpected behavior
When we run a method or class has deprecated decorator of optuna, we expect a warning message is shown. But the current implementation does not show any warning message.
Environment
- Optuna version: the lastest version & additional commit
- Python version: 3.8.4
- OS: MacOSX 10.15.5
Error messages, stack traces, or logs
# error messages, stack traces, or logs
Steps to reproduce
pip install git+https://github.com/nzw0301/optuna.git@deprecated-test
- Run the following examples: they do not show anything.
Reproducible examples (optional)
By the additional commit, IntLogUniformDistribution
and IntLogUniformDistribution.single
have deprecated decorators. But no warning messages appear when they are called:
import optuna
from optuna.distributions import IntLogUniformDistribution
dist = IntLogUniformDistribution(1, 10)
dist.single()
Or
import optuna
from optuna.distributions import IntLogUniformDistribution
optuna.logging.set_verbosity(optuna.logging.WARNING)
dist = IntLogUniformDistribution(1, 10)
dist.single()
Additional context (optional)
Other optuna’s codes such that it contains DeprecatedWarning
such as optuna.structs.py
show the warning message by default when we use them.
For example, if I run the following line,
from optuna.structs import FrozenTrial
then the following warning message is printed:
[W 2020-06-24 01:11:56,553] `structs` is deprecated. Classes have moved to the following modules. `structs.StudyDirection`->`study.StudyDirection`, `structs.StudySummary`->`study.StudySummary`, `structs.FrozenTrial`->`trial.FrozenTrial`, `structs.TrialState`->`trial.TrialState`, `structs.TrialPruned`->`exceptions.TrialPruned`.
Thank you @HideakiImamura for investigating this issue.
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (7 by maintainers)
Top Results From Across the Web
decorators in the python standard lib (@deprecated ...
I am aware of recipes for it and the warnings module, but my question is: why is there no standard library decorator for...
Read more >Make deprecation highlighting for decorated functions with ...
That's be very cool if I created @deprecated("message") decorator, and highlighting of decorated with this decorator functions will be striked. For example:.
Read more >Using the “Sphinx” decorators
In Python 3.3 and previous versions, the docstring of a class is immutable [1], this means that you cannot use the “Sphinx” decorators....
Read more >Source code for matplotlib._api.deprecation
Helper functions for deprecating parts of the Matplotlib API. This documentation is only relevant for Matplotlib developers, not for users. .. warning: This ......
Read more >Deprecations and Removals
Deprecated since version 6.0. Removed in version 7.0. The pytest.collect module is no longer part of the public API ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi all. Thank you for all of your contributions.
After the discussion with core team members, we have decided to use only
warnings.warn()
for the deprecation messages according to https://docs.python.org/3/howto/logging.html, because users can avoid this situation (reported in Issue #1411) by fixing their own code.However, thanks to the investigation by @nzw0301, we have noticed the following TODOs.
warnings.warn()
andlogging.warn()
in https://github.com/optuna/optuna/wiki/Coding-Style-Conventions.optuna/structs.py
to use onlywarnings.warn()
.@HideakiImamura Thanks for the reply. Got it!