Skip to content
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

Apply deprecation decorator. #1413

Merged
merged 5 commits into from Jun 24, 2020

Conversation

toshihikoyanase
Copy link
Member

Motivation

Followup #1382.

Description of the changes

This PR applies the deprecation decorator to the following classes:

  • optuna.integratoin.CmaEsSampler
  • optuna.struct.FrozenTrial
  • optuna.struct.StudySummary
  • optuna.struct.TrialPruned

@toshihikoyanase toshihikoyanase added the code-fix Change that does not change the behavior, such as code refactoring. label Jun 24, 2020
Copy link
Member

@HideakiImamura HideakiImamura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! LGTM!

Copy link
Member

@hvy hvy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the follow up. I left some nits.

A question also, should we apply it to best_booster https://46573-122299416-gh.circle-artifacts.com/0/docs/build/html/reference/integration.html#optuna.integration.lightgbm.LightGBMTuner.best_booster ? It now hit me that we haven't tested this decorator on custom getters/setters.

optuna/structs.py Outdated Show resolved Hide resolved
optuna/structs.py Outdated Show resolved Hide resolved
@@ -42,3 +41,9 @@ def test_study_summary_deprecated():
datetime_start=datetime.datetime.now(),
study_id=0,
)


def test_trial_pruned_deprecated() -> None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Co-authored-by: Hiroyuki Vincent Yamazaki <hiroyuki.vincent.yamazaki@gmail.com>
@HideakiImamura
Copy link
Member

@toshihikoyanase I have another comment. How about applying the deprecation decorator to optuna.integration.lightgbm.LightGBMTuner.best_booster?

@toshihikoyanase
Copy link
Member Author

@hvy @HideakiImamura Thank you for your comment on the optuna.integration.lightgbm.LightGBMTuner.best_booster property. I applied the decorator in a3988b4, and confirmed that the decorator worked as expected. PTAL.

image

@toshihikoyanase
Copy link
Member Author

Mypy does not support the type checking of decorated properties.

optuna/integration/_lightgbm_tuner/optimize.py:732: error: Decorated property not supported

As suggested in python/mypy#1362, I add # type: ignore to the @propety.

"Please get the best booster via "
":class:`~optuna.integration.lightgbm.LightGBMTuner.get_best_booster` instead."
),
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly wondering but does having the deprecated also work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry but I couldn't get the point. If you mean the confirmation of the behavior of best_booster property with @decorated, it works as expected :

# examples/lightgbm_tuner_simple.py

    ....
    # model = lgb.train(
    #     params, dtrain, valid_sets=[dtrain, dval], verbose_eval=100, early_stopping_rounds=100,
    # )
    # model = lgb.train(
    #     params, dtrain, valid_sets=[dtrain, dval], verbose_eval=100, early_stopping_rounds=100,
     # )
    lgbt = lgb.LightGBMTuner(
        params, dtrain, valid_sets=[dtrain, dval], verbose_eval=100, early_stopping_rounds=100,
    )
    lgbt.run()
    model = lgbt.best_booster
optuna/_deprecated.py:110: DeprecationWarning: best_booster has been deprecated in v1.4.0. This feature will be removed in v3.0.0.
  DeprecationWarning,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I meant having the deprecated decorator outermost (applied after property).

Copy link
Member

@hvy hvy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@hvy hvy merged commit 99b7321 into optuna:master Jun 24, 2020
@hvy hvy added this to the v2.0.0 milestone Jun 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-fix Change that does not change the behavior, such as code refactoring.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants