Coverage for mlos_bench/mlos_bench/tests/config/globals/test_load_global_config_examples.py: 100%
16 statements
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-21 01:50 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-21 01:50 +0000
1#
2# Copyright (c) Microsoft Corporation.
3# Licensed under the MIT License.
4#
5"""Tests for loading globals config examples."""
6import logging
8import pytest
10from mlos_bench.config.schemas import ConfigSchema
11from mlos_bench.services.config_persistence import ConfigPersistenceService
12from mlos_bench.tests.config import BUILTIN_TEST_CONFIG_PATH, locate_config_examples
14_LOG = logging.getLogger(__name__)
15_LOG.setLevel(logging.DEBUG)
18# Get the set of configs to test.
19CONFIG_TYPE = "globals"
22def filter_configs(configs_to_filter: list[str]) -> list[str]:
23 """If necessary, filter out json files that aren't for the module we're testing."""
24 return configs_to_filter
27configs = [
28 # *locate_config_examples(
29 # ConfigPersistenceService.BUILTIN_CONFIG_PATH,
30 # CONFIG_TYPE,
31 # filter_configs,
32 # ),
33 *locate_config_examples(
34 ConfigPersistenceService.BUILTIN_CONFIG_PATH,
35 "experiments",
36 filter_configs,
37 ),
38 *locate_config_examples(
39 BUILTIN_TEST_CONFIG_PATH,
40 CONFIG_TYPE,
41 filter_configs,
42 ),
43 *locate_config_examples(
44 BUILTIN_TEST_CONFIG_PATH,
45 "experiments",
46 filter_configs,
47 ),
48]
49assert configs
52@pytest.mark.parametrize("config_path", configs)
53def test_load_globals_config_examples(
54 config_loader_service: ConfigPersistenceService,
55 config_path: str,
56) -> None:
57 """Tests loading a config example."""
58 config = config_loader_service.load_config(config_path, ConfigSchema.GLOBALS)
59 assert isinstance(config, dict)