Skip to content

Commit

Permalink
Merge pull request #51 from HideakiImamura/compatibility/deprecate-al…
Browse files Browse the repository at this point in the history
…lennlp-and-chainer

Deprecate allennlp and chainer integrations
  • Loading branch information
contramundum53 authored Dec 7, 2023
2 parents e8e3718 + 0a54ac3 commit 5a91bd0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions optuna_integration/allennlp/_dump_best_config.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions optuna_integration/allennlp/_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions optuna_integration/allennlp/_pruner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions optuna_integration/chainer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import optuna
from optuna._deprecated import deprecated_class

from optuna_integration._imports import try_import

Expand All @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions optuna_integration/chainermn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 5a91bd0

Please sign in to comment.