diff --git a/src/ert/config/ert_config.py b/src/ert/config/ert_config.py index e4a7efa220e..cf3ad9881be 100644 --- a/src/ert/config/ert_config.py +++ b/src/ert/config/ert_config.py @@ -63,6 +63,7 @@ parse, ) from .queue_config import QueueConfig +from .summary_config import SummaryConfig from .workflow import Workflow from .workflow_job import ErtScriptLoadFailure, WorkflowJob @@ -272,6 +273,31 @@ 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/test-data/snake_oil_field/snake_oil_surface.ert b/test-data/snake_oil_field/snake_oil_surface.ert index aa4177bfb23..9f5d339b42a 100644 --- a/test-data/snake_oil_field/snake_oil_surface.ert +++ b/test-data/snake_oil_field/snake_oil_surface.ert @@ -22,11 +22,11 @@ REFCASE refcase/SNAKE_OIL_FIELD TIME_MAP refcase/time_map.txt OBS_CONFIG observations/observations.txt -INSTALL_JOB SNAKE_OIL_SIMULATOR jobs/SNAKE_OIL_SIMULATOR +INSTALL_JOB SNAKE_OIL_ECLIPSE_SIMULATOR jobs/SNAKE_OIL_SIMULATOR INSTALL_JOB SNAKE_OIL_NPV jobs/SNAKE_OIL_NPV INSTALL_JOB SNAKE_OIL_DIFF jobs/SNAKE_OIL_DIFF -FORWARD_MODEL SNAKE_OIL_SIMULATOR +FORWARD_MODEL SNAKE_OIL_ECLIPSE_SIMULATOR FORWARD_MODEL SNAKE_OIL_NPV FORWARD_MODEL SNAKE_OIL_DIFF diff --git a/tests/unit_tests/config/test_ert_config.py b/tests/unit_tests/config/test_ert_config.py index 7b375365235..fb8cbc25477 100644 --- a/tests/unit_tests/config/test_ert_config.py +++ b/tests/unit_tests/config/test_ert_config.py @@ -1743,3 +1743,65 @@ def test_general_option_in_local_config_has_priority_over_site_config( assert config.queue_config.max_running == 13 assert config.queue_config.submit_sleep == 14 assert config.queue_config.queue_system == QueueSystem.TORQUE + + +@pytest.mark.usefixtures("use_tmpdir") +def test_warning_raised_when_summary_key_and_no_simulation_job_present(caplog, recwarn): + caplog.set_level(logging.WARNING) + + with open("job_file", "w", encoding="utf-8") as fout: + fout.write("EXECUTABLE echo\nARGLIST \n") + + with open("config_file.ert", "w", encoding="utf-8") as fout: + # Write a minimal config file + fout.write("NUM_REALIZATIONS 1\n") + fout.write("SUMMARY *\n") + fout.write("ECLBASE RESULT_SUMMARY\n") + + fout.write("INSTALL_JOB job_name job_file\n") + fout.write( + "FORWARD_MODEL job_name(=A/, =/x)\n" + ) + + ErtConfig.from_file("config_file.ert") + + # Check no warning is logged when config contains + # forward model step with and as arguments + assert not caplog.text + assert len(recwarn) == 1 + 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" + ) + + +@pytest.mark.parametrize( + "job_name", ["eclipse", "eclipse100", "flow", "FLOW", "ECLIPSE100"] +) +@pytest.mark.usefixtures("use_tmpdir") +def test_no_warning_when_summary_key_and_simulation_job_present( + caplog, recwarn, job_name +): + caplog.set_level(logging.WARNING) + + with open("job_file", "w", encoding="utf-8") as fout: + fout.write("EXECUTABLE echo\nARGLIST \n") + + with open("config_file.ert", "w", encoding="utf-8") as fout: + # Write a minimal config file + fout.write("NUM_REALIZATIONS 1\n") + fout.write("SUMMARY *\n") + fout.write("ECLBASE RESULT_SUMMARY\n") + + fout.write(f"INSTALL_JOB {job_name} job_file\n") + fout.write( + f"FORWARD_MODEL {job_name}(=A/, =/x)\n" + ) + + ErtConfig.from_file("config_file.ert") + + # Check no warning is logged when config contains + # forward model step with and as arguments + assert not caplog.text + assert len(recwarn) == 0