Hello Everyone,
This is my first post here. I have recently got a chance to work with JupyterLab eco system, and started to develop JupyterLab extension.
As part of my extension, I am suppose to create a new notebook → fill up code cell with python code snippet → execute this snippet.
Good thing is I could achieve the goal, however, when I create new notebook, I see an error in console - “Canceled future for execute_request message before replies were done”. I am using following code to create new notebook.
const createNew = async (cwd: string, kernelName?: string) => {
// docManager.createNew(cwd + '/example', FACTORY, { name: kernelName });
return commands
.execute('docmanager:new-untitled', { path: cwd, type: 'notebook' })
.then(model => { // Error is reported here.
if (model != undefined) {
return commands.execute('docmanager:open', {
path: model.path,
factory: FACTORY,
kernel: { name: kernelName }
});
}
})
.catch(e => console.log(e));
};
const populateCode = () => {
// Modelled after completer-extension's notebooks plugin
notebooks.widgetAdded.connect(
async (sender: INotebookTracker, panel: NotebookPanel) => {
await panel.revealed;
await panel.sessionContext.ready;
let activeCell = panel.content.activeCell;
let editor = activeCell?.editor ?? null;
const session = panel.sessionContext;
if (editor) {
editor.model.value.text = "print('Hello') \nprint('World')";
if (activeCell instanceof CodeCell) {
void CodeCell.execute(activeCell, session);
}
}
}
);
};
commands.addCommand(CommandIDs.open, {
label: 'Open',
execute: async args => {
await createNew(cwd, kernelName);
populateCode();
},
icon: folderIcon.bindprops({ stylesheet: 'menuItem' }),
mnemonic: 0
});
Now, if I comment “populateCode()”, I don’t face above mentioned issue. Can you please guide what might be causing this issue / direction to resolve this?
Thank you.
Best regards
Jigar.