Coverage for mlos_bench/mlos_bench/tests/launcher_in_process_test.py: 100%
8 statements
« prev ^ index » next coverage.py v7.5.1, created at 2024-05-06 00:35 +0000
« prev ^ index » next coverage.py v7.5.1, created at 2024-05-06 00:35 +0000
1#
2# Copyright (c) Microsoft Corporation.
3# Licensed under the MIT License.
4#
5"""
6Unit tests to check the launcher and the main optimization loop in-process.
7"""
9from typing import List
11import pytest
13from mlos_bench.run import _main
16@pytest.mark.parametrize(
17 ("argv", "expected_score"), [
18 ([
19 "--config", "mlos_bench/mlos_bench/tests/config/cli/mock-bench.jsonc",
20 ], 65.6742),
21 ([
22 "--config", "mlos_bench/mlos_bench/tests/config/cli/mock-opt.jsonc",
23 "--trial_config_repeat_count", "3",
24 "--max_suggestions", "3",
25 ], 64.53897),
26 ]
27)
28def test_main_bench(argv: List[str], expected_score: float) -> None:
29 """
30 Run mlos_bench optimization loop with given config and check the results.
31 """
32 (score, _config) = _main(argv)
33 assert pytest.approx(score, 1e-6) == expected_score