Allow opening notebooks without starting a kernel#17798
Conversation
|
Thanks for making a pull request to jupyterlab! |
|
Since CI is passing, I'll mark the PR as ready for review, so folks can try it locally or on Binder: https://mybinder.org/v2/gh/jtpio/jupyterlab/open-no-kernel?urlpath=lab Happy to hear what people think and iterate more on it if needed. |
| const hasNotebooks = selectedItems.some(item => item.type === 'notebook'); | ||
|
|
||
| if (hasNotebooks) { | ||
| items.push( | ||
| openWith.addItem({ | ||
| args: {}, | ||
| command: CommandIDs.openNotebookNoKernel | ||
| }) | ||
| ); | ||
| } |
There was a problem hiding this comment.
What do you think about not adding a new command and just reusing the existing open command and passing the kernelPreference argument to it? This would require changing .some to .every but this aligns with how it is done already:
jupyterlab/packages/filebrowser-extension/src/index.ts
Lines 749 to 766 in 47fcd3d
There was a problem hiding this comment.
Let me check, looks like we will need to use the filebrowser:open command to be able to handle multiple selections, and also pass the kernelPreference around to that command and to docmanager:open too.
krassowski
left a comment
There was a problem hiding this comment.
Thank you @jtpio - two minor suggestions.
Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
|
Looking good over on https://jupyterlab--17798.org.readthedocs.build/en/17798/user/commands.html#docmanager-open, thanks @krassowski for the lint pass!
|
|
I wrote up a few thoughts about this general approach at #18343, and proposed a way to make customizing the kernel startup behavior more institutional. |

References
Fixes #4040
Related issue in Notebook: jupyter/notebook#3170
The factory approach mentioned in #12019 sounded like a good start, but it also brought a couple of challenges as mentioned in this comment: #12019 (comment).
So this PR takes a different approach by defining a command and putting it in the context menu instead of trying to define a new notebook factory.
Currently, this is specific to the notebook only, but I wanted to open the PR early to get an idea of what people thought about this approach before trying to generalize these to other types of documents that can be backed by a kernel (which could likely be done in a follow-up PR).
Code changes
kernelPreference?: ISessionContext.IKernelPreferencewhen opening a documentUser-facing changes
jupyterlab-notebook-no-kernel.mp4
Backwards-incompatible changes
None