diff --git a/docs/everest/config_generated.rst b/docs/everest/config_generated.rst index 4be32fedd44..71bead7d4b3 100644 --- a/docs/everest/config_generated.rst +++ b/docs/everest/config_generated.rst @@ -29,12 +29,6 @@ Configuration of the Everest model If specified, it must be a list of numeric values, one per realization. -**report_steps (optional)** - Type: *Optional[List[str]]* - - List of dates allowed in the summary file. - - controls (required) ------------------- diff --git a/src/everest/config/model_config.py b/src/everest/config/model_config.py index 594e71b6fdb..3d70542fd02 100644 --- a/src/everest/config/model_config.py +++ b/src/everest/config/model_config.py @@ -1,9 +1,8 @@ -from datetime import datetime from typing import List, Optional -from pydantic import BaseModel, Field, NonNegativeInt, field_validator, model_validator +from pydantic import BaseModel, Field, NonNegativeInt, model_validator -from everest.strings import DATE_FORMAT +from ert.config import ConfigWarning class ModelConfig(BaseModel, extra="forbid"): # type: ignore @@ -26,10 +25,16 @@ class ModelConfig(BaseModel, extra="forbid"): # type: ignore If specified, it must be a list of numeric values, one per realization.""", ) - report_steps: Optional[List[str]] = Field( - default=None, - description="List of dates allowed in the summary file.", - ) + + @model_validator(mode="before") + @classmethod + def remove_deprecated(cls, values): + if values.get("report_steps") is not None: + ConfigWarning.warn( + "report_steps no longer has any effect and can be removed." + ) + values.pop("report_steps") + return values @model_validator(mode="before") @classmethod @@ -47,25 +52,3 @@ def validate_realizations_weights_same_cardinaltiy(cls, values): # pylint: disa ) return values - - @field_validator("report_steps") - @classmethod - def validate_report_steps_are_dates(cls, report_steps): # pylint: disable=E0213 - invalid_steps = [] - for step in report_steps: - try: - if not isinstance(step, str): - invalid_steps.append(str(step)) - continue - - datetime.strptime(step, DATE_FORMAT) - except ValueError: - invalid_steps.append(step) - - if len(invalid_steps) > 0: - raise ValueError( - f"malformed dates: {', '.join(invalid_steps)}," - f"expected format: {DATE_FORMAT}" - ) - - return report_steps diff --git a/src/everest/config_keys.py b/src/everest/config_keys.py index c6039bbe66d..c6c64eadbc8 100644 --- a/src/everest/config_keys.py +++ b/src/everest/config_keys.py @@ -104,7 +104,6 @@ class ConfigKeys: REALIZATIONS = "realizations" REALIZATIONS_WEIGHTS = "realizations_weights" RELATIVE = "relative" - REPORT_STEPS = "report_steps" RESUBMIT_LIMIT = "resubmit_limit" SKIP_EXPORT = "skip_export" RUN_TEMPLATE = "run_template" diff --git a/src/everest/simulator/everest_to_ert.py b/src/everest/simulator/everest_to_ert.py index 8b635bc1060..4625815d009 100644 --- a/src/everest/simulator/everest_to_ert.py +++ b/src/everest/simulator/everest_to_ert.py @@ -408,33 +408,10 @@ def _extract_templating(ever_config: EverestConfig): return forward_model -def _insert_strip_dates_job(everest_config: EverestConfig, forward_model): - report_steps = everest_config.model.report_steps - - if report_steps: - simulation_idx = [ - idx - for idx, model in enumerate(forward_model) - if "eclipse" in model.split()[0] or "flow" in model.split()[0] - ] - - strip_dates_job_str = "{job_name} {args}".format( - job_name="strip_dates", - args="--summary {file} --dates {dates}".format( - file=".UNSMRY", dates=" ".join(report_steps) - ), - ) - - for idx in simulation_idx: - forward_model.insert(idx + 1, strip_dates_job_str) - return forward_model - - def _extract_forward_model(ever_config: EverestConfig, ert_config): forward_model = _extract_data_operations(ever_config) forward_model += _extract_templating(ever_config) forward_model += ever_config.forward_model or [] - forward_model = _insert_strip_dates_job(ever_config, forward_model) sim_job = ert_config.get(ErtConfigKeys.SIMULATION_JOB, []) for job in forward_model: diff --git a/test-data/everest/egg/everest/model/config.yml b/test-data/everest/egg/everest/model/config.yml index 5d056c10709..795af7f8e93 100644 --- a/test-data/everest/egg/everest/model/config.yml +++ b/test-data/everest/egg/everest/model/config.yml @@ -90,7 +90,6 @@ optimization: model: realizations: [0, 1, 2] data_file: r{{data_file}} - report_steps: ['2014-05-30', '2014-08-28', '2014-11-26', '2015-02-24', '2015-05-25', '2015-08-23', '2015-11-21', '2016-02-19', '2016-05-19'] environment: simulation_folder: egg_simulations diff --git a/test-data/everest/egg/everest/model/config_flow.yml b/test-data/everest/egg/everest/model/config_flow.yml index 4b1c32b48f4..84df09e0cd8 100644 --- a/test-data/everest/egg/everest/model/config_flow.yml +++ b/test-data/everest/egg/everest/model/config_flow.yml @@ -88,7 +88,6 @@ optimization: model: realizations: [0, 1, 2] data_file: ../../eclipse/include/realizations/realization-r{{realization}}/eclipse/model/EGG_FLOW.DATA - report_steps: ['2014-05-30', '2014-08-28', '2014-11-26', '2015-02-24', '2015-05-25', '2015-08-23', '2015-11-21', '2016-02-19', '2016-05-19'] environment: simulation_folder: egg_simulations diff --git a/tests/everest/test_config_validation.py b/tests/everest/test_config_validation.py index 4415c0a48b6..7279c9d3440 100644 --- a/tests/everest/test_config_validation.py +++ b/tests/everest/test_config_validation.py @@ -644,33 +644,6 @@ def test_that_model_data_file_exists(change_to_tmpdir): ) -def test_that_model_report_steps_invalid_dates_errors(change_to_tmpdir): - os.makedirs("config_dir/relative/path") - with open("config_dir/test.yml", "w", encoding="utf-8") as f: - f.write(" ") - - with pytest.raises(ValueError) as e: - EverestConfig.with_defaults( - model={ - "realizations": [1, 2, 3], - "report_steps": ["2022-02-02", "hey", "yo", "sup", "ma", "dawg"], - "data_file": "relative/path", - }, - config_path=Path("config_dir/test.yml"), - ) - - assert has_error(e.value, "malformed dates: hey, yo, sup, ma, dawg") - - EverestConfig.with_defaults( - model={ - "realizations": [1, 2, 3], - "report_steps": ["2022-01-01", "2022-01-03", "2022-01-05"], - "data_file": "relative/path", - }, - config_path=Path("config_dir/test.yml"), - ) - - @pytest.mark.parametrize( ["install_keyword"], [ @@ -990,3 +963,8 @@ def test_warning_forward_model_write_objectives(objective, forward_model, warnin objective_functions=[{"name": o} for o in objective], forward_model=forward_model, ) + + +def test_deprecated_keyword(): + with pytest.warns(ConfigWarning, match="report_steps .* can be removed"): + ModelConfig(**{"report_steps": []}) diff --git a/tests/everest/test_egg_simulation.py b/tests/everest/test_egg_simulation.py index fdb32b54861..b77cbd9e9c5 100644 --- a/tests/everest/test_egg_simulation.py +++ b/tests/everest/test_egg_simulation.py @@ -537,21 +537,6 @@ def _generate_exp_ert_config(config_path, output_dir): "--version", "2020.2", ), - ( - "strip_dates", - "--summary", - ".UNSMRY", - "--dates", - "2014-05-30", - "2014-08-28", - "2014-11-26", - "2015-02-24", - "2015-05-25", - "2015-08-23", - "2015-11-21", - "2016-02-19", - "2016-05-19", - ), ("rf", "-s", "eclipse/model/EGG", "-o", "rf"), ], ErtConfigKeys.ENSPATH: os.path.join( diff --git a/tests/everest/test_everlint.py b/tests/everest/test_everlint.py index 7fef708eac8..caf5fec3916 100644 --- a/tests/everest/test_everlint.py +++ b/tests/everest/test_everlint.py @@ -550,25 +550,6 @@ def test_date_type(): has_error(err, match=f"malformed date: {date}(.*)") -def test_lint_report_steps(): - config_file = relpath("test_data/mocked_test_case/mocked_test_case.yml") - config = EverestConfig.load_file(config_file).to_dict() - # Check initial config file is valid - assert len(EverestConfig.lint_config_dict(config)) == 0 - config[ConfigKeys.MODEL][ConfigKeys.REPORT_STEPS] = [ - "2000-1-1", - "2001-1-1", - "2002-1-1", - "2003-1-1", - ] - # Check config file is valid after report steps have been added - assert len(EverestConfig.lint_config_dict(config)) == 0 - config[ConfigKeys.MODEL][ConfigKeys.REPORT_STEPS].append("invalid_date") - # Check config no longer valid when invalid date is added - errors = EverestConfig.lint_config_dict(config) - has_error(errors, match="malformed date: invalid_date(.*)") - - @pytest.mark.fails_on_macos_github_workflow def test_lint_everest_models_jobs(): pytest.importorskip("everest_models") diff --git a/tests/everest/test_res_initialization.py b/tests/everest/test_res_initialization.py index c04e2c237fa..7f825723232 100644 --- a/tests/everest/test_res_initialization.py +++ b/tests/everest/test_res_initialization.py @@ -32,7 +32,7 @@ TUTORIAL_CONFIG_DIR = "mocked_test_case" -def build_snake_dict(output_dir, queue_system, report_steps=False): +def build_snake_dict(output_dir, queue_system): # This is a tested config from ert corresponding to the # snake_oil @@ -50,20 +50,6 @@ def simulation_jobs(): ("snake_oil_npv",), ("snake_oil_diff",), ] - if report_steps: - sim_jobs.insert(2, ("eclipse100",)) - sim_jobs.insert( - 3, - ( - "strip_dates", - "--summary", - ".UNSMRY", - "--dates", - "2000-1-1", - "2001-1-2", - "2002-1-1", - ), - ) return sim_jobs def install_jobs(): @@ -610,24 +596,6 @@ def test_install_data_with_invalid_templates( assert expected_error_msg in str(exc_info.value) -def test_strip_date_job_insertion(copy_snake_oil_to_tmp): - # Load config file - ever_config = EverestConfig.load_file(SNAKE_CONFIG_PATH) - ever_config.model.report_steps = [ - "2000-1-1", - "2001-1-2", - "2002-1-1", - ] - ever_config.forward_model.insert(1, "eclipse100") - - output_dir = ever_config.output_dir - snake_dict = build_snake_dict(output_dir, ConfigKeys.LOCAL, report_steps=True) - - # Transform to res dict and verify equality - ert_config_dict = _everest_to_ert_config_dict(ever_config) - assert snake_dict == ert_config_dict - - def test_workflow_job(copy_snake_oil_to_tmp): workflow_jobs = [{"name": "test", "source": "jobs/TEST"}] ever_config = EverestConfig.load_file(SNAKE_CONFIG_PATH)