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

Disable experiment types that do parameter updates if there are no params to update #9007

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
17 changes: 12 additions & 5 deletions src/ert/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,22 @@ def run_cli(args: Namespace, plugin_manager: Optional[ErtPluginManager] = None)
f"'OBS_CONFIG observation_file.txt'."
)

if not ert_config.ensemble_config.parameter_configs and args.mode in [
if args.mode in [
ENSEMBLE_SMOOTHER_MODE,
ES_MDA_MODE,
ITERATIVE_ENSEMBLE_SMOOTHER_MODE,
]:
raise ErtCliError(
f"To run {args.mode}, GEN_KW, FIELD or SURFACE parameters are needed. \n"
f"Please add to file {args.config}"
)
if not ert_config.ensemble_config.parameter_configs:
raise ErtCliError(
f"To run {args.mode}, GEN_KW, FIELD or SURFACE parameters are needed. \n"
f"Please add to file {args.config}"
)
if not any(
p.update for p in ert_config.ensemble_config.parameter_configs.values()
):
raise ErtCliError(
f"All parameters are set to UPDATE:FALSE in {args.config}"
)

storage = open_storage(ert_config.ens_path, "w")

Expand Down
10 changes: 6 additions & 4 deletions src/ert/gui/simulation/experiment_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ def __init__(
True,
)

experiment_type_valid = bool(
config.ensemble_config.parameter_configs and config.observations
)
experiment_type_valid = any(
p.update for p in config.ensemble_config.parameter_configs.values()
) and bool(config.observations)

self.addExperimentConfigPanel(
MultipleDataAssimilationPanel(
Expand Down Expand Up @@ -202,7 +202,9 @@ def addExperimentConfigPanel(
sim_item = model.item(item_count)
assert sim_item is not None
sim_item.setEnabled(False)
sim_item.setToolTip("Both observations and parameters must be defined")
sim_item.setToolTip(
"Both observations and parameters must be defined.\nThere must be parameters to update."
)
style = self.style()
assert style is not None
sim_item.setIcon(
Expand Down
32 changes: 32 additions & 0 deletions tests/ert/ui_tests/cli/test_parameter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import fileinput
from argparse import ArgumentParser

import pytest

from ert.__main__ import ert_parser
from ert.cli.main import ErtCliError, run_cli
from ert.mode_definitions import ENSEMBLE_SMOOTHER_MODE


@pytest.mark.usefixtures("copy_poly_case")
def test_no_updateable_parameters():
with fileinput.input("poly.ert", inplace=True) as fin:
for line in fin:
if "GEN_KW COEFFS coeff_priors" in line:
print(f"{line[:-1]} UPDATE:FALSE")
else:
print(line, end="")

parser = ArgumentParser(prog="test_main")
parsed = ert_parser(
parser,
[
ENSEMBLE_SMOOTHER_MODE,
"--disable-monitor",
"poly.ert",
],
)

with pytest.raises(ErtCliError) as e:
run_cli(parsed)
assert "All parameters are set to UPDATE:FALSE in" in str(e)
26 changes: 26 additions & 0 deletions tests/ert/ui_tests/gui/test_missing_parameters_to_update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import fileinput

import pytest
from qtpy.QtCore import Qt
from qtpy.QtWidgets import QComboBox

from ert.gui.simulation.experiment_panel import ExperimentPanel
from tests.ert.ui_tests.gui.conftest import get_child, open_gui_with_config


@pytest.mark.usefixtures("copy_poly_case")
def test_no_updateable_parameters(qtbot):
with fileinput.input("poly.ert", inplace=True) as fin:
for line in fin:
if "GEN_KW COEFFS coeff_priors" in line:
print(f"{line[:-1]} UPDATE:FALSE")
else:
print(line, end="")

for gui in open_gui_with_config("poly.ert"):
experiment_panel = get_child(gui, ExperimentPanel)
simulation_mode_combo = get_child(experiment_panel, QComboBox)
idx = simulation_mode_combo.findText("Ensemble smoother")
assert not (
simulation_mode_combo.model().item(idx).flags() & Qt.ItemFlag.ItemIsEnabled
)