From c3214c2f5caa2747b09c33f1f583cdc325f34beb Mon Sep 17 00:00:00 2001 From: Jonathan Karlsen Date: Wed, 16 Oct 2024 16:12:25 +0200 Subject: [PATCH] Quickfix no validation for unintialized ensembles --- .../gui/simulation/evaluate_ensemble_panel.py | 15 ++++++++++++++- src/ert/gui/simulation/manual_update_panel.py | 18 +++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/ert/gui/simulation/evaluate_ensemble_panel.py b/src/ert/gui/simulation/evaluate_ensemble_panel.py index 44d7400c4ef..1140fc44452 100644 --- a/src/ert/gui/simulation/evaluate_ensemble_panel.py +++ b/src/ert/gui/simulation/evaluate_ensemble_panel.py @@ -15,6 +15,7 @@ from ert.mode_definitions import EVALUATE_ENSEMBLE_MODE from ert.run_models.evaluate_ensemble import EvaluateEnsemble from ert.validation import RangeStringArgument +from ert.validation.rangestring import rangestring_to_list @dataclass @@ -68,9 +69,21 @@ def isConfigurationValid(self) -> bool: return ( self._active_realizations_field.isValid() and self._ensemble_selector.currentIndex() != -1 - and bool(self._active_realizations_field.text()) + and self._validate_selected_realization_exist() ) + def _validate_selected_realization_exist(self): + realizations = rangestring_to_list(self._active_realizations_field.text()) + if len(realizations) < 1: + return False + selected_ensemble = self._ensemble_selector.selected_ensemble + for realization_index in realizations: + if not selected_ensemble._responses_exist_for_realization( + realization_index + ): + return False + return True + def get_experiment_arguments(self) -> Arguments: return Arguments( mode=EVALUATE_ENSEMBLE_MODE, diff --git a/src/ert/gui/simulation/manual_update_panel.py b/src/ert/gui/simulation/manual_update_panel.py index b96f75db15f..23016fa9a17 100644 --- a/src/ert/gui/simulation/manual_update_panel.py +++ b/src/ert/gui/simulation/manual_update_panel.py @@ -18,6 +18,7 @@ from ert.mode_definitions import MANUAL_UPDATE_MODE from ert.run_models.manual_update import ManualUpdate from ert.validation import ProperNameFormatArgument, RangeStringArgument +from ert.validation.rangestring import rangestring_to_list @dataclass @@ -93,9 +94,24 @@ def isConfigurationValid(self) -> bool: return ( self._active_realizations_field.isValid() and self._ensemble_selector.currentIndex() != -1 - and bool(self._active_realizations_field.text()) + and self._validate_selected_realization_exist() ) + def _validate_selected_realization_exist(self): + realizations = rangestring_to_list(self._active_realizations_field.text()) + if len(realizations) < 1: + print("NO REALIZATIONS GIVEN") + return False + selected_ensemble = self._ensemble_selector.selected_ensemble + for realization_index in realizations: + if not selected_ensemble._responses_exist_for_realization( + realization_index + ): + print(f"{realization_index=} does not exist!") + return False + print(f"VALID REALIZATIONS {realizations=}") + return True + def get_experiment_arguments(self) -> Arguments: return Arguments( mode=MANUAL_UPDATE_MODE,