From f58cd22f7946ef342d16ffbec8772e12b895ba9d Mon Sep 17 00:00:00 2001 From: Jonathan Karlsen Date: Fri, 11 Oct 2024 12:43:14 +0200 Subject: [PATCH] Fix run_dialog second progress bar hanging This commit fixes the issue where an immediate experiment failure would leave the second progress bar stuck in indeterminate state. The commit also makes the total progress bar turn red on immediate failures. --- src/ert/gui/simulation/run_dialog.py | 2 ++ .../gui/simulation/view/progress_widget.py | 31 ++++++++++++++----- .../ert/ui_tests/gui/test_missing_runpath.py | 1 + 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/ert/gui/simulation/run_dialog.py b/src/ert/gui/simulation/run_dialog.py index 4706693de94..fd193dcc07b 100644 --- a/src/ert/gui/simulation/run_dialog.py +++ b/src/ert/gui/simulation/run_dialog.py @@ -361,6 +361,7 @@ def closeEvent(self, a0: Optional[QCloseEvent]) -> None: def run_experiment(self, restart: bool = False) -> None: self._restart = restart + self._progress_widget.set_ensemble_running() if restart is False: self._snapshot_model.reset() self._tab_widget.clear() @@ -420,6 +421,7 @@ def _on_simulation_done(self, failed: bool, msg: str) -> None: self._notifier.set_is_simulation_running(False) if failed: self.update_total_progress(1.0, "Failed") + self._progress_widget.set_ensemble_failed() self.fail_msg_box = ErtMessageBox("ERT experiment failed!", msg, self) self.fail_msg_box.setModal(True) self.fail_msg_box.show() diff --git a/src/ert/gui/simulation/view/progress_widget.py b/src/ert/gui/simulation/view/progress_widget.py index 8596f6bacaa..e85d2db64ad 100644 --- a/src/ert/gui/simulation/view/progress_widget.py +++ b/src/ert/gui/simulation/view/progress_widget.py @@ -12,7 +12,7 @@ QWidget, ) -from ert.ensemble_evaluator.state import REAL_STATE_TO_COLOR +from ert.ensemble_evaluator.state import REAL_STATE_TO_COLOR, REALIZATION_STATE_FAILED class ProgressWidget(QFrame): @@ -72,6 +72,7 @@ def __init__(self) -> None: self._horizontal_legend_layout.addWidget(label) def repaint_components(self) -> None: + self._update_waiting_progress_bar() if self._realization_count > 0: full_width = self.width() @@ -89,17 +90,31 @@ def repaint_components(self) -> None: def stop_waiting_progress_bar(self) -> None: self._waiting_progress_bar.setVisible(False) - def start_waiting_progress_bar(self) -> None: - self._waiting_progress_bar.setVisible(True) - def update_progress(self, status: dict[str, int], realization_count: int) -> None: self._status = status self._realization_count = realization_count - if status.get("Finished", 0) < self._realization_count: - self.start_waiting_progress_bar() - else: - self.stop_waiting_progress_bar() self.repaint_components() + def _update_waiting_progress_bar(self) -> None: + self._waiting_progress_bar.setVisible( + self._status.get("Finished", 0) + self._status.get("Failed", 0) + < self._realization_count + ) + + def set_ensemble_failed(self) -> None: + self._reset_progress_labels() + + failed_label = self._progress_label_map[REALIZATION_STATE_FAILED] + failed_label.setFixedWidth(self.width()) + failed_label.setVisible(True) + self.stop_waiting_progress_bar() + + def set_ensemble_running(self) -> None: + self._reset_progress_labels() + + def _reset_progress_labels(self) -> None: + for label in self._progress_label_map.values(): + label.setVisible(False) + def resizeEvent(self, a0: Any, event: Any = None) -> None: self.repaint_components() diff --git a/tests/ert/ui_tests/gui/test_missing_runpath.py b/tests/ert/ui_tests/gui/test_missing_runpath.py index 4b7409cdb6a..d7e0cdb9541 100644 --- a/tests/ert/ui_tests/gui/test_missing_runpath.py +++ b/tests/ert/ui_tests/gui/test_missing_runpath.py @@ -83,6 +83,7 @@ def inner(): QLabel, name="progress_label_text_Finished" ).text() ) + assert not run_dialog._progress_widget._waiting_progress_bar.isVisible() assert ( "1/10" in run_dialog._progress_widget.findChild(