diff --git a/src/ert/run_models/everest_run_model.py b/src/ert/run_models/everest_run_model.py index b768ee7a286..894af42d76c 100644 --- a/src/ert/run_models/everest_run_model.py +++ b/src/ert/run_models/everest_run_model.py @@ -189,12 +189,7 @@ def run_experiment( self.ever_storage = EverestStorage( output_dir=Path(self._everest_config.optimization_output_dir), ) - self.ever_storage.observe_optimizer( - optimizer, - Path(self._everest_config.optimization_output_dir) - / "dakota" - / "OPT_DEFAULT.out", - ) + self.ever_storage.observe_optimizer(optimizer) # Run the optimization: optimizer_exit_code = optimizer.run().exit_code diff --git a/src/everest/everest_storage.py b/src/everest/everest_storage.py index b85f0e216be..aec1588e583 100644 --- a/src/everest/everest_storage.py +++ b/src/everest/everest_storage.py @@ -256,7 +256,6 @@ def __init__( self._gradient_ensemble_id = 0 self._output_dir = output_dir - self._merit_file: Path | None = None self.data = OptimizationStorageData() @staticmethod @@ -338,12 +337,7 @@ def read_from_output_dir(self) -> None: def observe_optimizer( self, optimizer: BasicOptimizer, - merit_file: Path, ) -> None: - # We only need this file if we are observing a running ROPT instance - # (using dakota backend) - self._merit_file = merit_file - optimizer.add_observer( EventType.START_OPTIMIZER_STEP, self._on_start_optimization ) @@ -860,7 +854,7 @@ def _get_merit_values(self) -> list[_MeritValue]: # Iter F(x) mu alpha Merit feval btracks Penalty # :return: merit values indexed by the function evaluation number - def _get_merit_fn_lines(merit_path: str) -> list[str]: + def _get_merit_fn_lines(merit_path: Path) -> list[str]: if os.path.isfile(merit_path): with open(merit_path, errors="replace", encoding="utf-8") as reader: lines = reader.readlines() @@ -887,9 +881,10 @@ def _parse_merit_line(merit_values_string: str) -> tuple[int, float] | None: return int(values[5]) - 1, values[4] return None + merit_file = Path(self._output_dir) / "dakota" / "OPT_DEFAULT.out" merit_values = [] - if self._merit_file.exists(): - for line in _get_merit_fn_lines(self._merit_file): + if merit_file.exists(): + for line in _get_merit_fn_lines(merit_file): value = _parse_merit_line(line) if value is not None: merit_values.append(_MeritValue(iter=value[0], value=value[1]))