Datalayer Core
JupyterLab Extensions
Use these snippets to activate the Datalayer plugins.
import { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application';
import { doActivateDatalayerExtension } from ".";
const plugin: JupyterFrontEndPlugin<void> = {
id: '@datalayer/jupyter-kernels:activator',
description: 'Jupyter Kernels Activator.',
autoStart: true,
requires: [],
activate: (app: JupyterFrontEnd) => {},
activateDatalayerExtension(app);
}
export default plugin;
import { CommandRegistry } from "@lumino/commands";
import { JupyterFrontEnd } from "@jupyterlab/application";
A
const ACTIVATE_DATALAYER_EXTENSION_COMMAND = "@datalayer/jupyter-kernels:datalayer:activate";
export function activateDatalayerExtension(app: JupyterFrontEnd) {
try {
function doActivateDatalayerExtension(
commands: CommandRegistry,
changes: CommandRegistry.ICommandChangedArgs,
) {
if (
changes.type === "added" &&
changes.id === ACTIVATE_DATALAYER_EXTENSION_COMMAND
) {
commands
.execute(ACTIVATE_DATALAYER_EXTENSION_COMMAND)
.catch((reason: any) => {
console.warn("Error while activating the GPU extension", reason);
});
}
commands.commandChanged.disconnect(doActivateDatalayerExtension);
}
if (app.commands.hasCommand(ACTIVATE_DATALAYER_EXTENSION_COMMAND)) {
doActivateDatalayerExtension(app.commands, {
id: ACTIVATE_DATALAYER_EXTENSION_COMMAND,
type: "added",
});
} else {
app.commands.commandChanged.connect(doActivateDatalayerExtension);
}
} catch (e) {
console.warn("Error while activating the Datalayer extension", e);
}
}