I am building a VS Code extension in TypeScript that needs to fetch and list all available Jupyter kernels. I am using the Jupyter extension API provided by the ms-toolsai.jupyter extension.
Here is the code I am using:
async function getJupyterKernels(): Promise<any[]> {
const jupyterExt = vscode.extensions.getExtension("ms-toolsai.jupyter");
if (!jupyterExt) {
vscode.window.showErrorMessage("Jupyter extension is not installed.");
return [];
}
if (!jupyterExt.isActive) {
await jupyterExt.activate();
}
try {
const api = jupyterExt.exports;
if (!api) {
vscode.window.showErrorMessage("Jupyter API is unavailable.");
return [];
}
const kernelService = await api.getKernelService();
if (!kernelService) {
vscode.window.showErrorMessage("Could not get Jupyter kernel service.");
return [];
}
return kernelService.getKernelSpecs();
} catch (error) {
console.log(error, "error-error-error");
vscode.window.showErrorMessage(`Error fetching Jupyter kernels: ${error}`);
return [];
}
}
However, I am getting the following error message:
Please contact the Jupyter Extension to get access to the Kernel API. Publisher my-vscode-extensions
What I have tried:
- Ensured that the Jupyter extension (ms-toolsai.jupyter) is installed and activated.
- Verified that jupyterExt.exports is available.
- Tried to access the getKernelService() method but encountered the error mentioned above. My questions:
- Is there an official way to access the Jupyter Kernel API in VS Code extensions?
- Am I missing any permissions or configurations to properly access the Jupyter Kernel API?
- How can I resolve the error message that says "Please contact the Jupyter Extension to get access to the Kernel API"? Any help or guidance would be greatly appreciated.