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

[add] detect and recover from kernel auto restarts #5558

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

shibbas
Copy link
Contributor

@shibbas shibbas commented Jun 3, 2021

Checklist

  • I have read the Contributor Guide
  • I have updated the changelogs/current_changelog.md file with some information about the change that I am making the appropriate file.
  • I have validated or unit-tested the changes that I have made.
  • I have run through the TEST_PLAN.md to ensure that my change does not break anything else.

Context

This is PR for the issue mentioned at #5548
When the Jupyter option for kernel auto-restart is turned on (which it by default), then the kernel will be restarted on the server automatically. You get a "restarting" status followed by a "starting" message from the kernel. Server uses "restarting" only for auto-restart scenarios.

This PR adds a new epic to detect the successful auto-restart and nudge the kernel back into the idle state. Also raises an action that applications can use to raise notifications since the Kernel state is lost.

Only applicable to Jupyter host type.

Before

// Side note: The CSS for nteract_on_jupyter application seems to be broken in dev setup hence the weird cell layout.
After kernel auto-restart, status gets stuck in starting state and cell execution does not proceed.
kernelautorestart-before

After

After kernel auto-restart, kernel is back to Idle and cell execution can continue.
kernelautorestart-after

@todo
Copy link

todo bot commented Jun 3, 2021

test can't seem to identify next on subject. For now, check before calling

// TODO: test can't seem to identify next on subject. For now, check before calling
if (kernel.channels.next) {
kernel.channels.next(kernelInfoRequest());
}
}),
map(() =>


This comment was generated by todo based on a TODO comment in 7fc02ba in #5558. cc @shibbas.

@vercel
Copy link

vercel bot commented Jun 3, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/nteract/site/ATkM8NZdPXaB51a4yLx9MrX7cLCi
✅ Preview: https://site-git-fork-shibbas-kernelautorestartdetection-nteract.vercel.app

@todo
Copy link

todo bot commented Jun 3, 2021

test can't seem to identify next on subject. For now, check before calling

// TODO: test can't seem to identify next on subject. For now, check before calling
if (kernel.channels.next) {
kernel.channels.next(kernelInfoRequest());
}
}),
map(() =>


This comment was generated by todo based on a TODO comment in a44dbb5 in #5558. cc @shibbas.

@captainsafia captainsafia requested review from rgbkrk and MSeal June 4, 2021 04:24
@shibbas shibbas changed the title detect and recover from kernel auto restarts [add] detect and recover from kernel auto restarts Jun 4, 2021
@shibbas
Copy link
Contributor Author

shibbas commented Jun 7, 2021

Please let me know if you need me to provide any more information.

Copy link
Member

@rgbkrk rgbkrk left a comment

Choose a reason for hiding this comment

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

This is great and I learned a bit more RxJS while reviewing. Thanks!

{
header: { msg_type: "status" },
content: { execution_state: "starting" }
}) as Subject<any>,
Copy link
Member

Choose a reason for hiding this comment

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

Heh, this works nicely for tests. 😎

/**
* Jupyter has options to automatically restart the kernel on crash for a max-retry of 5 retries.
* Monitor for the kernel to have successfully restarted (sent as a "restarting" status followed by a "starting").
* If all 5 retries fail, the kernel status is reported as "dead".
Copy link
Member

Choose a reason for hiding this comment

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

👍

* Monitor for the kernel to have successfully restarted (sent as a "restarting" status followed by a "starting").
* If all 5 retries fail, the kernel status is reported as "dead".
*
* @oaram {ActionObservable} action$ ActionObservable for LAUNCH_KERNEL_SUCCESSFUL action
Copy link
Member

Choose a reason for hiding this comment

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

@oaram -> @param


return kernel.channels.pipe(
kernelStatuses(),
pairwise(),
Copy link
Member

Choose a reason for hiding this comment

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

Wow this one is new to me, very cool.

),
tap(() => {
// to avoid getting stuck in the "starting" state, nudge kernel with kernel_info_request to bring the status to Idle.
// TODO: test can't seem to identify next on subject. For now, check before calling
Copy link
Member

@rgbkrk rgbkrk Jun 21, 2021

Choose a reason for hiding this comment

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

Since channels is a plain observable in some of the tests rather than a subject, it doesn't have .next.

@captainsafia
Copy link
Member

@rgbkrk Thanks for taking the time to review!

@shibbas Heads up that automatic releases are now enabled on the repo (see #5568 for more info). To support automated releases, please make sure that the commits in this PR adhere to the conventional commit format (see https://www.conventionalcommits.org/en/v1.0.0/). Once this PR is merged, a release will be triggered for the modified packages based on the commit message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants