Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ax/adapter/pairwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
from typing import Any

from ax.adapter.torch import TorchAdapter
from ax.exceptions.core import DeprecationError


# PairwiseAdapter was deprecated in Ax 1.1.0, so it should be reaped in Ax
# 1.2.0+
class PairwiseAdapter(TorchAdapter):
def __init__(self, **kwargs: Any) -> None:
raise DeprecationWarning(
raise DeprecationError(
"PairwiseAdapter is deprecated. Use TorchAdapter instead."
)
9 changes: 7 additions & 2 deletions ax/core/batch_trial.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
TEvaluationOutcome,
validate_evaluation_outcome,
)
from ax.exceptions.core import AxError, UnsupportedError, UserInputError
from ax.exceptions.core import (
AxError,
DeprecationError,
UnsupportedError,
UserInputError,
)
from ax.utils.common.base import SortableBase
from ax.utils.common.docutils import copy_doc
from ax.utils.common.equality import datetime_equals, equality_typechecker
Expand Down Expand Up @@ -183,7 +188,7 @@ def arm_weights(self) -> MutableMapping[Arm, float]:

@property
def _status_quo_weight_override(self) -> None:
raise DeprecationWarning(
raise DeprecationError(
"Status quo weight override is no longer supported. Please "
"contact the Ax developers for help adjusting your application."
)
Expand Down
16 changes: 16 additions & 0 deletions ax/exceptions/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@ class UnsupportedError(AxError):
"""


class DeprecationError(AxError):
"""Raised when deprecated functionality is accessed as a hard break.

Use this for deprecations that have reached the point of removal, where
accessing the deprecated API (e.g. reading a removed property) should fail
immediately with an actionable message rather than silently returning a
wrong value. Prefer this over ``raise DeprecationWarning(...)``:
``DeprecationWarning`` is a warning *category*, not an exception type, so
raising it is semantically incorrect and is not suppressible via
``warnings.simplefilter("ignore", DeprecationWarning)``.

For *soft* deprecations that should still work (just with a notice), use
``warnings.warn(..., DeprecationWarning)`` instead of this error.
"""


class UnsupportedPlotError(AxError):
"""Raised when plotting functionality is not supported for the
given configurations.
Expand Down
4 changes: 3 additions & 1 deletion ax/service/utils/scheduler_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
# Scheduler was deprecated in Ax 1.1.0, so it should be removed in Ax
# Ax 1.2.0+.

from ax.exceptions.core import DeprecationError


class SchedulerOptions:
raise DeprecationWarning(
raise DeprecationError(
"Scheduler is deprecated following renaming of the Scheduler to "
"Orchestrator. Please use Orchestrator and OrchestratorOptions instead; "
"import with: `from ax.orchestration.orchestrator import Orchestrator, "
Expand Down
Loading