Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test for dask distributed example #110

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading