From e66392459fd9934622445391dadaa1a33a5e2b90 Mon Sep 17 00:00:00 2001 From: DanSava Date: Fri, 29 Nov 2024 10:32:26 +0200 Subject: [PATCH] Stop setting minimum_required_realizations in everest_run_model.py --- src/ert/run_models/everest_run_model.py | 12 +++--------- tests/everest/test_simulator_cache.py | 4 ++-- tests/everest/test_workflows.py | 3 +-- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/ert/run_models/everest_run_model.py b/src/ert/run_models/everest_run_model.py index dc83285c926..56aa3255e8e 100644 --- a/src/ert/run_models/everest_run_model.py +++ b/src/ert/run_models/everest_run_model.py @@ -34,7 +34,7 @@ from numpy import float64 from numpy._typing import NDArray from ropt.enums import EventType, OptimizerExitCode -from ropt.evaluator import Evaluator, EvaluatorContext, EvaluatorResult +from ropt.evaluator import EvaluatorContext, EvaluatorResult from ropt.plan import BasicOptimizer from ropt.plan import Event as OptimizerEvent from seba_sqlite import SqliteStorage @@ -390,7 +390,7 @@ def _create_optimizer(self) -> BasicOptimizer: # maximization results, necessitating a conversion step. optimizer = ( BasicOptimizer( - enopt_config=self.ropt_config, evaluator=self.run_forward_model + enopt_config=self.ropt_config, evaluator=self._forward_model_evaluator ) .add_table( columns=RESULT_COLUMNS, @@ -582,7 +582,7 @@ def _check_suffix( control_name, sim_id, ExtParamConfig.to_dataset(control) ) - def run_forward_model( + def _forward_model_evaluator( self, control_values: NDArray[np.float64], metadata: EvaluatorContext ) -> EvaluatorResult: def _slug(entity: str) -> str: @@ -617,12 +617,6 @@ def _slug(entity: str) -> str: if self.active_realizations[sim_id]: substitutions[f""] = str(geo_id) - # TODO: This causes problems with `test_remove_run_path`` Setting it to - # zero fixes that, but breaks `test_state_modifier_workflow_run`. There - # seems to be a disagreement on how everest and ert handle/define failed - # realizations. - self.minimum_required_realizations = len(self.active_realizations) - run_paths = Runpaths( jobname_format=self.ert_config.model_config.jobname_format_string, runpath_format=self.ert_config.model_config.runpath_format_string, diff --git a/tests/everest/test_simulator_cache.py b/tests/everest/test_simulator_cache.py index 40a5c7ecd01..e347fc76476 100644 --- a/tests/everest/test_simulator_cache.py +++ b/tests/everest/test_simulator_cache.py @@ -31,8 +31,8 @@ def new_call(*args): ) # Modify the forward model function to track number of calls: - original_call = run_model.run_forward_model - run_model.run_forward_model = new_call + original_call = run_model._forward_model_evaluator + run_model._forward_model_evaluator = new_call # First run populates the cache: run_model.run_experiment(evaluator_server_config) diff --git a/tests/everest/test_workflows.py b/tests/everest/test_workflows.py index 7484d79cfd9..6e59ffcade1 100644 --- a/tests/everest/test_workflows.py +++ b/tests/everest/test_workflows.py @@ -42,8 +42,7 @@ def test_state_modifier_workflow_run( EverestConfig.load_file(f"everest/model/{config}.yml") ) evaluator_server_config = evaluator_server_config_generator(run_model) - with pytest.raises(ValueError): - run_model.run_experiment(evaluator_server_config) + run_model.run_experiment(evaluator_server_config) for path in Path.cwd().glob("**/simulation_0/RESULT.SCH"): assert path.read_bytes() == (cwd / "eclipse/model/EXPECTED.SCH").read_bytes()