如何在 development/debugging 期间自动更新 jupyter notebook 扩展?
How to auto-update jupyter notebook extension during development/debugging?
我尝试为 Jupyter Notebook 编写自定义扩展,如下所述:
https://towardsdatascience.com/how-to-write-a-jupyter-notebook-extension-a63f9578a38c
我在 Windows7 上使用 Chrome 开发人员工具来检查和编辑我的自定义扩展的 Javascript 源代码。我希望当按 F5 更新页面时,我更改的源代码将立即应用。
但是,正如上述文章所述,我必须运行
jupyter-contrib-nbextensions.exe install
并重新启动服务器以刷新笔记本扩展并查看我的代码更改的效果。
在玩弄 developing/debugging 扩展程序时,在每次小改动后都这样做非常烦人。
=>是否有某种自动 updating/reloading 扩展的开发选项?
作为解决方法,我写了一个扩展“工作区模块”:
https://github.com/stefaneidelloth/treezjs/tree/master/jupyter_notebook_extension/workspace_module
该扩展的目的是导入文件“workspace.js”(如果它存在于笔记本文件夹中)。我的分机的main.js是:
define([
'require',
'jquery',
'base/js/namespace',
'base/js/events',
'notebook/js/codecell'
], function(
requirejs,
$,
Jupyter,
events,
codecell
) {
var load_ipython_extension = function() {
if (Jupyter.notebook !== undefined && Jupyter.notebook._fully_loaded) {
init();
} else {
console.log("[workspace_module] Waiting for notebook availability")
events.on("notebook_loaded.Notebook", function() {
init();
})
}
};
function init(){
console.log("[workspace_module] trying to load workspace.js")
var moduleScript = document.createElement('script');
moduleScript.setAttribute('type','module');
moduleScript.setAttribute('src','workspace.js');
document.body.appendChild(moduleScript);
}
return {
load_ipython_extension: load_ipython_extension
};
});
workspace.js 重定向到我的实际分机:
import './treezjs/src/treezJupyterNotebook.js';
这样,我就可以在开发过程中调整我的代码,而无需 re-execute 安装命令。
我尝试为 Jupyter Notebook 编写自定义扩展,如下所述: https://towardsdatascience.com/how-to-write-a-jupyter-notebook-extension-a63f9578a38c
我在 Windows7 上使用 Chrome 开发人员工具来检查和编辑我的自定义扩展的 Javascript 源代码。我希望当按 F5 更新页面时,我更改的源代码将立即应用。
但是,正如上述文章所述,我必须运行
jupyter-contrib-nbextensions.exe install
并重新启动服务器以刷新笔记本扩展并查看我的代码更改的效果。
在玩弄 developing/debugging 扩展程序时,在每次小改动后都这样做非常烦人。
=>是否有某种自动 updating/reloading 扩展的开发选项?
作为解决方法,我写了一个扩展“工作区模块”:
https://github.com/stefaneidelloth/treezjs/tree/master/jupyter_notebook_extension/workspace_module
该扩展的目的是导入文件“workspace.js”(如果它存在于笔记本文件夹中)。我的分机的main.js是:
define([
'require',
'jquery',
'base/js/namespace',
'base/js/events',
'notebook/js/codecell'
], function(
requirejs,
$,
Jupyter,
events,
codecell
) {
var load_ipython_extension = function() {
if (Jupyter.notebook !== undefined && Jupyter.notebook._fully_loaded) {
init();
} else {
console.log("[workspace_module] Waiting for notebook availability")
events.on("notebook_loaded.Notebook", function() {
init();
})
}
};
function init(){
console.log("[workspace_module] trying to load workspace.js")
var moduleScript = document.createElement('script');
moduleScript.setAttribute('type','module');
moduleScript.setAttribute('src','workspace.js');
document.body.appendChild(moduleScript);
}
return {
load_ipython_extension: load_ipython_extension
};
});
workspace.js 重定向到我的实际分机:
import './treezjs/src/treezJupyterNotebook.js';
这样,我就可以在开发过程中调整我的代码,而无需 re-execute 安装命令。