-
Notifications
You must be signed in to change notification settings - Fork 295
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
Strict IKernel with notebook document linked in core. #10817
Conversation
Co-authored-by: Don Jayamanne <don.jayamanne@outlook.com>
Codecov Report
@@ Coverage Diff @@
## main #10817 +/- ##
========================================
- Coverage 63% 52% -11%
========================================
Files 486 482 -4
Lines 33679 33758 +79
Branches 5496 5505 +9
========================================
- Hits 21297 17750 -3547
- Misses 10337 14284 +3947
+ Partials 2045 1724 -321
|
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.
Pretty neat and complete! From my limited perspective, this looks good!
if (notebook) { | ||
this.notebookData.delete(notebook.uri.toString()); | ||
} | ||
this.notebookData.delete(kernel.notebook.uri.toString()); |
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.
Maybe out of scope for this PR, but I thought we removed almost all cases of using uri.toString(). Seems like this should maybe WeakMap the NotebookDocument instead like we do in other places.
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 like it, nice to just have a .notebook instead of the helper function all over the place.
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 think this is changing the 3rd party API.
Before this change, 3rd parties could get kernels from live notebooks. Now they can only find kernels that they've created.
I think the 3rd party kernel provider has to search in the original kernel provider too.
Sorry I didn't read all the way down to the API section. It's using both. My initial feeling was that the 3rd party provider should provide both but thinking about it more, it makes more sense for the API to do it in the API layer. |
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 wonder if there still might be problems though with internal code not seeing 3rd party kernels at all? If a 3rd party creates a kernel for a notebook and then the user runs a cell, it won't use it. So from the 3rd party's point of view they're using the wrong kernel.
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.
No it looks like you've handled that case in the KernelConnector code.
This PR tries to separate jupyter kernels created for notebook documents and non notebook documents.
The motivation behind this is having a clear separation between the use of kernels created for notebooks or non-notebooks. Currently kernels created for non-notebooks are only created by 3rd party extensions and breaking the 1 to 1 mapping between
IKernel
toNotebookDocument
. That means the core system (notebook and interactive window) needs to handle theundefined
case when runninggetAssociatedNotebookDocument
, even if that should never happen.As @DonJayamanne and I discussed offline, with changes in this PR, internal components only need to care about Kernels that are attached to a
NotebookDocument
. Thesrc/kernels
component will offerIKernel
which always ties toNotebookDocument
Kernels created by third party only matters to
src/kernels
component (e.g., execution related code) and API (this is why we have such kernels).package-lock.json
has been regenerated by runningnpm install
(if dependencies have changed).