diff --git a/src/ert/enkf_main.py b/src/ert/enkf_main.py index 5e776a548d9..7ddde2b52ca 100644 --- a/src/ert/enkf_main.py +++ b/src/ert/enkf_main.py @@ -191,6 +191,7 @@ def sample_prior( ) ensemble.save_parameters(parameter, realization_nr, ds) + ensemble.refresh_ensemble_state() logger.debug(f"sample_prior() time_used {(time.perf_counter() - t):.4f}s") diff --git a/src/ert/libres_facade.py b/src/ert/libres_facade.py index bc516f04455..2a3237cf697 100644 --- a/src/ert/libres_facade.py +++ b/src/ert/libres_facade.py @@ -136,6 +136,7 @@ def load_from_forward_model( ensemble, [r for r, active in enumerate(realisations) if active], ) + ensemble.refresh_ensemble_state() _logger.debug( f"load_from_forward_model() time_used {(time.perf_counter() - t):.4f}s" ) @@ -173,6 +174,7 @@ def load_from_run_path( else: _logger.error(f"Realization: {iens}, load failure: {message}") + ensemble.refresh_ensemble_state() return loaded def get_observations(self) -> "EnkfObs": diff --git a/src/ert/run_models/base_run_model.py b/src/ert/run_models/base_run_model.py index 53bc3a9fa9b..e332f8ee9dc 100644 --- a/src/ert/run_models/base_run_model.py +++ b/src/ert/run_models/base_run_model.py @@ -574,6 +574,8 @@ async def run_ensemble_evaluator_async( self._end_queue.get() return [] await evaluator_task + ensemble.refresh_ensemble_state() + return evaluator_task.result() # This function needs to be there for the sake of testing that expects sync ee run diff --git a/src/ert/storage/local_ensemble.py b/src/ert/storage/local_ensemble.py index 3387a74aa2f..72c6e923fb6 100644 --- a/src/ert/storage/local_ensemble.py +++ b/src/ert/storage/local_ensemble.py @@ -419,6 +419,11 @@ def get_failure(self, realization: int) -> Optional[_Failure]: ) return None + def refresh_ensemble_state(self) -> None: + self.get_ensemble_state.cache_clear() + self.get_ensemble_state() + + @lru_cache # noqa: B019 def get_ensemble_state(self) -> List[Set[RealizationStorageState]]: """ Retrieve the state of each realization within ensemble. diff --git a/src/ert/storage/local_storage.py b/src/ert/storage/local_storage.py index fc09f5108d6..ecaee5f9d6f 100644 --- a/src/ert/storage/local_storage.py +++ b/src/ert/storage/local_storage.py @@ -148,6 +148,9 @@ def refresh(self) -> None: self._ensembles = self._load_ensembles() self._experiments = self._load_experiments() + for ens in self._ensembles.values(): + ens.refresh_ensemble_state() + def get_experiment(self, uuid: UUID) -> LocalExperiment: """ Retrieves an experiment by UUID.