|
26 | 26 | from ax.core.generator_run import GeneratorRun |
27 | 27 | from ax.core.metric import Metric |
28 | 28 | from ax.core.multi_type_experiment import MultiTypeExperiment |
29 | | -from ax.core.objective import MultiObjective, Objective |
30 | | -from ax.core.optimization_config import ( |
31 | | - MultiObjectiveOptimizationConfig, |
32 | | - OptimizationConfig, |
33 | | -) |
| 29 | +from ax.core.objective import MultiObjective |
| 30 | +from ax.core.optimization_config import MultiObjectiveOptimizationConfig |
34 | 31 | from ax.core.outcome_constraint import ObjectiveThreshold, OutcomeConstraint |
35 | 32 | from ax.core.parameter import ( |
36 | 33 | ChoiceParameter, |
@@ -493,8 +490,6 @@ def test_default_generation_strategy_continuous(self) -> None: |
493 | 490 | ], |
494 | 491 | [Generators.SOBOL, Generators.BOTORCH_MODULAR], |
495 | 492 | ) |
496 | | - with self.assertRaisesRegex(ValueError, ".* no trials"): |
497 | | - ax_client.get_optimization_trace(objective_optimum=branin.fmin) |
498 | 493 | for i in range(6): |
499 | 494 | gen_limit, opt_complete = ax_client.get_current_trial_generation_limit() |
500 | 495 | self.assertFalse(opt_complete) |
@@ -522,7 +517,6 @@ def test_default_generation_strategy_continuous(self) -> None: |
522 | 517 | self.assertEqual( |
523 | 518 | none_throws(ax_client.generation_strategy.adapter)._generator_key, "BoTorch" |
524 | 519 | ) |
525 | | - ax_client.get_optimization_trace(objective_optimum=branin.fmin) |
526 | 520 | ax_client.get_contour_plot() |
527 | 521 | trials_df = ax_client.get_trials_data_frame() |
528 | 522 | self.assertIn("x", trials_df) |
@@ -690,8 +684,6 @@ def test_default_generation_strategy_continuous_for_moo(self) -> None: |
690 | 684 | ], |
691 | 685 | [Generators.SOBOL, Generators.BOTORCH_MODULAR], |
692 | 686 | ) |
693 | | - with self.assertRaisesRegex(ValueError, ".* no trials"): |
694 | | - ax_client.get_optimization_trace(objective_optimum=branin.fmin) |
695 | 687 | for i in range(6): |
696 | 688 | with mock.patch("ax.service.ax_client.logger.info") as mock_log: |
697 | 689 | parameterization, trial_index = ax_client.get_next_trial() |
@@ -739,10 +731,6 @@ def test_default_generation_strategy_continuous_for_moo(self) -> None: |
739 | 731 | self.assertIn("b", trials_df) |
740 | 732 | self.assertEqual(len(trials_df), 6) |
741 | 733 |
|
742 | | - with self.subTest("it raises UnsupportedError for get_optimization_trace"): |
743 | | - with self.assertRaises(UnsupportedError): |
744 | | - ax_client.get_optimization_trace(objective_optimum=branin.fmin) |
745 | | - |
746 | 734 | with self.subTest( |
747 | 735 | "it raises UnsupportedError for get_contour_plot without metric" |
748 | 736 | ): |
@@ -3641,49 +3629,6 @@ def test_with_node_based_gs(self) -> None: |
3641 | 3629 | )._generator_key, |
3642 | 3630 | "Sobol", |
3643 | 3631 | ) |
3644 | | - with mock.patch( |
3645 | | - "ax.service.ax_client.optimization_trace_single_method" |
3646 | | - ) as mock_plot: |
3647 | | - ax_client.get_optimization_trace() |
3648 | | - mock_plot.assert_called_once() |
3649 | | - |
3650 | | - def test_get_optimization_trace_scalarized(self) -> None: |
3651 | | - """get_optimization_trace raises UnsupportedError for scalarized.""" |
3652 | | - ax_client = get_branin_optimization() |
3653 | | - params, idx = ax_client.get_next_trial() |
3654 | | - ax_client.complete_trial(trial_index=idx, raw_data={"branin": (1.0, 0.0)}) |
3655 | | - ax_client.experiment.add_tracking_metric(Metric(name="other_metric")) |
3656 | | - ax_client.experiment._optimization_config = OptimizationConfig( |
3657 | | - objective=Objective( |
3658 | | - expression="2*branin + -1*other_metric", |
3659 | | - metric_name_to_signature={ |
3660 | | - "branin": "branin", |
3661 | | - "other_metric": "other_metric", |
3662 | | - }, |
3663 | | - ), |
3664 | | - ) |
3665 | | - with self.assertRaisesRegex(UnsupportedError, "not supported for scalarized"): |
3666 | | - ax_client.get_optimization_trace() |
3667 | | - |
3668 | | - def test_get_optimization_trace_scalarized_outcome_constraint(self) -> None: |
3669 | | - """get_optimization_trace raises UnsupportedError for scalarized |
3670 | | - outcome constraints.""" |
3671 | | - ax_client = get_branin_optimization() |
3672 | | - params, idx = ax_client.get_next_trial() |
3673 | | - ax_client.complete_trial(trial_index=idx, raw_data={"branin": (1.0, 0.0)}) |
3674 | | - ax_client.experiment.add_tracking_metric(Metric(name="m1")) |
3675 | | - ax_client.experiment.add_tracking_metric(Metric(name="m2")) |
3676 | | - ax_client.experiment._optimization_config = OptimizationConfig( |
3677 | | - objective=Objective(metric=Metric(name="branin"), minimize=True), |
3678 | | - outcome_constraints=[ |
3679 | | - OutcomeConstraint( |
3680 | | - expression="2*m1 + 3*m2 <= 10", |
3681 | | - metric_name_to_signature={"m1": "m1", "m2": "m2"}, |
3682 | | - ), |
3683 | | - ], |
3684 | | - ) |
3685 | | - with self.assertRaisesRegex(UnsupportedError, "not supported for scalarized"): |
3686 | | - ax_client.get_optimization_trace() |
3687 | 3632 |
|
3688 | 3633 |
|
3689 | 3634 | # Utility functions for testing get_model_predictions without calling |
|
0 commit comments