创建自定义内核#
提示
我们建议您首先了解如何创建 JupyterLab 扩展:创建新的前端扩展
引导服务器扩展#
设置好服务器扩展后,添加以下插件来注册内核
/**
* A plugin to register the custom kernel.
*/
const kernel: JupyterFrontEndPlugin<void> = {
id: 'my-custom-kernel:plugin',
autoStart: true,
requires: [IKernelSpecs],
activate: (app: JupyterFrontEnd, kernelspecs: IKernelSpecs) => {
kernelspecs.register({
spec: {
name: 'custom',
display_name: 'Custom Kernel',
language: 'text',
argv: [],
resources: {
'logo-32x32': '',
'logo-64x64': '',
},
},
create: async (options: IKernel.IOptions): Promise<IKernel> => {
return new CustomKernel(options);
},
});
},
};
Echo 内核示例#
另一种快速引导新内核的方法是从现有内核开始。
jupyterlite-echo-kernel 是一个示例内核,它返回用户提交的输入
它很简单,仅用于演示目的。
如果您想从该内核开始
对于 repo
按照开发说明在本地构建内核
一旦本地设置就绪,您就可以迭代内核的实际逻辑并开始实现协议
示例#
为了获得灵感,您还可以查看其他 JupyterLite 内核