Skip to content

Commit

Permalink
Expire 0.6.* deprecations (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianSosic authored Apr 23, 2024
2 parents 725dca5 + 1125647 commit 4f0cb62
Show file tree
Hide file tree
Showing 11 changed files with 8 additions and 92 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `acquisition_function_cls` constructor parameter for `BayesianRecommender`
- `VarUCB` and `qVarUCB` acquisition functions

### Expired Deprecations (from 0.6.*)
- `BayBE` class
- `baybe.surrogate` module
- `baybe.targets.Objective` class
- `baybe.strategies.Strategy` class

## [0.8.2] - 2024-03-27
### Added
- Simulation user guide
Expand Down
2 changes: 0 additions & 2 deletions baybe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import warnings

from baybe.campaign import Campaign
from baybe.deprecation import BayBE

# Show deprecation warnings
warnings.filterwarnings("default", category=DeprecationWarning, module="baybe")
Expand Down Expand Up @@ -52,7 +51,6 @@ def infer_version() -> str: # pragma: no cover
__version__ = infer_version()
__all__ = [
"__version__",
"BayBE",
"Campaign",
]

Expand Down
16 changes: 0 additions & 16 deletions baybe/deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,6 @@

import warnings

from attrs import define

from baybe import Campaign


@define
class BayBE(Campaign):
"""A :class:`baybe.campaign.Campaign` alias for backward compatibility."""

def __attrs_pre_init__(self):
warnings.warn(
"The 'BayBE' class is deprecated and will be removed in a future version. "
"Please use the 'Campaign' class instead.",
DeprecationWarning,
)


def compatibilize_config(config: dict) -> dict:
"""Turn a legacy-format config into the new format."""
Expand Down
2 changes: 0 additions & 2 deletions baybe/strategies/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from baybe.strategies.deprecation import (
SequentialStrategy,
Strategy,
StreamingSequentialStrategy,
TwoPhaseStrategy,
)
Expand All @@ -11,5 +10,4 @@
"SequentialStrategy",
"StreamingSequentialStrategy",
"TwoPhaseStrategy",
"Strategy",
]
12 changes: 0 additions & 12 deletions baybe/strategies/deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@
)


def Strategy(*args, **kwargs) -> TwoPhaseMetaRecommender:
"""A ``Strategy`` alias for backward compatibility.""" # noqa: D401 (imperative mood)
warnings.warn(
f"Using 'Strategy' directly is deprecated and will be removed in a future "
f"version. Please use 'recommenders.{TwoPhaseMetaRecommender.__name__}' class "
f"instead.",
DeprecationWarning,
)

return TwoPhaseMetaRecommender(*args, **kwargs)


def TwoPhaseStrategy(*args, **kwargs) -> TwoPhaseMetaRecommender:
"""A ``TwoPhaseStrategy`` alias for backward compatibility.""" # noqa: D401 (imperative mood)
warnings.warn(
Expand Down
11 changes: 0 additions & 11 deletions baybe/surrogate.py

This file was deleted.

2 changes: 0 additions & 2 deletions baybe/targets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
"""BayBE targets."""

from baybe.targets.deprecation import Objective
from baybe.targets.enum import TargetMode, TargetTransformation
from baybe.targets.numerical import NumericalTarget

__all__ = [
"NumericalTarget",
"Objective",
"TargetMode",
"TargetTransformation",
]
22 changes: 0 additions & 22 deletions baybe/targets/deprecation.py

This file was deleted.

2 changes: 1 addition & 1 deletion docs/templates/custom-module-template.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
:template: custom-module-template.rst
:recursive:
{% for item in modules %}
{% if not item in ("baybe.deprecation", "baybe.surrogate", "baybe.strategies.deprecation", "baybe.targets.deprecation", "baybe.objectives.deprecation") %}
{% if not item in ("baybe.deprecation", "baybe.strategies.deprecation", "baybe.objectives.deprecation") %}
{{ item }}
{%- endif %}
{%- endfor %}
Expand Down
1 change: 0 additions & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ exclude = (?x)(
| baybe/exceptions.py
| baybe/scaler.py
| baybe/simulation.py
| baybe/surrogate.py
)

[mypy-gpytorch.*]
Expand Down
24 changes: 1 addition & 23 deletions tests/test_deprecations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pytest

from baybe import BayBE, Campaign
from baybe import Campaign
from baybe.acquisition.base import AcquisitionFunction
from baybe.exceptions import DeprecationError
from baybe.objective import Objective as OldObjective
Expand All @@ -17,37 +17,16 @@
FPSRecommender,
RandomRecommender,
)
from baybe.searchspace import SearchSpace
from baybe.strategies import (
SequentialStrategy,
Strategy,
StreamingSequentialStrategy,
TwoPhaseStrategy,
)
from baybe.targets import Objective as ObjectiveFromTargets
from baybe.targets.base import Target
from baybe.targets.numerical import NumericalTarget
from baybe.utils.interval import Interval


def test_deprecated_baybe_class(parameters, objective):
"""Using the deprecated ``BayBE`` class raises a warning."""
with pytest.warns(DeprecationWarning):
BayBE(SearchSpace.from_product(parameters), objective)


def test_moved_objective(targets):
"""Importing ``Objective`` from ``baybe.targets`` raises a warning."""
with pytest.warns(DeprecationWarning):
ObjectiveFromTargets(mode="SINGLE", targets=targets)


def test_renamed_surrogate():
"""Importing from ``baybe.surrogate`` raises a warning."""
with pytest.warns(DeprecationWarning):
from baybe.surrogate import GaussianProcessSurrogate # noqa: F401


def test_missing_recommender_type(config):
"""Specifying a recommender without a corresponding type raises a warning."""
dict_ = json.loads(config)
Expand All @@ -65,7 +44,6 @@ def test_missing_recommender_type(config):
@pytest.mark.parametrize(
"test_objects",
[
(Strategy, {}),
(TwoPhaseStrategy, {}),
(SequentialStrategy, {"recommenders": RECOMMENDERS}),
(StreamingSequentialStrategy, {"recommenders": RECOMMENDERS}),
Expand Down

0 comments on commit 4f0cb62

Please sign in to comment.