Skip to content

Commit

Permalink
Try caching ensemble_state
Browse files Browse the repository at this point in the history
  • Loading branch information
yngve-sk committed Nov 15, 2024
1 parent c86a9c6 commit 0d76ce2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ert/enkf_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")


Expand Down
1 change: 1 addition & 0 deletions src/ert/libres_facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
2 changes: 2 additions & 0 deletions src/ert/run_models/base_run_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/ert/storage/local_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 0d76ce2

Please sign in to comment.