diff --git a/src/ert/config/queue_config.py b/src/ert/config/queue_config.py index 949b2ede07a..3424abdc665 100644 --- a/src/ert/config/queue_config.py +++ b/src/ert/config/queue_config.py @@ -9,7 +9,7 @@ from ert import _clib -from .parsing import ConfigDict, ConfigValidationError +from .parsing import ConfigDict, ConfigValidationError, ContextString from .queue_system import QueueSystem GENERIC_QUEUE_OPTIONS: List[str] = ["MAX_RUNNING"] @@ -196,7 +196,7 @@ def generate_dict(option_list: List[Tuple[str, str]]) -> Dict[str, List[str]]: def _validate_queue_driver_settings( - queue_system_options: List[Tuple[str, str]], queue_type: str + queue_system_options: List[Tuple[ContextString, ContextString]], queue_type: str ) -> None: for option_strings in queue_system_options: option_name = option_strings[0] @@ -207,31 +207,35 @@ def _validate_queue_driver_settings( option_name in memory_options[queue_type] and re.match("[0-9]+[mg]b", option_value) is None ): - raise ConfigValidationError( + raise ConfigValidationError.with_context( f"'{option_value}' for {option_name} is not a valid format " f"for {queue_type} QUEUE. It must be of " - "the format 'mb' or 'gb'." + "the format 'mb' or 'gb'.", + option_value.token, ) if option_name in string_options[queue_type] and not isinstance( option_value, str ): - raise ConfigValidationError( + raise ConfigValidationError.with_context( f"'{option_value}' for {option_name} is not a valid string type " - f"for the {queue_type} QUEUE." + f"for the {queue_type} QUEUE.", + option_value.token, ) if option_name in positive_number_options[queue_type] and ( re.match(r"^\d+(\.\d+)?$", option_value) is None ): - raise ConfigValidationError( + raise ConfigValidationError.with_context( f"'{option_value}' for {option_name} is not a valid integer or float" - f" for the {queue_type} QUEUE." + f" for the {queue_type} QUEUE.", + option_value.token, ) if option_name in positive_int_options[queue_type] and ( re.match(r"^\d+$", option_value) is None ): - raise ConfigValidationError( + raise ConfigValidationError.with_context( f"'{option_value}' for {option_name} is not a valid positive integer" - f" for the {queue_type} QUEUE." + f" for the {queue_type} QUEUE.", + option_value.token, ) if option_name in bool_options[queue_type] and not option_value in [ "TRUE", @@ -241,7 +245,8 @@ def _validate_queue_driver_settings( "T", "F", ]: - raise ConfigValidationError( + raise ConfigValidationError.with_context( f"The '{option_value}' for {option_name} must be one of TRUE, FALSE, T, F, 1, 0 " - f" for the {queue_type}." + f" for the {queue_type}.", + option_value.token, ) diff --git a/tests/unit_tests/config/test_parser_error_collection.py b/tests/unit_tests/config/test_parser_error_collection.py index 7973f2398a5..609cf266246 100644 --- a/tests/unit_tests/config/test_parser_error_collection.py +++ b/tests/unit_tests/config/test_parser_error_collection.py @@ -470,14 +470,14 @@ def test_queue_option_max_running_non_int(): """ NUM_REALIZATIONS 1 QUEUE_SYSTEM LOCAL - QUEUE_OPTION LOCAL MAX_RUNNING ert + QUEUE_OPTION LOCAL MAX_RUNNING s """ ), expected_error=ExpectedErrorInfo( line=4, column=32, end_column=35, - match="not an integer", + match=r"'ert' for MAX_RUNNING is not a valid positive integer for the LOCAL QUEUE.", ), ) @@ -675,7 +675,7 @@ def test_queue_option_max_running_negative(): line=4, column=32, end_column=34, - match="negative", + match="is not a valid positive integer", ), )