Skip to content

Commit

Permalink
Downgrade error to beta-warning for gs selection in AxClient
Browse files Browse the repository at this point in the history
Summary:
Previously we added this error in D56048665 in response to a github issue, however now that we are adding support for GenerationStrategy selection for BatchTrials this can be a warning that this method is in development.

In the future we should be able to fully remove the method

Differential Revision: D59143308
  • Loading branch information
mgarrard authored and facebook-github-bot committed Jun 28, 2024
1 parent ff1445a commit cf2f195
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
6 changes: 3 additions & 3 deletions ax/service/ax_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1732,9 +1732,9 @@ def _set_generation_strategy(
"use_batch_trials" in choose_generation_strategy_kwargs
and type(self) is AxClient
):
raise UnsupportedError(
"AxClient API does not support batch trials yet."
" We plan to add this support in coming versions."
logger.warning(
"Selecting a GenerationStrategy when using BatchTrials is in beta. "
"Double check the recommended strategy matches your expectations."
)
random_seed = choose_generation_strategy_kwargs.pop(
"random_seed", self._random_seed
Expand Down
16 changes: 11 additions & 5 deletions ax/telemetry/tests/test_ax_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

# pyre-strict

import logging
from logging import Logger
from typing import Dict, List, Sequence, Union

import numpy as np
Expand All @@ -16,8 +18,11 @@
from ax.telemetry.ax_client import AxClientCompletedRecord, AxClientCreatedRecord
from ax.telemetry.experiment import ExperimentCompletedRecord, ExperimentCreatedRecord
from ax.telemetry.generation_strategy import GenerationStrategyCreatedRecord
from ax.utils.common.logger import get_logger
from ax.utils.common.testutils import TestCase

logger: Logger = get_logger(__name__)


class TestAxClient(TestCase):
def test_ax_client_created_record_from_ax_client(self) -> None:
Expand Down Expand Up @@ -133,11 +138,8 @@ def test_ax_client_completed_record_from_ax_client(self) -> None:

def test_batch_trial_warning(self) -> None:
ax_client = AxClient()
error_msg = (
"AxClient API does not support batch trials yet."
" We plan to add this support in coming versions."
)
with self.assertRaisesRegex(UnsupportedError, error_msg):
warning_msg = "GenerationStrategy when using BatchTrials is in beta."
with self.assertLogs(AxClient.__module__, logging.WARNING) as logger:
ax_client.create_experiment(
name="test_experiment",
parameters=[
Expand All @@ -149,6 +151,10 @@ def test_batch_trial_warning(self) -> None:
"use_batch_trials": True,
},
)
self.assertTrue(
any(warning_msg in output for output in logger.output),
logger.output,
)

def _compare_axclient_completed_records(
self, record: AxClientCompletedRecord, expected: AxClientCompletedRecord
Expand Down

0 comments on commit cf2f195

Please sign in to comment.