question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing kernelspec on new notebooks created in VSCode

See original GitHub issue

Describe 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:

  1. Create and open an .ipynb file in VSCode
  2. Add some content to it
  3. Save the notebook file
  4. Open the notebook Jupyter Lab
  5. Add the notebook to an Elyra Pipeline
  6. Set a runtime image for the node
  7. Submit notebook for local execution
  8. Get error KeyError: 'kernelspec'

Screenshots or log output Screen Shot 2021-02-25 at 10 38 17 AM

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:closed
  • Created 3 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
kevin-batescommented, Mar 25, 2021

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.

1reaction
kevin-batescommented, Feb 25, 2021

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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found