Skip to content

Commit

Permalink
Show the list of kernels in the running tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
jtpio committed May 20, 2020
1 parent 0d5d6f2 commit de826c2
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 5 deletions.
3 changes: 3 additions & 0 deletions packages/jupyterlab-voila/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
"@jupyterlab/fileeditor": "^2.0.0",
"@jupyterlab/mainmenu": "^2.0.0",
"@jupyterlab/notebook": "^2.0.0",
"@jupyterlab/running": "^2.1.1",
"@jupyterlab/services": "^5.0.0",
"@jupyterlab/ui-components": "^2.1.1",
"react": "~16.9.0",
"react-dom": "~16.9.0"
},
Expand Down
67 changes: 63 additions & 4 deletions packages/jupyterlab-voila/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ import {
INotebookModel
} from "@jupyterlab/notebook";

import { IRunningSessionManagers, IRunningSessions } from "@jupyterlab/running";

import { KernelAPI, KernelManager } from "@jupyterlab/services";

import { notebookIcon } from "@jupyterlab/ui-components";

import { toArray } from "@lumino/algorithm";

import { CommandRegistry } from "@lumino/commands";

import { ReadonlyJSONObject } from "@lumino/coreutils";
Expand Down Expand Up @@ -81,9 +89,9 @@ class VoilaRenderButton
}

/**
* Initialization data for the jupyterlab-voila extension.
* Initialization data for the jupyterlab-voila preview plugin.
*/
const extension: JupyterFrontEndPlugin<IVoilaPreviewTracker> = {
const preview: JupyterFrontEndPlugin<IVoilaPreviewTracker> = {
id: "@jupyter-voila/jupyterlab-preview:plugin",
autoStart: true,
requires: [INotebookTracker],
Expand Down Expand Up @@ -158,7 +166,7 @@ const extension: JupyterFrontEndPlugin<IVoilaPreviewTracker> = {
};

if (settingRegistry) {
Promise.all([settingRegistry.load(extension.id), app.restored])
Promise.all([settingRegistry.load(preview.id), app.restored])
.then(([settings]) => {
updateSettings(settings);
settings.changed.connect(updateSettings);
Expand Down Expand Up @@ -235,4 +243,55 @@ const extension: JupyterFrontEndPlugin<IVoilaPreviewTracker> = {
}
};

export default extension;
/**
* A plugin to show the list of running Voila kernels.
*/
const kernels: JupyterFrontEndPlugin<void> = {
id: "@jupyter-voila/jupyterlab-preview:kernels",
autoStart: true,
requires: [IRunningSessionManagers],
activate: (app: JupyterFrontEnd, managers: IRunningSessionManagers) => {
const kernelManager = new KernelManager();
const filterKernels = (m: KernelAPI.IModel) => {
// TODO: filter voila kernels only
return true;
};

managers.add({
name: "Voila",
running: () => {
return toArray(kernelManager.running())
.filter(filterKernels)
.map(model => new RunningKernel(model));
},
shutdownAll: () => kernelManager.shutdownAll(),
refreshRunning: () => kernelManager.refreshRunning(),
runningChanged: kernelManager.runningChanged
});

class RunningKernel implements IRunningSessions.IRunningItem {
constructor(model: KernelAPI.IModel) {
this._model = model;
}
open() {
// no-op
}
shutdown() {
return kernelManager.shutdown(this._model.id);
}
icon() {
return notebookIcon;
}
label() {
return this._model.id;
}
labelTitle() {
return `name: ${this._model.name}`;
}

private _model: KernelAPI.IModel;
}
}
};

export default [preview, kernels];
55 changes: 54 additions & 1 deletion packages/jupyterlab-voila/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,31 @@
react-dom "~16.9.0"
sanitize-html "~1.20.1"

"@jupyterlab/apputils@^2.1.1":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@jupyterlab/apputils/-/apputils-2.1.1.tgz#069dc8214261c01c9e2ef58209137430649d4c01"
integrity sha512-orGzvW2S1k/FjW42dhygq8XJZbQRBTsNXXKFWsqewSn9sNTd3irKjDEwS3Ilce1w+LsS/t3H03xCnsOYPu8LSQ==
dependencies:
"@jupyterlab/coreutils" "^4.1.0"
"@jupyterlab/services" "^5.1.0"
"@jupyterlab/settingregistry" "^2.1.0"
"@jupyterlab/statedb" "^2.1.0"
"@jupyterlab/ui-components" "^2.1.1"
"@lumino/algorithm" "^1.2.3"
"@lumino/commands" "^1.10.1"
"@lumino/coreutils" "^1.4.2"
"@lumino/disposable" "^1.3.5"
"@lumino/domutils" "^1.1.7"
"@lumino/messaging" "^1.3.3"
"@lumino/properties" "^1.1.6"
"@lumino/signaling" "^1.3.5"
"@lumino/virtualdom" "^1.6.1"
"@lumino/widgets" "^1.11.1"
"@types/react" "~16.9.16"
react "~16.9.0"
react-dom "~16.9.0"
sanitize-html "~1.20.1"

"@jupyterlab/attachments@^2.1.0":
version "2.1.0"
resolved "https://registry.yarnpkg.com/@jupyterlab/attachments/-/attachments-2.1.0.tgz#86dd6c02a0ac2e5b6c1221056bed67bd4d933de1"
Expand Down Expand Up @@ -392,7 +417,19 @@
lodash.escape "^4.0.1"
marked "^0.8.0"

"@jupyterlab/services@^5.1.0":
"@jupyterlab/running@^2.1.1":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@jupyterlab/running/-/running-2.1.1.tgz#232029d96e671d8d0b73ad1335220438d6e3ff3d"
integrity sha512-4gzXDIq7UWeVDPjVaOZNz7hB5KnFqy1AscjkCCCCEqSEDp3L6te4e5vkni34CpVKiLDaL0ts2IKcY9omSBcFKw==
dependencies:
"@jupyterlab/apputils" "^2.1.1"
"@jupyterlab/ui-components" "^2.1.1"
"@lumino/coreutils" "^1.4.2"
"@lumino/disposable" "^1.3.5"
"@lumino/signaling" "^1.3.5"
react "~16.9.0"

"@jupyterlab/services@^5.0.0", "@jupyterlab/services@^5.1.0":
version "5.1.0"
resolved "https://registry.yarnpkg.com/@jupyterlab/services/-/services-5.1.0.tgz#891607d87cbe9413219cfe4ceb9905193b85b657"
integrity sha512-xhtDvAdgw+sWNSbpkExCYyJbHxlwhiZYqc07+zhOdYrpxO19k/ZmmyNoYCyfvNLcMQ4JWVBoczI714u1QNLj4w==
Expand Down Expand Up @@ -471,6 +508,22 @@
react-dom "~16.9.0"
typestyle "^2.0.4"

"@jupyterlab/ui-components@^2.1.1":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@jupyterlab/ui-components/-/ui-components-2.1.1.tgz#ace65290ebe3e913e85e574d5d94f3c9f55d244c"
integrity sha512-VZWtJud5XXzSTK6HJebbqg7TkJmvuRk5K+F30u+pgX7PStC4j8OFD7IXCreLWmrvxoVvEXd4GFH2sVng5cgsQA==
dependencies:
"@blueprintjs/core" "^3.22.2"
"@blueprintjs/select" "^3.11.2"
"@jupyterlab/coreutils" "^4.1.0"
"@lumino/coreutils" "^1.4.2"
"@lumino/signaling" "^1.3.5"
"@lumino/virtualdom" "^1.6.1"
"@lumino/widgets" "^1.11.1"
react "~16.9.0"
react-dom "~16.9.0"
typestyle "^2.0.4"

"@lumino/algorithm@^1.2.3":
version "1.2.3"
resolved "https://registry.yarnpkg.com/@lumino/algorithm/-/algorithm-1.2.3.tgz#4ab9883d7e9a5b1845372a752dcaee2a35a770c6"
Expand Down

0 comments on commit de826c2

Please sign in to comment.