Giselle S
Giselle S

Reputation: 11

How to connec to current jupyter notebook kernel in vscode extension development

I'm trying devleop a jupyter notebook extension for vscode that works specifically with dataframes (in pandas). As part of this project, I need to access data stored in dataframes within the notebook environment. To achieve this, I attempted to connect to the notebook's currently running kernel, following the approach:

const jupyterExt = vscode.extensions.getExtension('ms-toolsai.jupyter');     
if (!jupyterExt) {       return;     }      
await jupyterExt.activate();  
    
const kernelService = await jupyterExt.exports.getKernelService();     
if (!kernelService) {       
    console.log("Kernel service is not available.");       
    return;     
} 

However, my attempts were all unsuccessful, resulting in the error message: "Please contact the Jupyter Extension to get access to the Kernel API. Publisher undefined_publisher." Any insights on how to correctly establish a connection to the kernel service or alternative methods to access the kernel's capabilities?

Also, I've tried to implement a "Controller" myself, which is a notebook kernel in vscode, and it still doesn't work. Correct me if I'm wrong, I believe I should try to communicate with the existing kernel instead of defining a new one myself.

Any help would be really appreciated!!

  1. I tried to connect directly to the current jupyter notebook kernel using the method above, but was unsuccessful.
  2. I tried to define a new "Controller" which is the vscode APT for a notebook kernel, but this gave me a completely new kernel and I was unable to mimic normal notebook execution of cells in this new kernel.

Upvotes: 1

Views: 47

Answers (0)

Related Questions