Skip to content

Commit

Permalink
Provide more descriptive feedback on USE_EE and USE_GE
Browse files Browse the repository at this point in the history
Collect errors before raising them together
  • Loading branch information
andreas-el committed Jan 18, 2024
1 parent 91ea363 commit ba54b66
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
36 changes: 27 additions & 9 deletions src/ert/config/analysis_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

logger = logging.getLogger(__name__)


DEFAULT_ANALYSIS_MODE = AnalysisMode.ENSEMBLE_SMOOTHER


Expand Down Expand Up @@ -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)
Expand All @@ -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"])
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/unit_tests/config/test_ert_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit ba54b66

Please sign in to comment.