def test_recommended_parallelism(self): ax_client = AxClient() with self.assertRaisesRegex(ValueError, "No generation strategy"): ax_client.get_max_parallelism() ax_client.create_experiment( parameters=[ {"name": "x", "type": "range", "bounds": [-5.0, 10.0]}, {"name": "y", "type": "range", "bounds": [0.0, 15.0]}, ], minimize=True, ) self.assertEqual(ax_client.get_max_parallelism(), [(5, 5), (-1, 3)]) self.assertEqual( run_trials_using_recommended_parallelism( ax_client, ax_client.get_max_parallelism(), 20 ), 0, ) # With incorrect parallelism setting, the 'need more data' error should # still be raised. ax_client = AxClient() ax_client.create_experiment( parameters=[ {"name": "x", "type": "range", "bounds": [-5.0, 10.0]}, {"name": "y", "type": "range", "bounds": [0.0, 15.0]}, ], minimize=True, ) with self.assertRaisesRegex(DataRequiredError, "All trials for current model "): run_trials_using_recommended_parallelism(ax_client, [(6, 6), (-1, 3)], 20)
def test_default_generation_strategy_discrete(self) -> None: """Test that Sobol is used if no GenerationStrategy is provided and the search space is discrete. """ # Test that Sobol is chosen when all parameters are choice. ax_client = AxClient() ax_client.create_experiment( parameters=[ # pyre-fixme[6]: expected union that should include { "name": "x", "type": "choice", "values": [1, 2, 3] }, { "name": "y", "type": "choice", "values": [1, 2, 3] }, ]) self.assertEqual( [s.model for s in not_none(ax_client.generation_strategy)._steps], [Models.SOBOL], ) self.assertEqual(ax_client.get_max_parallelism(), [(-1, -1)]) self.assertTrue(ax_client.get_trials_data_frame().empty)