Coverage for mlos_bench/mlos_bench/schedulers/sync_scheduler.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.9.2, created at 2025-07-14 00:55 +0000

1# 

2# Copyright (c) Microsoft Corporation. 

3# Licensed under the MIT License. 

4# 

5"""A simple single-threaded synchronous optimization loop implementation.""" 

6 

7import logging 

8 

9from mlos_bench.schedulers.base_scheduler import Scheduler 

10from mlos_bench.storage.base_storage import Storage 

11 

12_LOG = logging.getLogger(__name__) 

13 

14 

15class SyncScheduler(Scheduler): 

16 """A simple single-threaded synchronous optimization loop implementation.""" 

17 

18 def run_trial(self, trial: Storage.Trial) -> None: 

19 """ 

20 Set up and run a single :py:class:`~.Storage.Trial` on its 

21 :py:class:`~.TrialRunner`. 

22 

23 Save the results in the storage. 

24 """ 

25 super().run_trial(trial) 

26 # In the sync scheduler we run each trial on its own TrialRunner in sequence. 

27 trial_runner = self.get_trial_runner(trial) 

28 with trial_runner: 

29 trial_runner.run_trial(trial, self.global_config) 

30 _LOG.info("QUEUE: Finished trial: %s on %s", trial, trial_runner)