From b857a582a130d9676754f2bb53ef454a6f37709b Mon Sep 17 00:00:00 2001 From: DanSava Date: Mon, 23 Sep 2024 10:04:10 +0300 Subject: [PATCH] Resolving conflicts after rebase --- src/ert/config/ert_config.py | 26 ------------------- src/ert/config/summary_config.py | 24 +++++++++++++---- .../ert/unit_tests/config/test_ert_config.py | 2 +- 3 files changed, 20 insertions(+), 32 deletions(-) diff --git a/src/ert/config/ert_config.py b/src/ert/config/ert_config.py index 60c5a1e93bd..be39c1dc52b 100644 --- a/src/ert/config/ert_config.py +++ b/src/ert/config/ert_config.py @@ -69,7 +69,6 @@ parse as parse_observations, ) from .queue_config import QueueConfig -from .summary_config import SummaryConfig from .workflow import Workflow from .workflow_job import ErtScriptLoadFailure, WorkflowJob @@ -318,31 +317,6 @@ def from_dict(cls, config_dict) -> Self: for key, val in config_dict.get("SETENV", []): env_vars[key] = val - forward_model_steps = cls._create_list_of_forward_model_steps_to_run( - installed_forward_model_steps, - substitution_list, - config_dict, - ) - - simulation_step_exists = False - for step in forward_model_steps: - for name in ["eclipse", "flow"]: - if name in step.name.lower(): - simulation_step_exists = True - break - if simulation_step_exists: - break - - has_summary_config = any( - isinstance(config, SummaryConfig) - for config in ensemble_config.response_configuration - ) - - if has_summary_config and not simulation_step_exists: - ConfigWarning.warn( - "Config contians a SUMMARY key but no simulation job known to generate a summary file detected in the forward model" - ) - return cls( substitution_list=substitution_list, ensemble_config=ensemble_config, diff --git a/src/ert/config/summary_config.py b/src/ert/config/summary_config.py index bcd08a37bc8..4fad7d1bdb5 100644 --- a/src/ert/config/summary_config.py +++ b/src/ert/config/summary_config.py @@ -3,14 +3,14 @@ import logging from dataclasses import dataclass from datetime import datetime -from typing import TYPE_CHECKING, Optional, Set, Union +from typing import TYPE_CHECKING, Optional, Set, Union, no_type_check import xarray as xr from ._read_summary import read_summary from .ensemble_config import Refcase from .parsing import ConfigDict, ConfigKeys -from .parsing.config_errors import ConfigValidationError +from .parsing.config_errors import ConfigValidationError, ConfigWarning from .response_config import ResponseConfig from .responses_index import responses_index @@ -57,17 +57,31 @@ def read_from_file(self, run_path: str, iens: int) -> xr.Dataset: def response_type(self) -> str: return "summary" + @no_type_check @classmethod def from_config_dict(cls, config_dict: ConfigDict) -> Optional[SummaryConfig]: refcase = Refcase.from_config_dict(config_dict) - if summary_keys := config_dict.get(ConfigKeys.SUMMARY, []): # type: ignore - eclbase: Optional[str] = config_dict.get("ECLBASE") # type: ignore + if summary_keys := config_dict.get(ConfigKeys.SUMMARY, []): + eclbase: Optional[str] = config_dict.get("ECLBASE") if eclbase is None: raise ConfigValidationError( "In order to use summary responses, ECLBASE has to be set." ) time_map = set(refcase.dates) if refcase is not None else None - + forward_model = config_dict.get(ConfigKeys.FORWARD_MODEL, []) + names = [step[0] for step in forward_model] + simulation_step_exists = False + for job_name in names: + for name in ["eclipse", "flow"]: + if name in job_name.lower(): + simulation_step_exists = True + break + if simulation_step_exists: + break + if not simulation_step_exists: + ConfigWarning.warn( + "Config contains a SUMMARY key but no forward model steps known to generate a summary file" + ) return cls( name="summary", input_files=[eclbase.replace("%d", "")], diff --git a/tests/ert/unit_tests/config/test_ert_config.py b/tests/ert/unit_tests/config/test_ert_config.py index 289f5cf390b..c711883d38c 100644 --- a/tests/ert/unit_tests/config/test_ert_config.py +++ b/tests/ert/unit_tests/config/test_ert_config.py @@ -1638,7 +1638,7 @@ def test_warning_raised_when_summary_key_and_no_simulation_job_present(caplog, r assert issubclass(recwarn[0].category, ConfigWarning) assert ( recwarn[0].message.info.message - == "Config contians a SUMMARY key but no simulation job known to generate a summary file detected in the forward model" + == "Config contains a SUMMARY key but no forward model steps known to generate a summary file" )