diff --git a/src/ert/config/design_matrix.py b/src/ert/config/design_matrix.py index fd8f262e9ef..c6eaa0c8a56 100644 --- a/src/ert/config/design_matrix.py +++ b/src/ert/config/design_matrix.py @@ -11,15 +11,10 @@ from ert.config.gen_kw_config import GenKwConfig, TransformFunctionDefinition from ._option_dict import option_dict -from .parsing import ( - ConfigValidationError, - ErrorInfo, -) +from .parsing import ConfigValidationError, ErrorInfo if TYPE_CHECKING: - from ert.config import ( - ParameterConfig, - ) + from ert.config import ParameterConfig DESIGN_MATRIX_GROUP = "DESIGN_MATRIX" @@ -74,6 +69,20 @@ def from_config_list(cls, config_list: List[str]) -> "DesignMatrix": default_sheet=default_sheet, ) + def merge_with_existing_parameters( + self, existing_parameters: Dict[str, ParameterConfig] + ) -> Dict[str, ParameterConfig]: + design_keys = self.parameter_configuration[DESIGN_MATRIX_GROUP].getKeyWords() + for parameter_group_name, genkw_group in existing_parameters.items(): + existing_keys = genkw_group.getKeyWords() + if set(design_keys).issubset(set(existing_keys)): + self.parameter_configuration[parameter_group_name] = ( + self.parameter_configuration[DESIGN_MATRIX_GROUP] + ) + genkw_group.disabled = True + elif set(design_keys) & set(existing_keys): + raise ConfigValidationError("overlapping parameter names") + def read_design_matrix( self, ) -> None: diff --git a/src/ert/config/gen_kw_config.py b/src/ert/config/gen_kw_config.py index 459b9b46aad..594073dea8c 100644 --- a/src/ert/config/gen_kw_config.py +++ b/src/ert/config/gen_kw_config.py @@ -72,6 +72,7 @@ class GenKwConfig(ParameterConfig): output_file: Optional[str] transform_function_definitions: List[TransformFunctionDefinition] forward_init_file: Optional[str] = None + disabled: bool = False def __post_init__(self) -> None: self.transform_functions: List[TransformFunction] = []