question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deprecated decorator's message does not appear

See original GitHub issue

Expected 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

Error messages, stack traces, or logs

# error messages, stack traces, or logs

Steps to reproduce

  1. pip install git+https://github.com/nzw0301/optuna.git@deprecated-test
  2. 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:closed
  • Created 3 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
HideakiImamuracommented, Jun 24, 2020

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. image (1)

However, thanks to the investigation by @nzw0301, we have noticed the following TODOs.

0reactions
harupycommented, Jun 24, 2020

@HideakiImamura Thanks for the reply. Got it!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found