Missing kernelspec on new notebooks created in VSCode
See original GitHub issueDescribe the issue Notebooks created in VSCode don’t have a kernel spec until you run them, which causes issues when trying to run them with Elyra.
To Reproduce Steps to reproduce the behavior:
- Create and open an
.ipynb
file in VSCode - Add some content to it
- Save the notebook file
- Open the notebook Jupyter Lab
- Add the notebook to an Elyra Pipeline
- Set a runtime image for the node
- Submit notebook for local execution
- Get error
KeyError: 'kernelspec'
Screenshots or log output
Expected behavior Either a better error message with steps to resolve the issue, or just magically run somehow. (This can be fixed by opening the notebook in Jupyter Lab and re-saving the file or by running the notebook at least once in VSCode)
Deployment information Describe what you’ve deployed and how:
- Elyra version: 1.5.3
- Operating system: macos
- Installation source: from source
- Deployment type: local installation
Pipeline runtime environment If the issue is related to pipeline execution, identify the environment where the pipeline is executed
- Local execution
Notebook source:
{
"metadata": {
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": 3
},
"orig_nbformat": 2
},
"nbformat": 4,
"nbformat_minor": 2,
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(\"hello world\")"
]
}
]
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (13 by maintainers)
Top Results From Across the Web
Jupyter notebooks in VSCode not showing up to date python ...
I tried both from the button, select kernel and through the command palette. I usually start vscode from the command line, with my...
Read more >Notebooks - Language attribute in kernelspec metadata gone ...
Steps to Reproduce (in both VS Code and Jupyer):. Create new notebook; Save. VS Code Jupyter Notebook. image. Jupyter Notebook. image. Not ...
Read more >November 2022 (version 1.74) - Visual Studio Code
This picker will group all kernels by their source (for example: Jupyter Kernel, Python Environment, etc.) when you have latest Jupyter extension installed....
Read more >What to do when things go wrong - The Jupyter Notebook
First, have a look at the common problems listed below. If you can figure it out from these notes, it will be quicker...
Read more >NET Core with Jupyter Notebooks - Available today | Preview 1
Jupyter Notebook with .NET core is here! You can now write C# and F# code in a Jupyter notebook. Create your .NET Jupyter...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If we’re simply trying to improve the user experience with a better message or possibly interrogating the language-info, then I can take this. The crux of this issue is that papermill makes an assumption that the kernelspec will be in the NB metadata. Since they allow a
kernel_name
to override that, I’m sure the idea is that, in those cases, they expect the user (vscode) to provide the kernel name.I think the right thing to do here is add best-fit logic like we do in kfp, but extend it to include checks against the language-info (which should also apply to kfp).
I don’t think we want to catch
KeyError
from papermill, but I suppose that could be a fallback should we run into issues with language-info code.So the idea would be - since this is local processing - check the NB metadata, if a kernelspec exists, done (let default scenario happen - even if that particular kernel is not defined, the error message will be appropriate), else, look at language-info to determine language, then hit the kernelspec manager to find matching language. We should probably check if the “default” kernel is also a language match and let that override any (if it matches the lang). Once found, set the
kernel_name
to that when calling Papermill.I’ll go ahead and assign this to me.
Ok - per a side-bar discussion, the server will detect missing kernelspec information. If the information is present, but the kernel is not available, we’ll use the language indicator and select the first kernel found that corresponds to that language (which I believe is the case today). If no language (or kernelspec information) is present, we’ll use the default kernel name configured on the notebook server’s KernelManager. A warning message should be produced indicating this defaulting behavior has taken place.
It also sounds like VSCode “insiders” will be updating the notebook with kernelspec information on first use. However, the server changes described above are good to have in place anyway.
Thanks @bourdakos1!