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 15, 2020
1 parent 0c71616 commit b603635
Show file tree
Hide file tree
Showing 34 changed files with 228 additions and 229 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
53 changes: 27 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,46 +43,47 @@
"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",
"@types/chai": "^4.1.3",
"@babel/preset-env": "^7.7.6",
"@jupyterlab/testutils": "^2.0.0-beta.2",
"@types/chai": "^4.2.7",
"@types/codemirror": "0.0.76",
"@types/jest": "^24.0.17",
"@types/murmurhash-js": "1.0.3",
"chai": "^4.2.0",
"husky": "^3.0.2",
"jest": "^24.8.0",
"jest-junit": "^6.3.0",
"lint-staged": "^9.2.1",
"husky": "^3.1.0",
"jest": "^24.9.0",
"jest-junit": "^10.0.0",
"jest-raw-loader": "^1.0.1",
"lint-staged": "^9.5.0",
"prettier": "^1.19.1",
"rimraf": "~2.6.2",
"rimraf": "~3.0.0",
"ts-jest": "^24",
"tslint": "^5.18.0",
"tslint": "^5.20.1",
"tslint-config-prettier": "^1.18.0",
"tslint-plugin-prettier": "^2.0.1",
"typedoc": "^0.15.0",
"typescript": "~3.7.2"
"typedoc": "^0.15.4",
"typescript": "~3.7.3"
},
"husky": {
"hooks": {
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 { Panel, SplitPanel } from '@phosphor/widgets';
import { Panel, SplitPanel } from '@lumino/widgets';

import { Breakpoints } from './breakpoints';

Expand Down
54 changes: 22 additions & 32 deletions src/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { JupyterFrontEnd } from '@jupyterlab/application';

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

import { ConsolePanel } from '@jupyterlab/console';

Expand Down Expand Up @@ -37,24 +37,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 @@ -94,44 +82,45 @@ export class DebuggerHandler {
* handle kernel changed events.
* @param debug The debug service.
* @param widget The widget to update.
* @param connection The session connection.
*/
async update(
widget: DebuggerHandler.SessionWidget[DebuggerHandler.SessionType],
client: IClientSession | Session.ISession
connection: Session.ISessionConnection
): Promise<void> {
const updateHandler = async () => {
return this._update(widget, client);
return this._update(widget, connection);
};

// setup handler when the kernel changes
const kernelChangedHandler = this._kernelChangedHandlers[client.path];
const kernelChangedHandler = this._kernelChangedHandlers[connection.path];
if (kernelChangedHandler) {
client.kernelChanged.disconnect(kernelChangedHandler);
connection.kernelChanged.disconnect(kernelChangedHandler);
}
client.kernelChanged.connect(updateHandler);
this._kernelChangedHandlers[client.path] = updateHandler;
connection.kernelChanged.connect(updateHandler);
this._kernelChangedHandlers[connection.path] = updateHandler;

// setup handler when the status of the kernel changes (restart)
// TODO: is there a better way to handle restarts?
let restarted = false;
const statusChanged = async () => {
// wait for the first `idle` status after a restart
if (restarted && client.status === 'idle') {
if (restarted && connection.kernel?.status === 'idle') {
restarted = false;
return updateHandler();
}
// handle `starting`, `restarting` and `autorestarting`
if (client.status.endsWith('starting')) {
if (connection.kernel?.status.endsWith('starting')) {
restarted = true;
}
};

const statusChangedHandler = this._statusChangedHandlers[client.path];
const statusChangedHandler = this._statusChangedHandlers[connection.path];
if (statusChangedHandler) {
client.statusChanged.disconnect(statusChangedHandler);
connection.statusChanged.disconnect(statusChangedHandler);
}
client.statusChanged.connect(statusChanged);
this._statusChangedHandlers[client.path] = statusChanged;
connection.statusChanged.connect(statusChanged);
this._statusChangedHandlers[connection.path] = statusChanged;

return updateHandler();
}
Expand All @@ -140,10 +129,11 @@ export class DebuggerHandler {
* Update a debug handler for the given widget.
* @param debug The debug service.
* @param widget The widget to update.
* @param connection The session connection.
*/
private async _update(
widget: DebuggerHandler.SessionWidget[DebuggerHandler.SessionType],
client: IClientSession | Session.ISession
connection: Session.ISessionConnection
): Promise<void> {
if (!this._service.model) {
return;
Expand Down Expand Up @@ -203,7 +193,7 @@ export class DebuggerHandler {

// clear the model if the handler being removed corresponds
// to the current active debug session
if (this._service.session?.client?.path === client.path) {
if (this._service.session?.connection?.path === connection.path) {
const model = this._service.model as DebuggerModel;
model.clear();
}
Expand Down Expand Up @@ -245,7 +235,7 @@ export class DebuggerHandler {
}
};

const debuggingEnabled = await this._service.isAvailable(client);
const debuggingEnabled = await this._service.isAvailable(connection);
if (!debuggingEnabled) {
removeHandlers();
removeToolbarButton();
Expand All @@ -254,9 +244,9 @@ export class DebuggerHandler {

// update the active debug session
if (!this._service.session) {
this._service.session = new DebugSession({ client: client });
this._service.session = new DebugSession({ connection });
} else {
this._service.session.client = client;
this._service.session.connection = connection;
}

await this._service.restoreState(false);
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
14 changes: 7 additions & 7 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 Expand Up @@ -40,7 +40,7 @@ export class EditorHandler implements IDisposable {
* @param options The instantiation options for a EditorHandler.
*/
constructor(options: EditorHandler.IOptions) {
this._id = options.debuggerService.session.client.path;
this._id = options.debuggerService.session.connection.path;
this._path = options.path;
this._debuggerService = options.debuggerService;
this._editor = options.editor;
Expand Down Expand Up @@ -151,7 +151,7 @@ export class EditorHandler implements IDisposable {

const breakpoints = this._getBreakpointsFromEditor().map(lineInfo => {
return Private.createBreakpoint(
this._debuggerService.session.client.name,
this._debuggerService.session.connection.name,
lineInfo.line + 1
);
});
Expand All @@ -171,7 +171,7 @@ export class EditorHandler implements IDisposable {
private _onGutterClick = (editor: Editor, lineNumber: number) => {
const info = editor.lineInfo(lineNumber);

if (!info || this._id !== this._debuggerService.session.client.path) {
if (!info || this._id !== this._debuggerService.session.connection.path) {
return;
}

Expand All @@ -182,7 +182,7 @@ export class EditorHandler implements IDisposable {
} else {
breakpoints.push(
Private.createBreakpoint(
this._path ?? this._debuggerService.session.client.name,
this._path ?? this._debuggerService.session.connection.name,
info.line + 1
)
);
Expand All @@ -201,7 +201,7 @@ export class EditorHandler implements IDisposable {
private _addBreakpointsToEditor() {
const editor = this._editor as CodeMirrorEditor;
const breakpoints = this._getBreakpoints();
if (this._id !== this._debuggerService.session.client.path) {
if (this._id !== this._debuggerService.session.connection.path) {
return;
}
EditorHandler.clearGutter(editor);
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

0 comments on commit b603635

Please sign in to comment.