Rename and reorganize some Scheduler methods#975
Merged
motus merged 11 commits intomicrosoft:mainfrom May 12, 2025
Merged
Conversation
…r some reuse by ParallelTrialScheduler
This was referenced May 9, 2025
for more information, see https://pre-commit.ci
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the Scheduler methods to improve clarity and support the upcoming ParallelScheduler changes. Key changes include renaming methods (e.g., schedule_trial to add_trial_to_queue), moving common functionality into the base class, and subtly updating trial filtering logic in pending_trials.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| mlos_bench/tests/storage/trial_schedule_test.py | Added tests for the new trial_runner_assigned parameter in pending_trials |
| mlos_bench/storage/sql/experiment.py | Updated pending_trials to support optional filtering based on trial runner status |
| mlos_bench/storage/base_storage.py | Revised interface of pending_trials with new optional trial_runner_assigned flag |
| mlos_bench/schedulers/trial_runner.py | Modified run_trial to return a tuple containing status, timestamp, and results |
| mlos_bench/schedulers/sync_scheduler.py | Removed redundant start method implementation |
| mlos_bench/schedulers/base_scheduler.py | Renamed methods and restructured the scheduling loop |
| .vscode/settings.json | Adjusted VS Code settings for import organization |
Comments suppressed due to low confidence (2)
mlos_bench/mlos_bench/schedulers/trial_runner.py:171
- The docstring for run_trial does not reflect its updated return type. Please update the documentation to specify that the function returns a tuple with (Status, datetime, dict[str, TunableValue] | None).
def run_trial(self, trial: Storage.Trial, global_config: dict[str, Any] | None = None) -> tuple[Status, datetime, dict[str, TunableValue] | None]:
mlos_bench/mlos_bench/schedulers/base_scheduler.py:523
- Since pending_trials is filtered using trial_runner_assigned=True, the following check for trial.trial_runner_id being None might be redundant. Please verify that this extra safeguard is intended and necessary.
if trial.trial_runner_id is None:
bpkroth
commented
May 10, 2025
bpkroth
commented
May 10, 2025
bpkroth
commented
May 10, 2025
bpkroth
commented
May 10, 2025
bpkroth
commented
May 12, 2025
motus
approved these changes
May 12, 2025
Member
motus
left a comment
There was a problem hiding this comment.
Looks very nice and clean! Thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Title
Rename and reorganize some Scheduler methods
Description
In preparation for ParallelScheduler PR (#971) this PR
schedule_trial-->add_trial_to_queue) so that the role of other methods (e.g.,assign_trial_runners) is more clear and readily overridable.This is done based on an observation that some of the methods (e.g., the main
startloop) are largely reusable across both SyncScheduler and ParallelScheduler if the method separation is done a little bit more fine grained such that each can override the only the parts they need to.Additionall, it also
pending_trialsmethod in order to filter based on whether or not the trial already has a runner assigned or not.TrialRunner.run_trialto return the results of the Trial.This isn't really used anywhere, but it is helpful to check that TrialRunners run in a child process finished successfully by using that result as a check in the return value, even though for Optimizer bulk_registering it actually pulls the results back off of Storage in the MainProcess.
Type of Change
Testing
pending_trialsAdditional Notes (optional)