-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minimal attempt at keeping response/param states #8232
Conversation
548a801
to
c3bc99b
Compare
2cfd244
to
c8ddb62
Compare
0dfdd73
to
00ccd21
Compare
86adcb0
to
d6c2272
Compare
def _to_json(self) -> Dict[int, List[Tuple[str, str, bool]]]: | ||
return {i: list(states) for i, states in self._states.items()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest inlining this
def has(self, realization: int, key: str) -> bool: | ||
if realization not in self._states: | ||
return False | ||
|
||
state = self._states[realization] | ||
|
||
return ( | ||
(key, key, True) in state | ||
or any(_has_it and key == _group for _group, _, _has_it in state) | ||
or any(_has_it and key == _key for _, _key, _has_it in state) | ||
) | ||
|
||
def has_entry(self, realization: int, key: str) -> bool: | ||
if realization not in self._states: | ||
return False | ||
|
||
state = self._states[realization] | ||
|
||
result = ( | ||
(key, key, True) in state | ||
or (key, key, False) in state | ||
or any(key == _group for _group, _, _ in state) | ||
or any(key == _key for _, _key, _ in state) | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the difference between these two?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has_entry is if a state is registered for the realization, whether it be True
or False
, whereas has
is if there is a state registered and it is also True
@@ -544,6 +698,17 @@ def unset_failure( | |||
if filename.exists(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be joined with the state_map
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
failure is scoped per realization, state map holds the has_response
/ has_parameter
, and responses/params have unique keys/subkeys depending on the grouping, the has_failure
would be a single bool per realization, and adding it would be possible but would also imply restructuring the json a bit. I'd prefer leaving it for a separate PR after this
src/ert/storage/local_ensemble.py
Outdated
@@ -1045,6 +1210,13 @@ def save_parameters( | |||
|
|||
dataset.to_netcdf(path, engine="scipy") | |||
|
|||
if self._realization_states is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cant be None?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, removing Optional logic
src/ert/storage/local_ensemble.py
Outdated
def _refresh_parameter_state( | ||
self, parameter_key: str, realization: int, skip_others: bool = False | ||
) -> None: | ||
if self._realization_states is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cant be None?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, removing Optional logic
) | ||
return | ||
|
||
self._realization_states.add( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else?
80ef929
to
98fdfdb
Compare
with some safeguards to be removed
98fdfdb
to
bb1d26e
Compare
Issue
Resolves #8125