Skip to content
Closed
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
9 changes: 9 additions & 0 deletions ax/service/ax_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,15 @@ def __init__(
early_stopping_strategy: BaseEarlyStoppingStrategy | None = None,
global_stopping_strategy: BaseGlobalStoppingStrategy | None = None,
) -> None:
if self.__class__.__name__ in ["AxClient", "AxClientInternal"]:
warnings.warn(
"The `AxClient` class is deprecated and will be removed in Ax 1.4.0. "
"Please migrate to the modern Ax API / `Client` class, found under "
"ax/api. For example usage, check out the tutorials at https://ax.dev ",
DeprecationWarning,
stacklevel=2,
)

super().__init__(
db_settings=db_settings,
suppress_all_errors=suppress_storage_errors,
Expand Down
15 changes: 15 additions & 0 deletions ax/service/tests/test_ax_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import math
import sys
import time
import warnings
from itertools import product
from math import ceil
from typing import Any, TYPE_CHECKING
Expand Down Expand Up @@ -267,6 +268,20 @@ def get_client_with_simple_discrete_moo_problem(
class TestAxClient(TestCase):
"""Tests service-like API functionality."""

def test_deprecation_warning(self) -> None:
# Should warn for AxClient but not for arbitrary subclasses.
with self.assertWarnsRegex(
DeprecationWarning, "`AxClient` class is deprecated and will be removed"
):
AxClient()

class TestAxClient(AxClient):
pass

with warnings.catch_warnings(record=True) as ws:
TestAxClient()
self.assertEqual(len(ws), 0)

@mock_botorch_optimize
def test_interruption(self) -> None:
ax_client = AxClient()
Expand Down