diff --git a/blackboxopt/examples/dask_distributed.py b/blackboxopt/examples/dask_distributed.py index aa0a8a8..65c745c 100644 --- a/blackboxopt/examples/dask_distributed.py +++ b/blackboxopt/examples/dask_distributed.py @@ -27,7 +27,7 @@ def evaluation_function(eval_spec: EvaluationSpecification) -> Evaluation: ) -if __name__ == "__main__": +def main(): space = ps.ParameterSpace() space.add(ps.ContinuousParameter("p1", (-1.0, 1.0))) optimizer = RandomSearch( @@ -42,3 +42,7 @@ def evaluation_function(eval_spec: EvaluationSpecification) -> Evaluation: n_successes = len([e for e in evaluations if not e.all_objectives_none]) print(f"Successfully evaluated {n_successes}/{len(evaluations)}") + + +if __name__ == "__main__": + main() diff --git a/tests/examples_test.py b/tests/examples_test.py index 423e76c..2cab18e 100644 --- a/tests/examples_test.py +++ b/tests/examples_test.py @@ -2,11 +2,12 @@ import pytest -from blackboxopt.examples import multi_objective_multi_param +from blackboxopt.examples import dask_distributed, multi_objective_multi_param -@pytest.mark.parametrize("example_module", [multi_objective_multi_param]) -@pytest.mark.integration_test +@pytest.mark.parametrize( + "example_module", [multi_objective_multi_param, dask_distributed] +) def test_full_loop_examples(tmp_path, monkeypatch, example_module): if not example_module: return @@ -17,6 +18,7 @@ def test_full_loop_examples(tmp_path, monkeypatch, example_module): def run_sequential_mocked(*args, **kwargs): kwargs["timeout_s"] = 5 + kwargs["max_evaluations"] = None return run_sequential(*args, **kwargs) monkeypatch.setattr(example_module, "run_optimization_loop", run_sequential_mocked)