Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
Update to JupyterLab 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jtpio committed Jan 13, 2020
1 parent 793492b commit d4a9b5a
Show file tree
Hide file tree
Showing 31 changed files with 148 additions and 166 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,18 @@ conda install -c conda-forge xeus-python=0.6.7 notebook>=6 ptvsd

## Development

The current master branch targets the JupyterLab 2.0 beta release.

```bash
# Create a new conda environment
conda create -n jupyterlab-debugger -c conda-forge jupyterlab nodejs xeus-python=0.6 ptvsd
conda create -n jupyterlab-debugger -c conda-forge nodejs xeus-python=0.6 ptvsd

# Activate the conda environment
conda activate jupyterlab-debugger

# Install JupyterLab 2.0
python -m pip install --pre -U jupyterlab

# Install dependencies
jlpm

Expand Down
33 changes: 17 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,29 @@
"watch": "tsc -b --watch"
},
"dependencies": {
"@jupyterlab/application": "^1.1.0",
"@jupyterlab/apputils": "^1.1.0",
"@jupyterlab/codeeditor": "^1.1.0",
"@jupyterlab/console": "^1.1.0",
"@jupyterlab/coreutils": "^3.1.0",
"@jupyterlab/docregistry": "^1.1.0",
"@jupyterlab/fileeditor": "^1.1.0",
"@jupyterlab/launcher": "^1.1.0",
"@jupyterlab/observables": "^2.4.0",
"@jupyterlab/notebook": "^1.1.0",
"@jupyterlab/services": "^4.1.0",
"@phosphor/algorithm": "^1.2.0",
"@phosphor/coreutils": "^1.3.1",
"@phosphor/disposable": "^1.2.0",
"@phosphor/widgets": "^1.8.0",
"@jupyterlab/application": "^2.0.0-beta.2",
"@jupyterlab/apputils": "^2.0.0-beta.2",
"@jupyterlab/codeeditor": "^2.0.0-beta.2",
"@jupyterlab/console": "^2.0.0-beta.2",
"@jupyterlab/coreutils": "^4.0.0-beta.2",
"@jupyterlab/docregistry": "^2.0.0-beta.2",
"@jupyterlab/fileeditor": "^2.0.0-beta.2",
"@jupyterlab/launcher": "^2.0.0-beta.2",
"@jupyterlab/observables": "^3.0.0-beta.2",
"@jupyterlab/notebook": "^2.0.0-beta.2",
"@jupyterlab/services": "^5.0.0-beta.2",
"@lumino/algorithm": "^1.2.0",
"@lumino/coreutils": "^1.3.1",
"@lumino/disposable": "^1.2.0",
"@lumino/widgets": "^1.8.0",
"murmurhash-js": "^1.0.0",
"react-inspector": "^2.0.0",
"vscode-debugprotocol": "^1.37.0"
},
"devDependencies": {
"@babel/core": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"@jupyterlab/testutils": "^1.1.0",
"@jupyterlab/testutils": "^2.0.0-beta.2",
"@types/chai": "^4.1.3",
"@types/codemirror": "0.0.76",
"@types/jest": "^24.0.17",
Expand All @@ -74,6 +74,7 @@
"husky": "^3.0.2",
"jest": "^24.8.0",
"jest-junit": "^6.3.0",
"jest-raw-loader": "^1.0.1",
"lint-staged": "^9.2.1",
"prettier": "^1.19.1",
"rimraf": "~2.6.2",
Expand Down
2 changes: 1 addition & 1 deletion src/breakpoints/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { Toolbar } from '@jupyterlab/apputils';

import { PanelLayout, Widget } from '@phosphor/widgets';
import { PanelLayout, Widget } from '@lumino/widgets';

/**
* The header for a Breakpoints Panel.
Expand Down
4 changes: 2 additions & 2 deletions src/breakpoints/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { ToolbarButton } from '@jupyterlab/apputils';

import { Panel } from '@phosphor/widgets';
import { Panel } from '@lumino/widgets';

import { IDebugger } from '../tokens';

Expand Down Expand Up @@ -31,7 +31,7 @@ export class Breakpoints extends Panel {
header.toolbar.addItem(
'closeAll',
new ToolbarButton({
iconClassName: 'jp-CloseAllIcon',
iconClass: 'jp-CloseAllIcon',
onClick: () => {
void service.clearBreakpoints();
},
Expand Down
4 changes: 2 additions & 2 deletions src/breakpoints/model.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import { IDisposable } from '@phosphor/disposable';
import { IDisposable } from '@lumino/disposable';

import { ISignal, Signal } from '@phosphor/signaling';
import { ISignal, Signal } from '@lumino/signaling';

import { IDebugger } from '../tokens';

Expand Down
2 changes: 1 addition & 1 deletion src/callstack/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { Toolbar } from '@jupyterlab/apputils';

import { PanelLayout, Widget } from '@phosphor/widgets';
import { PanelLayout, Widget } from '@lumino/widgets';

/**
* The header for a Callstack Panel.
Expand Down
4 changes: 2 additions & 2 deletions src/callstack/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

import { CommandToolbarButton } from '@jupyterlab/apputils';

import { CommandRegistry } from '@phosphor/commands';
import { CommandRegistry } from '@lumino/commands';

import { Panel } from '@phosphor/widgets';
import { Panel } from '@lumino/widgets';

import { CallstackBody } from './body';

Expand Down
2 changes: 1 addition & 1 deletion src/callstack/model.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import { ISignal, Signal } from '@phosphor/signaling';
import { ISignal, Signal } from '@lumino/signaling';

import { DebugProtocol } from 'vscode-debugprotocol';

Expand Down
2 changes: 1 addition & 1 deletion src/debugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { IEditorServices } from '@jupyterlab/codeeditor';

import { SplitPanel } from '@phosphor/widgets';
import { SplitPanel } from '@lumino/widgets';

import { Breakpoints } from './breakpoints';

Expand Down
6 changes: 3 additions & 3 deletions src/handlers/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { Cell, CodeCell } from '@jupyterlab/cells';

import { IObservableMap, ObservableMap } from '@jupyterlab/observables';

import { each } from '@phosphor/algorithm';
import { each } from '@lumino/algorithm';

import { IDisposable } from '@phosphor/disposable';
import { IDisposable } from '@lumino/disposable';

import { Signal } from '@phosphor/signaling';
import { Signal } from '@lumino/signaling';

import { EditorHandler } from '../handlers/editor';

Expand Down
4 changes: 2 additions & 2 deletions src/handlers/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { ActivityMonitor } from '@jupyterlab/coreutils';

import { IObservableString } from '@jupyterlab/observables';

import { IDisposable } from '@phosphor/disposable';
import { IDisposable } from '@lumino/disposable';

import { Signal } from '@phosphor/signaling';
import { Signal } from '@lumino/signaling';

import { Editor } from 'codemirror';

Expand Down
4 changes: 2 additions & 2 deletions src/handlers/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { DocumentWidget } from '@jupyterlab/docregistry';

import { FileEditor } from '@jupyterlab/fileeditor';

import { IDisposable } from '@phosphor/disposable';
import { IDisposable } from '@lumino/disposable';

import { Signal } from '@phosphor/signaling';
import { Signal } from '@lumino/signaling';

import { EditorHandler } from '../handlers/editor';

Expand Down
4 changes: 2 additions & 2 deletions src/handlers/notebook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { IObservableMap, ObservableMap } from '@jupyterlab/observables';

import { Notebook, NotebookPanel } from '@jupyterlab/notebook';

import { IDisposable } from '@phosphor/disposable';
import { IDisposable } from '@lumino/disposable';

import { Signal } from '@phosphor/signaling';
import { Signal } from '@lumino/signaling';

import { EditorHandler } from './editor';

Expand Down
16 changes: 8 additions & 8 deletions src/handlers/tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import { IEditorTracker } from '@jupyterlab/fileeditor';

import { INotebookTracker } from '@jupyterlab/notebook';

import { chain, each } from '@phosphor/algorithm';
import { chain, each } from '@lumino/algorithm';

import { Token } from '@phosphor/coreutils';
import { Token } from '@lumino/coreutils';

import { IDisposable } from '@phosphor/disposable';
import { IDisposable } from '@lumino/disposable';

import { Signal } from '@phosphor/signaling';
import { Signal } from '@lumino/signaling';

import { EditorHandler } from './editor';

Expand Down Expand Up @@ -210,9 +210,9 @@ export class TrackerHandler implements IDisposable {
}
const editors: CodeEditor.IEditor[] = [];
this._notebookTracker.forEach(notebookPanel => {
const session = notebookPanel.session;
const sessionContext = notebookPanel.sessionContext;

if (session.path !== debugSessionPath) {
if (sessionContext.path !== debugSessionPath) {
return;
}

Expand Down Expand Up @@ -248,9 +248,9 @@ export class TrackerHandler implements IDisposable {
}
const editors: CodeEditor.IEditor[] = [];
this._consoleTracker.forEach(consoleWidget => {
const session = consoleWidget.session;
const sessionContext = consoleWidget.sessionContext;

if (session.path !== debugSessionPath) {
if (sessionContext.path !== debugSessionPath) {
return;
}

Expand Down
49 changes: 21 additions & 28 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ import {
JupyterFrontEndPlugin
} from '@jupyterlab/application';

import {
IClientSession,
ICommandPalette,
Toolbar,
ToolbarButton
} from '@jupyterlab/apputils';
import { ICommandPalette, ToolbarButton } from '@jupyterlab/apputils';

import { IEditorServices } from '@jupyterlab/codeeditor';

Expand Down Expand Up @@ -75,24 +70,12 @@ function updateToolbar(
) {
const button = new ToolbarButton({
className: 'jp-DebuggerSwitchButton',
iconClassName: 'jp-ToggleSwitch',
iconClass: 'jp-ToggleSwitch',
onClick,
tooltip: 'Enable / Disable Debugger'
});

const getToolbar = (): Toolbar => {
if (!(widget instanceof ConsolePanel)) {
return widget.toolbar;
}
const toolbar = widget.widgets.find(w => w instanceof Toolbar) as Toolbar;
return toolbar ?? new Toolbar();
};

const toolbar = getToolbar();
const itemAdded = toolbar.addItem('debugger-button', button);
if (itemAdded && widget instanceof ConsolePanel) {
widget.insertWidget(0, toolbar);
}
widget.toolbar.addItem('debugger-button', button);
return button;
}

Expand Down Expand Up @@ -137,7 +120,7 @@ class DebuggerHandler<
shell: JupyterFrontEnd.IShell,
debug: IDebugger,
widget: W,
client: IClientSession | Session.ISession
client: Session.ISessionConnection
): Promise<void> {
const updateHandler = async () => {
return this._update(shell, debug, widget, client);
Expand All @@ -156,12 +139,12 @@ class DebuggerHandler<
let restarted = false;
const statusChanged = async () => {
// wait for the first `idle` status after a restart
if (restarted && client.status === 'idle') {
if (restarted && client.kernel?.status === 'idle') {
restarted = false;
return updateHandler();
}
// handle `starting`, `restarting` and `autorestarting`
if (client.status.endsWith('starting')) {
if (client.kernel?.status.endsWith('starting')) {
restarted = true;
}
};
Expand All @@ -187,7 +170,7 @@ class DebuggerHandler<
shell: JupyterFrontEnd.IShell,
debug: IDebugger,
widget: W,
client: IClientSession | Session.ISession
client: Session.ISessionConnection
): Promise<void> {
if (!debug.model) {
return;
Expand Down Expand Up @@ -326,7 +309,12 @@ const consoles: JupyterFrontEndPlugin<void> = {
if (!(widget instanceof ConsolePanel)) {
return;
}
await handler.update(app.shell, debug, widget, widget.session);
await handler.update(
app.shell,
debug,
widget,
widget.sessionContext.session
);
app.commands.notifyCommandChanged();
});
}
Expand All @@ -346,7 +334,7 @@ const files: JupyterFrontEndPlugin<void> = {
});

const activeSessions: {
[id: string]: Session.ISession;
[id: string]: Session.ISessionConnection;
} = {};

labShell.currentChanged.connect(async (_, update) => {
Expand All @@ -369,7 +357,7 @@ const files: JupyterFrontEndPlugin<void> = {
// `connectTo` sends a kernel_info_request on the shell
// channel, which blocks the debug session restore when waiting
// for the kernel to be ready
session = sessions.connectTo(model);
session = sessions.connectTo({ model });
activeSessions[model.id] = session;
}
await handler.update(app.shell, debug, widget, session);
Expand Down Expand Up @@ -399,7 +387,12 @@ const notebooks: JupyterFrontEndPlugin<void> = {
if (!(widget instanceof NotebookPanel)) {
return;
}
await handler.update(app.shell, debug, widget, widget.session);
await handler.update(
app.shell,
debug,
widget,
widget.sessionContext.session
);
app.commands.notifyCommandChanged();
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { IDebugger } from './tokens';

import { ISignal, Signal } from '@phosphor/signaling';
import { ISignal, Signal } from '@lumino/signaling';

import { BreakpointsModel } from './breakpoints/model';

Expand Down

0 comments on commit d4a9b5a

Please sign in to comment.