Coverage for mlos_bench/mlos_bench/run.py: 100%

14 statements  

« prev     ^ index     » next       coverage.py v7.5.1, created at 2024-05-05 00:36 +0000

1#!/usr/bin/env python3 

2# 

3# Copyright (c) Microsoft Corporation. 

4# Licensed under the MIT License. 

5# 

6""" 

7OS Autotune main optimization loop. 

8 

9Note: this script is also available as a CLI tool via pip under the name "mlos_bench". 

10 

11See `--help` output for details. 

12""" 

13 

14import logging 

15from typing import List, Optional, Tuple 

16 

17from mlos_bench.launcher import Launcher 

18from mlos_bench.tunables.tunable_groups import TunableGroups 

19 

20_LOG = logging.getLogger(__name__) 

21 

22 

23def _main(argv: Optional[List[str]] = None) -> Tuple[Optional[float], Optional[TunableGroups]]: 

24 

25 launcher = Launcher("mlos_bench", "Systems autotuning and benchmarking tool", argv=argv) 

26 

27 with launcher.scheduler as scheduler_context: 

28 scheduler_context.start() 

29 scheduler_context.teardown() 

30 

31 (score, _config) = result = launcher.scheduler.get_best_observation() 

32 # NOTE: This log line is used in test_launch_main_app_* unit tests: 

33 _LOG.info("Final score: %s", score) 

34 return result 

35 

36 

37if __name__ == "__main__": 

38 _main()