-
Notifications
You must be signed in to change notification settings - Fork 110
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
Improve handling of missing responses.json #9589
base: main
Are you sure you want to change the base?
Conversation
CodSpeed Performance ReportMerging #9589 will improve performances by 10.99%Comparing Summary
Benchmarks breakdown
|
d644aee
to
2fe1d74
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9589 +/- ##
==========================================
- Coverage 91.85% 91.83% -0.03%
==========================================
Files 433 433
Lines 26768 26879 +111
==========================================
+ Hits 24587 24683 +96
- Misses 2181 2196 +15
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
and not ensemble.experiment.is_valid() | ||
): | ||
index = self.count() - 1 | ||
model_item = model.item(index) |
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.
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.
Yes, it works well. Should I use ItemData instead?
abb616c
to
d6e1bdd
Compare
src/ert/gui/main_window.py
Outdated
@@ -154,6 +154,7 @@ def right_clicked(self) -> None: | |||
def select_central_widget(self) -> None: | |||
actor = self.sender() | |||
if actor: | |||
self.notifier.refresh() |
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.
This refreshes storage to make sure the experiment files (responses, index, metadata, and parameters) are still valid.
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.
We could consider just re-running validation, and refresh if that fails.
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.
I updated it so that if will only actually refresh when the validity has changed, when toggling between the panels. This also means that the storage won't be updated if new experiments are added and we toggle between the panels, but that is the same behavior as on main.
There is a bug where it crashes if you are already in the manage experiment window, tab out to delete the responses.json file, and then put focus back on the ert window. I am trying to have ert refresh storage when gaining focus, but reimplementing |
5226e19
to
61e01c7
Compare
The handling of the missing file should in the future be extended to also handle the other experiment files in a similar manner (index.json, metadata.json, and parameters.json) This commit: * Makes storage reload and re-validate when changing between ert modes (manage experient, run experiment, and plot tool) * Disables ensemble with invalid experiments from ensemble_selectors (error is shown as tooltip on hover) * Filters out invalid experiments from dark storage, so plotter won't attempt to plot them. * Reloads and re-validates storage on end of experiment, so ert won't crash if responses.json is deleted mid-run.
61e01c7
to
9203cd3
Compare
This PR contains the initial work towards making this part of the storage more robust. There is still an issue where ert crashes if you have selected an experiment in the manage-experiment panel, tab out and delete responses.json, and tab back in. It seems like the SelectionModel for the QListView tries reselecting the experiment (which is now invalid) before it has been revalidated. |
@@ -94,6 +94,8 @@ def __init__(self) -> None: | |||
|
|||
@Slot(Experiment) | |||
def setExperiment(self, experiment: Experiment) -> None: | |||
if not experiment.is_valid(): |
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 even happen?
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.
Yes, when the selected experiment in manage-experiment becomes invalid while still selected. Apparently, when you tab out of ert while an experiment is selected, and tab in again; the same experiment is re-selected, and this signal is emitted. Very fun to debug 🔮
@@ -128,7 +129,9 @@ def data( | |||
qapp = QApplication.instance() | |||
assert isinstance(qapp, QApplication) | |||
return qapp.palette().mid() | |||
|
|||
elif role == Qt.ItemDataRole.ToolTipRole: | |||
if self._error: |
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.
Is is the same error shown twice?
@override | ||
def hasChildren(self, parent: QModelIndex | None = None) -> bool: | ||
if parent is None or not parent.isValid(): | ||
return True |
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.
shouldn't this be False? At least it sounds like it, but it might be my lack of understanding.
I will argue that you should alter the title of this PR. The PR does not specifically target the missing file, but rather handling invalid experiments. |
|
||
def check_plot_tool(expected_number_of_cases: int) -> None: | ||
find_and_click_button("button_Create_plot") | ||
# Due to the fact that we create new instances of PlotWindow on tab change, QtBot is defaulting to the first child |
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.
I have to test the plotter as the missing responses.json
bug also occurred there
Yes, I was hit by scope creep... |
def _validate_files(self) -> None: | ||
self.valid_parameters = (self._path / self._parameter_file).exists() | ||
self.valid_responses = (self._path / self._responses_file).exists() | ||
self.valid_metadata = (self._path / self._metadata_file).exists() | ||
|
||
def is_valid(self) -> bool: | ||
return self.valid_parameters and self.valid_responses and self.valid_metadata |
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.
Does it make sense to combine these, and check for existence of files in is_valid
?
Issue
Resolves #9493
Approach
The commit in this PR:
(Screenshot of new behavior in GUI if applicable)
(This is when the responses.json file is deleted mid run. Prior to this PR, ert would crash with
ValueError: responses.json does not exist
)(This is when responses.json is deleted, and we open the plotter. The ensemble exists, but is not given as a option to plot due to it having an invalid experiment)
(This is when responses.json is deleted and we open manage-experiment. The experiment is shown, but cannot be selected. It is greyed out, and gives error as a tooltip when hovered)
git rebase -i main --exec 'pytest tests/ert/unit_tests -n logical -m "not integration_test"'
)When applicable