Skip to content

Commit cc7a094

Browse files
mpolson64facebook-github-bot
authored andcommitted
Move choose_generation_strategy from ax.preview.modelbridge to ax.preview.api
Summary: We need to move the new dispatch logic out of ax.preview in preparation for promoting the api module out of ax.preview. There are a number of things to take into consideration while making this move, including: * Keeping the api module a top level import and not importing it from anywhere else in the Ax codebase * Continuing to allow choose_generation_strategy to accept a GenerationStrategyConfig rather than all the options and flags individually After some consideration, the most natural place for this is inside the api.utils module. This is where the other functions that consume Configs and produce Ax objects live. Differential Revision: D70732507
1 parent 9ea7e78 commit cc7a094

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

ax/preview/api/client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@
4545
from ax.preview.api.protocols.metric import IMetric
4646
from ax.preview.api.protocols.runner import IRunner
4747
from ax.preview.api.types import TOutcome, TParameterization
48+
from ax.preview.api.utils.generation_strategy_dispatch import choose_generation_strategy
4849
from ax.preview.api.utils.instantiation.from_config import experiment_from_config
4950
from ax.preview.api.utils.instantiation.from_string import (
5051
optimization_config_from_string,
5152
)
5253
from ax.preview.api.utils.storage import db_settings_from_storage_config
53-
from ax.preview.modelbridge.dispatch_utils import choose_generation_strategy
5454
from ax.service.scheduler import Scheduler, SchedulerOptions
5555
from ax.service.utils.best_point_mixin import BestPointMixin
5656
from ax.service.utils.with_db_settings_base import WithDBSettingsBase

ax/preview/modelbridge/dispatch_utils.py ax/preview/api/utils/generation_strategy_dispatch.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
# This source code is licensed under the MIT license found in the
55
# LICENSE file in the root directory of this source tree.
66

7-
# pyre-unsafe
7+
# pyre-strict
8+
89

910
import torch
1011
from ax.core.trial_status import TrialStatus
@@ -131,8 +132,9 @@ def _get_mbm_node(
131132
def choose_generation_strategy(
132133
gs_config: GenerationStrategyConfig,
133134
) -> GenerationStrategy:
134-
"""Choose a generation strategy based on the properties of the experiment
135-
and the inputs provided in ``gs_config``.
135+
"""
136+
Choose a generation strategy based on the properties of the experiment and the
137+
inputs provided in ``gs_config``.
136138
137139
NOTE: The behavior of this function is subject to change. It will be updated to
138140
produce best general purpose generation strategies based on benchmarking results.

ax/preview/modelbridge/tests/test_preview_dispatch_utils.py ax/preview/api/utils/tests/test_generation_strategy_dispatch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from ax.modelbridge.registry import Generators
1313
from ax.models.torch.botorch_modular.surrogate import ModelConfig, SurrogateSpec
1414
from ax.preview.api.configs import GenerationMethod, GenerationStrategyConfig
15-
from ax.preview.modelbridge.dispatch_utils import choose_generation_strategy
15+
from ax.preview.api.utils.generation_strategy_dispatch import choose_generation_strategy
1616
from ax.utils.common.testutils import TestCase
1717
from ax.utils.testing.core_stubs import (
1818
get_branin_experiment,

ax/preview/modelbridge/__init__.py

-5
This file was deleted.

0 commit comments

Comments
 (0)