Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport bugfixes gui to 12 #9478

Merged
merged 3 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/ert/gui/simulation/multiple_data_assimilation_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ def __init__(
self._active_realizations_model, # type: ignore
"config/simulation/active_realizations",
)
self._active_realizations_field.setObjectName("active_realizations_box")
self._active_realizations_field.setValidator(RangeStringArgument(ensemble_size))
self._ensemble_selector = EnsembleSelector(notifier)
self._realizations_from_fs()
layout.addRow("Active realizations:", self._active_realizations_field)

self._restart_box = QCheckBox("")
Expand All @@ -114,6 +114,7 @@ def __init__(
self._restart_box.toggled.connect(self.update_experiment_edit)

self._restart_box.setEnabled(bool(self._ensemble_selector._ensemble_list()))
self._ensemble_selector.setEnabled(False)
layout.addRow("Restart run:", self._restart_box)

self._ensemble_selector.ensemble_populated.connect(self.restart_run_toggled)
Expand Down Expand Up @@ -189,6 +190,11 @@ def restart_run_toggled(self) -> None:
if self._restart_box.isChecked()
else MultipleDataAssimilation.default_weights
)
if self._restart_box.isChecked():
self._realizations_from_fs()
else:
# If box is unchecked we reset to the default mask
self._active_realizations_field.model.setValue(value="")

def _createInputForWeights(self, layout: QFormLayout) -> None:
relative_iteration_weights_model = ValueModel(self.weights)
Expand Down
1 change: 1 addition & 0 deletions src/ert/gui/simulation/run_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ def on_snapshot_new_iteration(

widget = RealizationWidget(iter_row)
widget.setSnapshotModel(self._snapshot_model)
widget.itemClicked.connect(self._select_real)
self._select_real(widget._real_list_model.index(0, 0))
tab_index = self._tab_widget.addTab(
widget, f"Realizations for iteration {index.internalPointer().id_}"
Expand Down
40 changes: 39 additions & 1 deletion tests/ert/ui_tests/gui/test_restart_esmda.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from ert.gui.ertwidgets import StringBox
from ert.gui.simulation.experiment_panel import ExperimentPanel
from ert.gui.simulation.run_dialog import RunDialog
from ert.run_models import MultipleDataAssimilation
from ert.run_models import MultipleDataAssimilation, SingleTestRun

from .conftest import get_child

Expand Down Expand Up @@ -40,6 +40,44 @@ def test_restart_esmda(ensemble_experiment_has_run_no_failure, qtbot):
)


def test_active_realizations_esmda(opened_main_window_poly, qtbot):
"""This runs a single test run and then verifies that this does
not interfere with the activate realizations in the es_mda panel
unless the restart from that specific ensemble is checked.
"""
gui = opened_main_window_poly

experiment_panel = get_child(gui, ExperimentPanel)
simulation_mode_combo = get_child(experiment_panel, QComboBox)
simulation_mode_combo.setCurrentText(SingleTestRun.name())

single_test_run_panel = gui.findChild(QWidget, name="Single_test_run_panel")
assert single_test_run_panel
run_experiment = experiment_panel.findChild(QWidget, name="run_experiment")
qtbot.mouseClick(run_experiment, Qt.MouseButton.LeftButton)
qtbot.waitUntil(lambda: gui.findChild(RunDialog) is not None)
run_dialog = gui.findChild(RunDialog)
qtbot.waitUntil(lambda: run_dialog.is_simulation_done() == True, timeout=15000)
assert (
run_dialog._total_progress_label.text()
== "Total progress 100% — Experiment completed."
)

simulation_mode_combo.setCurrentText(MultipleDataAssimilation.name())
es_mda_panel = gui.findChild(QWidget, name="ES_MDA_panel")
assert es_mda_panel
active_reals = gui.findChild(StringBox, "active_realizations_box")
assert active_reals.text() == "0-19"

restart_checkbox = es_mda_panel.findChild(QCheckBox, name="restart_checkbox_esmda")
assert restart_checkbox
assert not restart_checkbox.isChecked()
restart_checkbox.click()
assert active_reals.text() == "0"
restart_checkbox.click()
assert active_reals.text() == "0-19"


def test_custom_weights_stored_and_retrieved_from_metadata_esmda(
opened_main_window_minimal_realizations, qtbot
):
Expand Down
23 changes: 19 additions & 4 deletions tests/ert/unit_tests/gui/simulation/test_run_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,14 @@ def test_run_dialog_memory_usage_showing(
name="fm_step_0",
status=state.FORWARD_MODEL_STATE_START,
)
.add_fm_step(
fm_step_id="1",
index="1",
name="fm_step_1",
status=state.FORWARD_MODEL_STATE_START,
)
.build(
["0"],
["0", "1"],
status=state.REALIZATION_STATE_UNKNOWN,
exec_hosts="COMP_01",
)
Expand Down Expand Up @@ -503,7 +509,13 @@ def test_run_dialog_memory_usage_showing(
name="fm_step_0",
status=state.FORWARD_MODEL_STATE_START,
)
.build(["0"], status=state.REALIZATION_STATE_UNKNOWN)
.add_fm_step(
fm_step_id="1",
index="1",
name="fm_step_1",
status=state.FORWARD_MODEL_STATE_START,
)
.build(["0", "1"], status=state.REALIZATION_STATE_UNKNOWN)
),
iteration_label="Foo",
current_iteration=0,
Expand Down Expand Up @@ -541,12 +553,15 @@ def test_run_dialog_fm_label_show_correct_info(
fm_step_model = run_dialog._fm_step_overview.model()
assert fm_step_model._real == 0

# default selection should yield realization 0, iteration 0
fm_step_label = run_dialog.findChild(QLabel, name="fm_step_label")
assert "Realization id 0 in iteration 0" in fm_step_label.text()

realization_box._item_clicked(run_dialog._fm_step_overview.model().index(0, 0))
# clicking realization 1 should update fm_label with realization 1, iteration 0
realization_box._item_clicked(run_dialog._fm_step_overview.model().index(1, 0))

assert (
fm_step_label.text() == f"Realization id 0 in iteration 0{expected_host_info}"
fm_step_label.text() == f"Realization id 1 in iteration 0{expected_host_info}"
)


Expand Down
Loading