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

Make sure that the last evaluator event is EETerminated #8887

Merged
merged 1 commit into from
Oct 8, 2024

Conversation

xjules
Copy link
Contributor

@xjules xjules commented Oct 4, 2024

Issue
Resolves #8869
Resolves #8889

Approach
Check that the last event in test_ensure_multi_level_events_in_order is EETerminated.

(Screenshot of new behavior in GUI if applicable)

  • PR title captures the intent of the changes, and is fitting for release notes.
  • Added appropriate release note label
  • Commit history is consistent and clean, in line with the contribution guidelines.
  • Make sure unit tests pass locally after every commit (git rebase -i main --exec 'pytest tests/ert/unit_tests -n logical -m "not integration_test"')

When applicable

  • When there are user facing changes: Updated documentation
  • New behavior or changes to existing untested code: Ensured that unit tests are added (See Ground Rules).
  • Large PR: Prepare changes in small commits for more convenient review
  • Bug fix: Add regression test for the bug
  • Bug fix: Create Backport PR to latest release

@xjules xjules self-assigned this Oct 4, 2024
@xjules xjules marked this pull request as ready for review October 4, 2024 10:59
async for event in monitor.track():
if isinstance(event, EETerminated):
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we check if the ensemble_state has changed appropriately? Otherwise this looks like an improvement.

@codecov-commenter
Copy link

codecov-commenter commented Oct 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.49%. Comparing base (c258c76) to head (fd99dbe).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8887      +/-   ##
==========================================
+ Coverage   91.48%   91.49%   +0.01%     
==========================================
  Files         345      345              
  Lines       21263    21267       +4     
==========================================
+ Hits        19452    19459       +7     
+ Misses       1811     1808       -3     
Flag Coverage Δ
cli-tests 39.58% <100.00%> (+0.01%) ⬆️
gui-tests 73.30% <100.00%> (-0.03%) ⬇️
performance-tests 50.17% <100.00%> (+0.01%) ⬆️
unit-tests 80.27% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jonathan-eq jonathan-eq self-requested a review October 7, 2024 11:23
Comment on lines +144 to +152
self._complete_batch.clear()
try:
event = await asyncio.wait_for(self._events.get(), timeout=0.1)
function = event_handler[type(event)]
batch.append((function, event))
self._events.task_done()
except asyncio.TimeoutError:
continue
self._complete_batch.set()
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be over engineered if we made everything inside the loop a separate method, and had the self._complete_batch.set/clear in a decorator on that new method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it would be over engineered - yes! If there would be more utilization of such a decorator then I would say yes.

await self._events.join()
await self._complete_batch.wait()
Copy link
Contributor

Choose a reason for hiding this comment

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

Very nice!

if type(event) in [EESnapshot, EESnapshotUpdate]:
assert finished_event_received == False
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should rename this variable to final_event_was_EETerminated

@@ -469,11 +471,18 @@ async def test_ensure_multi_level_events_in_order(evaluator_to_use):
# about realizations, the state of the ensemble up until that point
# should be not final (i.e. not cancelled, stopped, failed).
ensemble_state = snapshot_event.snapshot.get("status")
final_event_was_EETerminated = False
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also have another flag for testing that we get both a snapshot/snapshotupdate in addition to the terminated event?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

This introduces EnsembleEvaluator._complete_batch event, which is set
every time a batch is produced. When closing the ee server, we make sure
that the _complete_batch is set and thus preventing an events to be
lost.

This behaviour is then tested in
test_ensure_multi_level_events_in_order, which was updated
correspondighly.
Copy link
Contributor

@andreas-el andreas-el left a comment

Choose a reason for hiding this comment

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

Absolutely brilliant! ✈️

@xjules xjules merged commit c98db94 into equinor:main Oct 8, 2024
56 checks passed
@xjules xjules deleted the fix_test_ee branch October 8, 2024 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants