From ba54b66c91d407bb41ef4a0533bdb4f86fb90ed9 Mon Sep 17 00:00:00 2001 From: Andreas Eknes Lie Date: Thu, 18 Jan 2024 12:17:33 +0100 Subject: [PATCH] Provide more descriptive feedback on USE_EE and USE_GE Collect errors before raising them together --- src/ert/config/analysis_config.py | 36 ++++++++++++++++------ tests/unit_tests/config/test_ert_config.py | 4 +-- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/ert/config/analysis_config.py b/src/ert/config/analysis_config.py index 31494062627..059ea16e313 100644 --- a/src/ert/config/analysis_config.py +++ b/src/ert/config/analysis_config.py @@ -18,7 +18,6 @@ logger = logging.getLogger(__name__) - DEFAULT_ANALYSIS_MODE = AnalysisMode.ENSEMBLE_SMOOTHER @@ -52,7 +51,10 @@ def __init__( "SUBSPACE_RE": 3, } deprecated_keys = ["ENKF_NCOMP", "ENKF_SUBSPACE_DIMENSION"] + deprecated_inversion_keys = ["USE_EE", "USE_GE"] errors = [] + all_errors = [] + for module_name, var_name, value in analysis_set_var: if var_name in deprecated_keys: errors.append(var_name) @@ -62,8 +64,28 @@ def __init__( if var_name == "INVERSION": value = str(inversion_str_map[value]) var_name = "IES_INVERSION" + if var_name in deprecated_inversion_keys: + all_errors.append( + ConfigValidationError( + f"Keyword {var_name} has been replaced by INVERSION and has no effect." + "\n\nPlease see https://ert.readthedocs.io/en/latest/reference/configuration/keywords.html#inversion-algorithm " + "for documentation how to use this instead." + ) + ) + continue key = var_name.lower() options[module_name][key] = value + + if errors: + all_errors.append( + ConfigValidationError( + f"The {', '.join(errors)} keyword(s) has been removed and functionality " + "replaced with the ENKF_TRUNCATION keyword. Please see " + "https://ert.readthedocs.io/en/latest/reference/configuration/keywords.html#enkf-truncation " + "for documentation how to use this instead." + ) + ) + try: self.es_module = ESSettings(**options["STD_ENKF"]) self.ies_module = IESSettings(**options["IES_ENKF"]) @@ -72,14 +94,10 @@ def __init__( error["loc"] = tuple( [val.upper() for val in error["loc"] if isinstance(val, str)] ) - raise ConfigValidationError(str(err)) from err - if errors: - raise ConfigValidationError( - f"The {', '.join(errors)} keyword(s) has been removed and functionality " - "replaced with the ENKF_TRUNCATION keyword. Please see " - "https://ert.readthedocs.io/en/latest/reference/configuration/keywords.html#enkf-truncation " - "for documentation how to use this instead." - ) + all_errors.append(ConfigValidationError(str(error))) + + if all_errors: + raise ConfigValidationError.from_collected(all_errors) @no_type_check @classmethod diff --git a/tests/unit_tests/config/test_ert_config.py b/tests/unit_tests/config/test_ert_config.py index 8479ebc85de..50f6c01baac 100644 --- a/tests/unit_tests/config/test_ert_config.py +++ b/tests/unit_tests/config/test_ert_config.py @@ -1515,8 +1515,8 @@ def test_validate_no_logs_when_overwriting_with_same_value(caplog): @pytest.mark.parametrize( "obsolete_analysis_keyword,error_msg", [ - ("USE_EE", "Extra inputs are not permitted"), - ("USE_GE", "Extra inputs are not permitted"), + ("USE_EE", "Keyword USE_EE has been replaced"), + ("USE_GE", "Keyword USE_GE has been replaced"), ("ENKF_NCOMP", r"ENKF_NCOMP keyword\(s\) has been removed"), ( "ENKF_SUBSPACE_DIMENSION",