Skip to content

Commit

Permalink
Make _has_response realization-specific for combined
Browse files Browse the repository at this point in the history
  • Loading branch information
yngve-sk committed Oct 25, 2024
1 parent 55fa828 commit 9fd8cc3
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions src/ert/storage/local_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,21 +299,39 @@ def _responses_exist_for_realization(

if not self.experiment.response_configuration:
return True
path = self._realization_dir(realization)

responses_for_all_reals: Dict[str, polars.DataFrame] = {}

_response_types = (
[self.experiment.response_key_to_response_type.get(key, key)]
if key
else list(self.experiment.response_configuration)
)

for response_type in _response_types:
responses_for_all_reals[response_type] = self.load_responses(
response_type, tuple(range(self.ensemble_size))
)

# Note: potential performance bottleneck,
# should be improved greatly by having statemap.
# Should also be faster due to lru cache on load_responses
def _has_response(_response_type: str) -> bool:
if (path / f"{_response_type}.parquet").exists():
return True
# This currently also relies on LRU cache on load_responses
# If it is removed, we should try to hold these datasets
# especially when we loop over all reals and invoke this function
if key and key not in responses_for_all_reals:

def _has_response(_response_type: str) -> bool:
return (
realization
in responses_for_all_reals[_response_type]["realization"]
and key in responses_for_all_reals[_response_type]["response_key"]
)
else:

if (self.mount_point / f"{_response_type}.parquet").exists():
def _has_response(_response_type: str) -> bool:
return (
realization
in self.load_responses(
_response_type, tuple(range(self.ensemble_size))
)["realization"]
in responses_for_all_reals[_response_type]["realization"]
)

if key:
Expand Down

0 comments on commit 9fd8cc3

Please sign in to comment.