Skip to content
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

Closed

Conversation

yngve-sk
Copy link
Contributor

@yngve-sk yngve-sk commented Jun 25, 2024

Issue
Resolves #8125

@yngve-sk yngve-sk force-pushed the fix-slow-realmask-fn-on-save-only branch 30 times, most recently from 548a801 to c3bc99b Compare June 26, 2024 07:19
@yngve-sk yngve-sk force-pushed the fix-slow-realmask-fn-on-save-only branch 10 times, most recently from 2cfd244 to c8ddb62 Compare July 1, 2024 12:08
@yngve-sk yngve-sk force-pushed the fix-slow-realmask-fn-on-save-only branch 8 times, most recently from 0dfdd73 to 00ccd21 Compare July 2, 2024 10:04
@yngve-sk yngve-sk force-pushed the fix-slow-realmask-fn-on-save-only branch 2 times, most recently from 86adcb0 to d6c2272 Compare July 2, 2024 12:36
Comment on lines +151 to +152
def _to_json(self) -> Dict[int, List[Tuple[str, str, bool]]]:
return {i: list(states) for i, states in self._states.items()}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest inlining this

Comment on lines +172 to +196
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)
)

Copy link
Collaborator

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?

Copy link
Contributor Author

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():
Copy link
Collaborator

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?

Copy link
Contributor Author

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

@@ -1045,6 +1210,13 @@ def save_parameters(

dataset.to_netcdf(path, engine="scipy")

if self._realization_states is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cant be None?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, removing Optional logic

def _refresh_parameter_state(
self, parameter_key: str, realization: int, skip_others: bool = False
) -> None:
if self._realization_states is None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cant be None?

Copy link
Contributor Author

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(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else?

@yngve-sk yngve-sk force-pushed the fix-slow-realmask-fn-on-save-only branch 4 times, most recently from 80ef929 to 98fdfdb Compare July 2, 2024 13:15
with some safeguards to be removed
@yngve-sk yngve-sk force-pushed the fix-slow-realmask-fn-on-save-only branch from 98fdfdb to bb1d26e Compare July 2, 2024 13:24
@yngve-sk yngve-sk closed this Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Checking if responses exist for realization is very slow
3 participants