Upgrade JupyterLab dependencies to 0.17.2, update build rules and README

This commit is contained in:
Andrew Head 2018-11-26 10:55:09 -08:00
Родитель 30ace17c53
Коммит 57f9e88b56
4 изменённых файлов: 36 добавлений и 25 удалений

Просмотреть файл

@ -51,6 +51,17 @@ But I don't know if either of these *really* fixed the issue. They're worth tryi
Then run `jupyter notebook` and the extension will be running.
### `500` message when launching Jupyter notebook
Install these versions of Jupyter notebook and dependencies
to see something working, before trying out other versions:
```
nbconvert==5.3.1
nbformat==4.4.0
notebook==5.6.0
```
### Backend (logging) extension (optional)
If you want to add logging to the project, look in the `src/nb/python` directory. This Python plugin needs to be installed to receive logging requests and save them to file (`~/.jupyter/events.txt`). To register this Python extension in Jupyter notebook or lab, see this guide: https://jupyter-notebook.readthedocs.io/en/latest/extending/handlers.html. As of the time of this writing, installation involves:

Просмотреть файл

@ -14,7 +14,7 @@
"build_nb_extension": "npm run build && npx webpack",
"watch_nb_extension": "npx webpack -w",
"install_nb_extension": "jupyter nbextension install dist && jupyter nbextension enable dist/gather",
"prepack": "npm run clean && npm run build_parser && npm run build",
"prepack": "npm run clean && npm run build && npm run build_parser ",
"clean": "rimraf lib",
"watch": "tsc -w",
"test": "mocha -r ts-node/register src/test/*.test.ts"
@ -27,12 +27,12 @@
"extension": true
},
"dependencies": {
"@jupyterlab/application": "^0.16.3",
"@jupyterlab/apputils": "^0.16.4",
"@jupyterlab/application": "^0.17.2",
"@jupyterlab/apputils": "^0.17.2",
"@jupyterlab/coreutils": "^2.0.0-0",
"@jupyterlab/docmanager": "^0.16.3",
"@jupyterlab/fileeditor": "^0.16.3",
"@jupyterlab/notebook": "^0.16.3",
"@jupyterlab/docmanager": "^0.17.2",
"@jupyterlab/fileeditor": "^0.17.2",
"@jupyterlab/notebook": "^0.17.2",
"@phosphor/widgets": "^1.6.0",
"diff-match-patch": "^1.0.1",
"jquery": "^3.3.1"

Просмотреть файл

@ -7,7 +7,7 @@ import { IClientSession, ICommandPalette } from '@jupyterlab/apputils';
import { Clipboard } from '@jupyterlab/apputils';
import { ICellModel, CodeCell, ICodeCellModel } from '@jupyterlab/cells';
import { IDocumentManager } from '@jupyterlab/docmanager';
import { DocumentRegistry } from '@jupyterlab/docregistry';
import { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry';
import { FileEditor } from '@jupyterlab/fileeditor';
import { NotebookPanel, INotebookModel, Notebook, INotebookTracker } from '@jupyterlab/notebook';
import { IObservableList } from '@jupyterlab/observables';
@ -68,9 +68,9 @@ class ExecutionLoggerExtension implements DocumentRegistry.IWidgetExtension<Note
}
createNew(panel: NotebookPanel, context: DocumentRegistry.IContext<INotebookModel>): IDisposable {
panel.notebook.model.cells.changed.connect(
panel.content.model.cells.changed.connect(
(cells, value) =>
this.onCellsChanged(panel.notebook, panel.session, cells, value),
this.onCellsChanged(panel.content, panel.session, cells, value),
this);
/*
@ -204,13 +204,13 @@ function activateExtension(app: JupyterLab, palette: ICommandPalette, notebooks:
// Choose cell from options or the active cell.
let chosenCell;
if (options.cellId) {
let cells = notebooks.currentWidget.notebook.widgets.filter(cell => cell.model.id == options.cellId);
let cells = notebooks.currentWidget.content.widgets.filter(cell => cell.model.id == options.cellId);
if (cells.length > 0) {
chosenCell = cells.pop();
}
}
if (!chosenCell && panel && panel.notebook && panel.notebook.activeCell && panel.notebook.activeCell.model.type === 'code') {
chosenCell = panel.notebook.activeCell;
if (!chosenCell && panel && panel.content && panel.content.activeCell && panel.content.activeCell.model.type === 'code') {
chosenCell = panel.content.activeCell;
}
if (!chosenCell || !(chosenCell.model.type == 'code')) return;
@ -252,8 +252,8 @@ function activateExtension(app: JupyterLab, palette: ICommandPalette, notebooks:
addCommand('livecells:gatherToNotebook', 'Gather this result into a new notebook', () => {
const panel = notebooks.currentWidget;
if (panel && panel.notebook && panel.notebook.activeCell.model.type === 'code') {
const activeCell = panel.notebook.activeCell;
if (panel && panel.content && panel.content.activeCell.model.type === 'code') {
const activeCell = panel.content.activeCell;
let slicer = executionLogger.executionSlicer;
let cellModel = activeCell.model as ICodeCellModel;
let slice = slicer.sliceLatestExecution(new LabCell(cellModel));
@ -261,7 +261,7 @@ function activateExtension(app: JupyterLab, palette: ICommandPalette, notebooks:
docManager.newUntitled({ ext: 'ipynb' }).then(model => {
const widget = docManager.open(model.path, undefined, panel.session.kernel.model) as NotebookPanel;
const newModel = widget.notebook.model;
const newModel = widget.content.model;
setTimeout(() => {
newModel.cells.remove(0); // remove the default blank cell
newModel.cells.pushAll(cells.map(c => {
@ -274,8 +274,8 @@ function activateExtension(app: JupyterLab, palette: ICommandPalette, notebooks:
addCommand('livecells:gatherToScript', 'Gather this result into a new script', () => {
const panel = notebooks.currentWidget;
if (panel && panel.notebook && panel.notebook.activeCell.model.type === 'code') {
const activeCell = panel.notebook.activeCell;
if (panel && panel.content && panel.content.activeCell.model.type === 'code') {
const activeCell = panel.content.activeCell;
let slicer = executionLogger.executionSlicer;
let cellModel = activeCell.model as ICodeCellModel;
let slice = slicer.sliceLatestExecution(new LabCell(cellModel));
@ -289,9 +289,9 @@ function activateExtension(app: JupyterLab, palette: ICommandPalette, notebooks:
console.log(selection);
docManager.newUntitled({ ext: 'py' }).then(model => {
const editor = docManager.open(model.path, undefined, panel.session.kernel.model) as FileEditor;
const editor = docManager.open(model.path, undefined, panel.session.kernel.model) as IDocumentWidget<FileEditor>;
setTimeout(() => {
editor.model.value.text = scriptText;
editor.content.model.value.text = scriptText;
}, 100);
});
}
@ -300,8 +300,8 @@ function activateExtension(app: JupyterLab, palette: ICommandPalette, notebooks:
addCommand('livecells:gatherFromHistory', 'Compare previous versions of this result', () => {
const panel = notebooks.currentWidget;
if (panel && panel.notebook && panel.notebook.activeCell.model.type === 'code') {
const activeCell = panel.notebook.activeCell;
if (panel && panel.content && panel.content.activeCell.model.type === 'code') {
const activeCell = panel.content.activeCell;
let slicer = executionLogger.executionSlicer;
let cellModel = activeCell.model as ICodeCellModel;
let slicedExecutions = slicer.sliceAllExecutions(new LabCell(cellModel));
@ -328,7 +328,7 @@ export class LiveCheckboxExtension implements DocumentRegistry.IWidgetExtension<
private liveness: CellLiveness;
createNew(panel: NotebookPanel, context: DocumentRegistry.IContext<INotebookModel>): IDisposable {
const checkbox = new ToolbarCheckbox(panel.notebook);
const checkbox = new ToolbarCheckbox(panel.content);
panel.toolbar.insertItem(9, 'liveCode', checkbox);
this.liveness = new CellLiveness(checkbox, panel);
@ -350,9 +350,9 @@ class CellLiveness {
private checkbox: ToolbarCheckbox,
panel: NotebookPanel
) {
panel.notebook.model.cells.changed.connect(
panel.content.model.cells.changed.connect(
(cells, value) =>
this.onCellsChanged(panel.notebook, panel.session, cells, value),
this.onCellsChanged(panel.content, panel.session, cells, value),
this);
}

Просмотреть файл

@ -27,7 +27,7 @@ export class DisplayData extends Widget {
// TODO(andrewhead): support other types of display data.
// TODO(andrewhead): change second argument (preferSafe) based on display data field.
if (nbformat.isExecuteResult(model) || nbformat.isDisplayData(model)) {
let mimeType = rendermime.preferredMimeType(model.data, true);
let mimeType = rendermime.preferredMimeType(model.data, "ensure");
let output = rendermime.createRenderer(mimeType);
output.renderModel(new OutputModel({ value: model }));
layout.addWidget(output);