diff --git a/src/ert/cli/main.py b/src/ert/cli/main.py index 288d048f8eb..c0069bd1fc9 100644 --- a/src/ert/cli/main.py +++ b/src/ert/cli/main.py @@ -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") diff --git a/src/ert/gui/simulation/experiment_panel.py b/src/ert/gui/simulation/experiment_panel.py index e37b4e55ee6..4a43a30d032 100644 --- a/src/ert/gui/simulation/experiment_panel.py +++ b/src/ert/gui/simulation/experiment_panel.py @@ -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( @@ -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( diff --git a/tests/ert/ui_tests/cli/test_parameter.py b/tests/ert/ui_tests/cli/test_parameter.py new file mode 100644 index 00000000000..6c62e26798a --- /dev/null +++ b/tests/ert/ui_tests/cli/test_parameter.py @@ -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) diff --git a/tests/ert/ui_tests/gui/test_missing_parameters_to_update.py b/tests/ert/ui_tests/gui/test_missing_parameters_to_update.py new file mode 100644 index 00000000000..23312cebbd8 --- /dev/null +++ b/tests/ert/ui_tests/gui/test_missing_parameters_to_update.py @@ -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 + )