Skip to content

Commit

Permalink
add test for dask distributed example
Browse files Browse the repository at this point in the history
Signed-off-by: Grossberger Lukas (CR/AIR2.2) <Lukas.Grossberger@de.bosch.com>
  • Loading branch information
LGro committed Jun 5, 2023
1 parent 906c5a7 commit 4dfa0c1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 5 additions & 1 deletion blackboxopt/examples/dask_distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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()
8 changes: 5 additions & 3 deletions tests/examples_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 4dfa0c1

Please sign in to comment.