Skip to content

Enhance mini GUI run controls - #288

Draft
michaellans wants to merge 37 commits into
xopt-org:mainfrom
michaellans:smart_run2
Draft

michaellans wants to merge 37 commits into
xopt-org:mainfrom
michaellans:smart_run2

Conversation

@michaellans

@michaellans michaellans commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

This PR build on #281 to improve play/pause/resume behavior for running optimizations in Badger. This is done by introducing a 'smart run' mode, which checks the state of the GUI when the play button is pressed against the currently displayed data and determines whether to resume, restart, or load the data and continue based on which parameters have changed. This allows you to pause a routine, resume, change variable ranges or update algorithm parameters and load the data and continue, or switch to new variables and restart with a single play button.

Note that this PR is built on the same branch/commit history as #281, the new changes here start after 76e72eb

Smart Run Controls

'Smart Run' mode handles play/pause/resume/restart.

  • Added SmartRunController class to centralize logic for play, pause, resume, restart, and stop behavior, and separate the logic from the UI.
    • Pressing the play button will pause an actively running routine
    • Pressing play again will then get a snapshot of the current GUI parameters and run_monitor state and trigger the following logic:
      • If the snapshot is identical to the displayed routine: unpause and continue
      • If parameters have changed but are still compatible with the displayed data: stop the active routine, load in the data, and restart to continue the optimization with the new parameters.
      • If variables or objectives have changed and displayed data is no longer compatible: stop the current routine, and restart a new routine with the selected parameters
  • If a routine is active and needs to restart, the run controller will emit a 'stop' signal and set a _pending_restart flag, and will then start the new routine and reset the flag after it receives a 'routine_finished' signal
  • Added Smart Run and Stop Run actions to the mini GUI run-options menu. Renamed menu option "Run" to "Run (restart)" for clarity
  • Removed the old pause button
  • Updated button availability and behavior while paused to allow 'reset' and 'dial in'.
  • SmartRunController includes a restart_override_flag which is set after actions which can change the machine state and variable values: reset environment, selecting a routine from the run history, and dialing in a solution. The flag is also set when selecting a template. For any of these cases, selecting "resume" from the run options menu will still load the data and continue, but the automatic behavior will be to restart without data.

Stopping runs and Termination handling

  • Extracted termination-condition checks into a dedicated method from within the subprocess optimization loop
  • Update GUI status bar with n_iterations/total while routine is running
  • With 'smart run' the GUI pauses rather than stops an active routine. This means the subprocess is still active. Added a paused field to BadgerOptMonitor to distinguished between running and paused subprocess states. The subprocess is then stopped and restarted when a routine restarts.
  • Updated window close behavior to ensure active subprocesses are stopped and cleaned up during window shutdown
  • Fixed pre-existing bug which could cause GUI to freeze when closing the application during a paused or running routine.

Data Loading and Routine State

  • Refactored data compatibility checks in mini/pages/home_page.py for better clarity, extracting loaded_data_keys_compatible to be a bool true/false check.
  • Enabled loading routine data for sequential generators and removed error message when trying to load data with neldermead as selected algorithm

Added/updated tests

  • Added tests covering the new run controller behavior.
  • Updated pause/play tests for the revised control flow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant