Play/pause update for mini GUI - #290
michaellans wants to merge 31 commits into
Conversation
…/close subprocess
… subprocess, extend condition on resume
MitchellAV
left a comment
There was a problem hiding this comment.
Wasn't able to find any issues during my limited testing in both -g and -mini graphics modes. I pulled in the latest changes from main and should have fixed the failing test (last github action run was hanging for some reason). I made some comments to look at.
Not blocking but...the entire PR does not have any type hints and will be adding more work on my end in #289. While not mandatory as part of the pre-commit hooks for the repo now, it will be in the future so might be worth getting used to when creating methods args and initializing variables.
| class BadgerActionBar(QWidget): | ||
| sig_start = pyqtSignal() | ||
| sig_start_until = pyqtSignal( | ||
| sig_start_until = pyqtSignal( # I think this is now deprecated |
There was a problem hiding this comment.
I think you are correct. There is no emit() for this signal any longer with the new rework of the action bar. This would also make def start_run_until() method in the BadgerHomePage class obsolete and should be removed along with it's connection in config_logic() method.
There was a problem hiding this comment.
Removed start_run_until and connected signals d149aa8
|
|
||
| # TODO: This is quite clunky, the run button (btn_stop) should really have | ||
| # its own class with action/signal/ui logic. | ||
| if self.mini_mode: |
There was a problem hiding this comment.
Both branches of this case statement should probably be refactored to handle the different display modes better, but it seems like you're aware of that with the separate widget comment. If you could at least separate out the common methods in both branches it would help with the clarity for now. Not blocking.
|
|
||
| def closeEvent(self, event): | ||
| self.save_config(self.configs) | ||
| # self.save_config(self.configs) |
There was a problem hiding this comment.
Should remove outdated code if no longer necessary
Thanks for the review, I've made a couple updates to fix the tests that were hanging and remove deprecated code. A lot of this did have type hints but I think I've now added them to all methods whose signatures have changed. Let me know how this looks. |
This PR features an update to the Badger mini run button behavior and routine subprocess and termination condition control flow, as well as an improvement to the variable range dialog window and a couple bug fixes.
Previously, every time the play button was pressed to start a run, a new routine_runner instance was initialized, which passed args to a new subprocess to run the optimization:
Badger/src/badger/gui/components/run_monitor.py
Line 470 in a59740f
Stopping a routine closed and terminated the subprocess:
Badger/src/badger/gui/components/routine_runner.py
Line 350 in a59740f
Updated Run Controls
This PR adds a new run controller class to replace the various run actions in the action bar and handle the logic for pause, resume, stop, and start based on the run_monitor state (is a subprocess active, is the optimization loop paused) and routine_page/env_cbox configuration (has anything changed, and are the current settings compatible with the displayed data).
Signals between the action_bar, run_controller, home_page, and run_monitor are all connected in the home_page config_logic method.
The run button menu options are updated from ["Run", "Run Until", and "Resume"] to ["New Run" and "Edit Condition"].
Handling Termination Conditions
Instead of being part of the start_run logic and enabled by passing a flag, this PR updates how the termination conditions are stored and applied to routines. The configured termination_condition is stored in the run_monitor (BadgerOptMonitor) class. The termination_condition gets passed in the args to each new routine, either as a dictionary with a configured number of iterations, time in seconds, and 'tc_idx' indicating which to use, or as 'None' to continue until manually stopped.
The termination_condition is extended from the current state each time an active routine is unpaused, so the behavior will be consistent as 'each time the play button is pressed, the routine will run for n iterations or n seconds' regardless of whether the optimization is resumed or restarted.
termination_control_queueto the subprocess. When an active but paused subprocess loop is unpaused, it checks this queue for an updated termination condition from the GUI, and either adds the specified number of seconds or iterations to it's current state before resuming, or clears it's condition if givenNoneas the new termination_condition.Other changes
Bug Fixes
Tests