Skip to content

Commit

Permalink
Fix run_dialog second progress bar hanging
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jonathan-eq committed Oct 25, 2024
1 parent 74e401e commit f58cd22
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/ert/gui/simulation/run_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
31 changes: 23 additions & 8 deletions src/ert/gui/simulation/view/progress_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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()

Expand All @@ -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()
1 change: 1 addition & 0 deletions tests/ert/ui_tests/gui/test_missing_runpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit f58cd22

Please sign in to comment.