From 0a54ac3710437272a9a988f73f0237c660a32752 Mon Sep 17 00:00:00 2001 From: HideakiImamura Date: Wed, 6 Dec 2023 17:07:34 +0900 Subject: [PATCH] Deprecate allennlp and chainer integrations. --- optuna_integration/allennlp/_dump_best_config.py | 2 ++ optuna_integration/allennlp/_executor.py | 4 ++-- optuna_integration/allennlp/_pruner.py | 4 ++-- optuna_integration/chainer.py | 2 ++ optuna_integration/chainermn.py | 3 +++ 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/optuna_integration/allennlp/_dump_best_config.py b/optuna_integration/allennlp/_dump_best_config.py index 0f936a65..4b419860 100644 --- a/optuna_integration/allennlp/_dump_best_config.py +++ b/optuna_integration/allennlp/_dump_best_config.py @@ -1,6 +1,7 @@ import json import optuna +from optuna._deprecated import deprecated_func from optuna_integration._imports import try_import from optuna_integration.allennlp._environment import _environment_variables @@ -10,6 +11,7 @@ import _jsonnet +@deprecated_func("3.5.0", "5.0.0") def dump_best_config(input_config_file: str, output_config_file: str, study: optuna.Study) -> None: """Save JSON config file with environment variables and best performing hyperparameters. diff --git a/optuna_integration/allennlp/_executor.py b/optuna_integration/allennlp/_executor.py index 1927d8f7..dd10c4c9 100644 --- a/optuna_integration/allennlp/_executor.py +++ b/optuna_integration/allennlp/_executor.py @@ -7,7 +7,7 @@ import optuna from optuna import TrialPruned -from optuna._experimental import experimental_class +from optuna._deprecated import deprecated_class from optuna_integration._imports import try_import from optuna_integration.allennlp._environment import _environment_variables @@ -67,7 +67,7 @@ def _fetch_pruner_config(trial: optuna.Trial) -> dict[str, Any]: return kwargs -@experimental_class("1.4.0") +@deprecated_class("3.5.0", "5.0.0") class AllenNLPExecutor: """AllenNLP extension to use optuna with Jsonnet config file. diff --git a/optuna_integration/allennlp/_pruner.py b/optuna_integration/allennlp/_pruner.py index 18096bb5..317dcabc 100644 --- a/optuna_integration/allennlp/_pruner.py +++ b/optuna_integration/allennlp/_pruner.py @@ -8,7 +8,7 @@ from optuna import pruners from optuna import Trial from optuna import TrialPruned -from optuna._experimental import experimental_class +from optuna._deprecated import deprecated_class from packaging import version from optuna_integration._imports import try_import @@ -72,7 +72,7 @@ def _create_pruner( return pruner(**pruner_kwargs) -@experimental_class("2.0.0") +@deprecated_class("3.5.0", "5.0.0") @TrainerCallback.register("optuna_pruner") class AllenNLPPruningCallback(TrainerCallback): """AllenNLP callback to prune unpromising trials. diff --git a/optuna_integration/chainer.py b/optuna_integration/chainer.py index 11e244b1..17758ed7 100644 --- a/optuna_integration/chainer.py +++ b/optuna_integration/chainer.py @@ -1,6 +1,7 @@ from __future__ import annotations import optuna +from optuna._deprecated import deprecated_class from optuna_integration._imports import try_import @@ -15,6 +16,7 @@ Extension = object # type: ignore[assignment, misc] # NOQA +@deprecated_class("3.5.0", "5.0.0") class ChainerPruningExtension(Extension): """Chainer extension to prune unpromising trials. diff --git a/optuna_integration/chainermn.py b/optuna_integration/chainermn.py index 99949100..6b0f0e0e 100644 --- a/optuna_integration/chainermn.py +++ b/optuna_integration/chainermn.py @@ -8,6 +8,7 @@ import warnings from optuna import TrialPruned +from optuna._deprecated import deprecated_class from optuna._deprecated import deprecated_func from optuna.distributions import BaseDistribution from optuna.distributions import CategoricalChoiceType @@ -53,6 +54,7 @@ def __call__(self, trial: Trial) -> float: return self.objective(ChainerMNTrial(trial, self.comm), self.comm) +@deprecated_class("3.5.0", "5.0.0") class ChainerMNStudy: """A wrapper of :class:`~optuna.study.Study` to incorporate Optuna with ChainerMN. @@ -140,6 +142,7 @@ def __setattr__(self, attr_name: str, value: Any) -> None: setattr(self.delegate, attr_name, value) +@deprecated_class("3.5.0", "5.0.0") class ChainerMNTrial(BaseTrial): """A wrapper of :class:`~optuna.trial.Trial` to incorporate Optuna with ChainerMN.