-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #923 from microsoft/jupyterKernelExecutionApi
Sample extension using Jupyter Execution API
- Loading branch information
Showing
11 changed files
with
2,144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/**@type {import('eslint').Linter.Config} */ | ||
// eslint-disable-next-line no-undef | ||
module.exports = { | ||
root: true, | ||
parser: '@typescript-eslint/parser', | ||
plugins: [ | ||
'@typescript-eslint', | ||
], | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
], | ||
rules: { | ||
'semi': [ | ||
2, | ||
"always" | ||
], | ||
'@typescript-eslint/no-unused-vars': 0, | ||
'@typescript-eslint/no-explicit-any': 0, | ||
'@typescript-eslint/explicit-module-boundary-types': 0, | ||
'@typescript-eslint/no-non-null-assertion': 0, | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"recommendations": [ | ||
"dbaeumer.vscode-eslint", | ||
"ms-toolsai.jupyter" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// A launch configuration that compiles the extension and then opens it inside a new window | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
{ | ||
"configurations": [ | ||
{ | ||
"args": [ | ||
"--extensionDevelopmentPath=${workspaceFolder}" | ||
], | ||
"name": "Run Extension", | ||
"outFiles": [ | ||
"${workspaceFolder}/out/**/*.js" | ||
], | ||
"preLaunchTask": "npm: compile", | ||
"request": "launch", | ||
"trace": true, | ||
"type": "extensionHost" | ||
} | ||
], | ||
"version": "0.2.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"search.exclude": { | ||
"out": true | ||
}, | ||
"typescript.tsc.autoDetect": "off" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"type": "npm", | ||
"script": "compile", | ||
"problemMatcher": ["$tsc"], | ||
"group": "build" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.vscode/** | ||
.vscode-test/** | ||
out/test/** | ||
src/** | ||
.gitignore | ||
.yarnrc | ||
vsc-extension-quickstart.md | ||
**/tsconfig.json | ||
**/.eslintrc.json | ||
**/*.map | ||
**/*.ts | ||
**/*.tsbuildinfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Jupyter Server Provider Sample | ||
|
||
This is a very simple extension sample demonstrating the use of the Jupyter Extension API allowing other extensions to execute code against Jupyter Kernels. | ||
|
||
- The sample lists finds kernels associated with notebooks that are currently open in the workspace. | ||
- The sample the filters the kernels by language, focusing on Python kernels. | ||
- Upon selecting a Python kernel, code selected by the user is executed against the selected kernel | ||
- The output is displayed in an output panel. | ||
- The sample demonstrates the ability to retrieve outputs of various mime types, including streamed output. | ||
|
||
## Running this sample | ||
|
||
1. `cd jupyter-kernel-execution-sample` | ||
1. `code .`: Open the folder in VS Code | ||
1. Run `npm install` in terminal to install the dependencies | ||
1. Run the `Run Extension` target in the Debug View. This will: | ||
- Start a task `npm: watch` to compile the code | ||
- Run the extension in a new VS Code window | ||
1. Open a Jupyter Notebook and select a Python kernel and execute some code. | ||
1. Select the command `Jupyter Kernel API: Execute code against a Python Kernel` | ||
1. Select the a Kernel and then select the Code to execute. | ||
1. Watch the output panel for outputs returned by the kernel. | ||
|
||
### Notes: | ||
|
||
1. Make use of the `language` property of the kernel to ensure the language of the code matches the kernel. | ||
2. `getKernel` API can can return `undefined` if the user does not grant the extension access to the kernel. | ||
3. Access to kernels for each extension is managed via the command `Manage Access To Jupyter Kernels`. |
Oops, something went wrong.