-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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 token ICellExecutor
providing an entry to customize cell execution
#15830
Conversation
Thanks for making a pull request to jupyterlab! |
Failure are not related. cc @echarles for awareness |
*/ | ||
export const cellExecutor: JupyterFrontEndPlugin<ICellExecutor> = { | ||
id: '@jupyterlab/notebook-extension:cell-executor', | ||
description: 'Provides the notebook cell executor.', |
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.
What about console cells? These get executed as well and 90% of the code is shared with notebook. Since this is named ICellExecutor
, should we make it handle either notebook or console (and then if in future another execution context comes along we can easily add it).
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 thought about it. But the two are quite different (presumably because they are separated). So should I try to reconciliate them or should the cell executor has two methods: runNotebookCell
and runConsoleCell
?
For reference, the console code is there:
jupyterlab/packages/console/src/widget.ts
Line 724 in 946f18c
private _execute(cell: CodeCell): Promise<void> { |
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.
So should I try to reconciliate them or should the cell executor has two methods:
runNotebookCell
andrunConsoleCell
?
I am not sure which would be better; I brought it up on the lab call yesterday but there were no strong opinions.
My thoughts:
- The disadvantage of reconciliating them into one method is that implementers might need to do a few conditional logic blocks depending on the execution context
- The disadvantage of two methods is that implementers would need to provide both, or we would need to have a default implementation as a fallback if we decided to make them optional (but then an interface with all methods optional risks that the implementer will fail to provide any if they make a typo and will be confused why nothing is working).
Thinking more about it, maybe there should be two separate plugins:
@jupyterlab/notebook-extension:cell-executor
providingINotebookCellExecutor
@jupyterlab/console-extension:cell-executor
providingIConsoleCellExecutor
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.
Separate plugins sounds better in the sense that additional execution context means just a new plugin, and that there is no need to have any fallbacks/optional methods, and no conditional logic.
The downside is that adding new execution context does require implementers to add a new plugin, but realistically this is something which does not happen frequently so I think this is a good trade-off.
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.
Having two plugins seems a good path. Thanks for bringing this PR for discussion at the call.
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.
So I think the minimum required change for this PR would be renaming ICellExecutor
to INotebookCellExecutor
.
57cffa1
to
2368a58
Compare
Ok I pushed this one forward; 🤞 for the CI. For the reviewer I have a final wording question, should it be |
I like how |
Kicking CI after bot updates |
The test failure in
|
Thanks @krassowski I fixed the code and rename the |
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.
Just one suggestion on renaming IExecutionOptions
or nesting them in namespaces.
Thanks @krassowski I went for the namespacing as it is a common pattern in core and will be a good fit in case new API are added to the executors. I used |
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.
Thank you @fcollonval.
I would personally prefix the namespaces with I
(which is already common in the codebase) to take advantage of declaration merging, but I know it was called confusing by some new contributors so I am equally happy to go with the current version.
done in 71cc3c9 |
The visual test failure is relevant. Maybe I should mock the descriptions, but for now updating it. bot please update documentation snapshots |
Documentation snapshots updated. |
Kicking the CI |
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.
Flaky snapshot update (a kernel from another test was captured). I feel like we need to mock the kernels out for some tests.
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.
Thanks for the help
…ion (jupyterlab#15830) * Add token `ICellExecutor` providing an entry to customize cell execution * Apply review comments to the notebook package * Add console cell executor * Some fixes * Automatic application of license header * Fix unit test * Align naming * Namespace the interfaces and rename them * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Prefix namespace with `I` * Update Playwright Snapshots * Revert flaky snapshot update --------- Co-authored-by: Frédéric Collonval <fcollonval@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
References
Follow-up of the discussion jupyterlab/frontends-team-compass#229 (comment)
This will allow experimentation like #15448 to happen outside of core. It will also open the box for handling non-standard cell type execution for example (e.g. SQL cell).
Code changes
Provide the
Private.runCell
generic function as a plugin to allow customization.User-facing changes
None
Backwards-incompatible changes
None