Skip to content

Commit

Permalink
Fix issue where progress_widget was indeterminate on fail
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindjahren committed Oct 28, 2024
1 parent 18c5d81 commit 35415b9
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/ert/gui/simulation/run_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,9 @@ 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_all_failed()

self.fail_msg_box = ErtMessageBox("ERT experiment failed!", msg, self)
self.fail_msg_box.setModal(True)
self.fail_msg_box.show()
Expand Down
10 changes: 9 additions & 1 deletion 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 ENSEMBLE_STATE_FAILED, REAL_STATE_TO_COLOR


class ProgressWidget(QFrame):
Expand Down Expand Up @@ -93,6 +93,14 @@ def stop_waiting_progress_bar(self) -> None:
def start_waiting_progress_bar(self) -> None:
self._waiting_progress_bar.setVisible(True)

def set_all_failed(self) -> None:
self.stop_waiting_progress_bar()
full_width = self.width()
for state, label in self._progress_label_map.items():
label.setVisible(True)
width = full_width if state == ENSEMBLE_STATE_FAILED else 0
label.setFixedWidth(width)

def update_progress(self, status: dict[str, int], realization_count: int) -> None:
self._status = status
self._realization_count = realization_count
Expand Down
50 changes: 50 additions & 0 deletions tests/ert/ui_tests/gui/test_missing_runpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
QLabel,
)

from ert.ensemble_evaluator.state import ENSEMBLE_STATE_FAILED
from ert.gui.simulation.run_dialog import RunDialog
from ert.run_models import EnsembleExperiment

Expand Down Expand Up @@ -95,3 +96,52 @@ def inner():
finally:
with suppress(FileNotFoundError):
(tmp_path / "simulations/realization-0/iter-0").chmod(0x777)


def test_missing_runpath_does_not_show_waiting_bar(
tmp_path, run_experiment, qtbot, monkeypatch
):
"""
This is a regression test for the gui showing waiting progress bar on ensemble failure
"""
monkeypatch.chdir(tmp_path)
write_config(tmp_path, "LOCAL")
run_path = tmp_path / "simulations"
run_path.mkdir()
run_path.chmod(0x444)

def handle_message_box(dialog):
def inner():
qtbot.waitUntil(
lambda: dialog.fail_msg_box is not None,
timeout=20000,
)

message_box = dialog.fail_msg_box
assert message_box is not None
assert message_box.label_text.text() == "ERT experiment failed!"
message_box.accept()

return inner

try:
for gui in open_gui_with_config(tmp_path / "config.ert"):
qtbot.addWidget(gui)
run_experiment(EnsembleExperiment, gui, click_done=False)
run_dialog = wait_for_child(gui, qtbot, RunDialog, timeout=10000)

QTimer.singleShot(100, handle_message_box(run_dialog))
qtbot.waitUntil(
lambda dialog=run_dialog: dialog.is_simulation_done() == True,
timeout=200000,
)
assert not run_dialog._progress_widget._waiting_progress_bar.isVisible()
assert (
run_dialog._progress_widget._progress_label_map[
ENSEMBLE_STATE_FAILED
].width()
== run_dialog._progress_widget.width()
)
finally:
with suppress(FileNotFoundError):
(tmp_path / "simulations").chmod(0x777)

0 comments on commit 35415b9

Please sign in to comment.