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 to establish connection and empty the event queue before cancelling publisher #7562

Merged
merged 2 commits into from
Apr 8, 2024

Conversation

xjules
Copy link
Contributor

@xjules xjules commented Apr 4, 2024

Issue
Resolves #7522

  • 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 tests pass locally (after every commit!)

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 Apr 4, 2024
@codecov-commenter
Copy link

codecov-commenter commented Apr 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.21%. Comparing base (3fdff88) to head (d3b2544).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7562      +/-   ##
==========================================
+ Coverage   85.19%   85.21%   +0.01%     
==========================================
  Files         388      388              
  Lines       23338    23352      +14     
  Branches      893      887       -6     
==========================================
+ Hits        19883    19899      +16     
+ Misses       3348     3341       -7     
- Partials      107      112       +5     

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

@xjules xjules changed the title Make sure to empty the event queue before cancelling publisher Make sure to establish connection and empty the event queue before cancelling publisher Apr 5, 2024
@xjules xjules force-pushed the unbox_scheduler branch from a943506 to 837b967 Compare April 5, 2024 10:36
@xjules xjules force-pushed the unbox_scheduler branch from df8a328 to b21fbeb Compare April 8, 2024 06:46
@jonathan-eq jonathan-eq requested review from jonathan-eq and removed request for jonathan-eq April 8, 2024 07:18
@xjules xjules force-pushed the unbox_scheduler branch from b21fbeb to 57cbf49 Compare April 8, 2024 08:45
@@ -16,7 +16,7 @@ repos:
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.1
rev: v18.1.3
Copy link
Contributor

Choose a reason for hiding this comment

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

would be nice to have in a separate commit in case of rollbacks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, left over. Will rm.

@@ -40,6 +41,16 @@ def _done_callback(task: asyncio.Task[_T_co]) -> None:
if (exc := task.exception()) is None:
return

logger.error(f"Exception occurred during {task.get_name()}", exc_info=exc)
# logger.error(f"Exception occurred during {task.get_name()}", exc_info=exc)
Copy link
Contributor

Choose a reason for hiding this comment

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

rm this line

@xjules xjules force-pushed the unbox_scheduler branch from 2d91198 to 457204e Compare April 8, 2024 12:00
@@ -164,7 +164,6 @@ def sample_prior(nx, ny):
)


@pytest.mark.skip(reason="Very flaky with scheduler")
Copy link
Contributor

Choose a reason for hiding this comment

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

thank you for not forgetting this! 😄

@@ -215,14 +225,18 @@ async def _monitor_and_handle_tasks(
)
logger.error(
(
f"Exception in scheduler task: {task_exception}\n"
f"Exception in scheduler task {task.get_name()}: {task_exception}\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

This should perhaps be a separate commit, as it is unrelated to fixing the premature closing of publisher.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now it's in two commits. 1) improving exception messages 2) the actual fix

@xjules xjules force-pushed the unbox_scheduler branch 2 times, most recently from 6f85d2d to ab1bf8f Compare April 8, 2024 12:34
xjules and others added 2 commits April 8, 2024 14:50
- Add _publisher_done event and CLOSE_PUBLISHER_SENTINEL to make sure that the connection was established and all events were sent before the cancellation happens.
- Supress CancelledError when task gets cancelled for long running jobs
- Ignore cancellation in job task
- Add test for scheduler publishings its events to a websocket with
publisher_done set Event.

Co-authored-by: Håvard Berland <[email protected]>
@xjules xjules force-pushed the unbox_scheduler branch from ab1bf8f to d3b2544 Compare April 8, 2024 12:55
@xjules xjules requested a review from berland April 8, 2024 12:56
Copy link
Contributor

@berland berland left a comment

Choose a reason for hiding this comment

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

splendid

@xjules xjules merged commit 4ababea into equinor:main Apr 8, 2024
37 checks passed
@xjules xjules deleted the unbox_scheduler branch April 8, 2024 13:27
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.

Scheduler is flaky, "Too many realizations failed"
4 participants