Skip to content

Commit d24c35d

Browse files
authored
Update Jupyter Npm To Latest (#15897)
* Update JupyterLab pkgs, support WS Protocols * Updates * Remove debugger statements * Revert disabling websocket protocol * misc * Fixes * Fix tests * More updates * Update minimum version of renderer extension * Updates to build * Fixes
1 parent 7c746b8 commit d24c35d

20 files changed

+1371
-419
lines changed

build/ci/postInstall.js

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,7 @@ const path = require('path');
99
const constants = require('../constants');
1010
const common = require('../webpack/common');
1111
const { downloadZMQ } = require('@vscode/zeromq');
12-
/**
13-
* In order to get raw kernels working, we reuse the default kernel that jupyterlab ships.
14-
* However it expects to be talking to a websocket which is serializing the messages to strings.
15-
* Our raw kernel is not a web socket and needs to do its own serialization. To do so, we make a copy
16-
* of the default kernel with the serialization stripped out. This is simpler than making a copy of the module
17-
* at runtime.
18-
*/
19-
function createJupyterKernelWithoutSerialization() {
20-
var relativePath = path.join('node_modules', '@jupyterlab', 'services', 'lib', 'kernel', 'default.js');
21-
var filePath = path.join(constants.ExtensionRootDir, relativePath);
22-
if (!fs.existsSync(filePath)) {
23-
throw new Error(
24-
"Jupyter lab default kernel not found '" + filePath + "' (Jupyter Extension post install script)"
25-
);
26-
}
27-
var fileContents = fs.readFileSync(filePath, { encoding: 'utf8' });
28-
var replacedContents = fileContents
29-
.replace(/^const serialize =.*$/gm, 'const serialize = { serialize: (a) => a, deserialize: (a) => a };')
30-
.replace(
31-
'const owned = team.session === this.clientId;',
32-
'const owned = parentHeader.session === this.clientId;'
33-
);
34-
if (replacedContents === fileContents) {
35-
throw new Error('Jupyter lab default kernel cannot be made non serializing');
36-
}
37-
var destPath = path.join(path.dirname(filePath), 'nonSerializingKernel.js');
38-
fs.writeFileSync(destPath, replacedContents);
39-
console.log(colors.green(destPath + ' file generated (by Jupyter VSC)'));
40-
}
12+
4113
function fixVariableNameInKernelDefaultJs() {
4214
var relativePath = path.join('node_modules', '@jupyterlab', 'services', 'lib', 'kernel', 'default.js');
4315
var filePath = path.join(constants.ExtensionRootDir, relativePath);
@@ -228,7 +200,6 @@ function commentOutInvalidExport() {
228200

229201
fixJupyterLabRenderers();
230202
makeVariableExplorerAlwaysSorted();
231-
createJupyterKernelWithoutSerialization();
232203
fixVariableNameInKernelDefaultJs();
233204
removeUnnecessaryLoggingFromKernelDefault();
234205
fixStripComments();

build/esbuild/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const deskTopNodeModulesToExternalize = [
3434
'@jupyterlab/services',
3535
'@jupyterlab/nbformat',
3636
'@jupyterlab/services/lib/kernel/serialize',
37-
'@jupyterlab/services/lib/kernel/nonSerializingKernel',
37+
'@jupyterlab/services/lib/kernel/default',
3838
'vscode-jsonrpc' // Used by a few modules, might as well pull this out, instead of duplicating it in separate bundles.
3939
];
4040
const commonExternals = [

package-lock.json

Lines changed: 1179 additions & 335 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2128,13 +2128,13 @@
21282128
"dependencies": {
21292129
"@c4312/evt": "^0.1.1",
21302130
"@enonic/fnv-plus": "^1.3.0",
2131-
"@jupyter-widgets/base": "4.0.0",
2132-
"@jupyter-widgets/controls": "3.0.0",
2133-
"@jupyter-widgets/schema": "0.4.0",
2134-
"@jupyterlab/coreutils": "5.1.17",
2135-
"@jupyterlab/nbformat": "3.1.17",
2136-
"@jupyterlab/services": "6.1.17",
2137-
"@lumino/widgets": "^1.28.0",
2131+
"@jupyter-widgets/base": "^6.0.8",
2132+
"@jupyter-widgets/controls": "^5.0.9",
2133+
"@jupyter-widgets/schema": "^0.5.5",
2134+
"@jupyterlab/coreutils": "^6.2.4",
2135+
"@jupyterlab/nbformat": "^4.2.4",
2136+
"@jupyterlab/services": "^7.2.4",
2137+
"@lumino/widgets": "^2.4.0",
21382138
"@nteract/messaging": "^7.0.0",
21392139
"@vscode/extension-telemetry": "^0.7.7",
21402140
"@vscode/python-extension": "^1.0.4",

src/kernels/common/baseJupyterSessionConnection.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ export abstract class BaseJupyterSessionConnection<
5858
* The kernel anyMessage signal, proxied from the current kernel.
5959
*/
6060
anyMessage = new Signal<this, Kernel.IAnyMessageArgs>(this);
61+
/**
62+
* The kernel pendingInput signal, proxied from the current
63+
* kernel.
64+
*/
65+
pendingInput = new Signal<this, boolean>(this);
6166

6267
constructor(
6368
public readonly kind: T,
@@ -70,6 +75,7 @@ export abstract class BaseJupyterSessionConnection<
7075
session.connectionStatusChanged.connect(this.onConnectionStatusChanged, this);
7176
session.iopubMessage.connect(this.onIOPubMessage, this);
7277
session.unhandledMessage.connect(this.onUnhandledMessage, this);
78+
session.pendingInput.connect(this.onPendingInput, this);
7379
session.anyMessage.connect(this.onAnyMessage, this);
7480

7581
this._register({
@@ -80,6 +86,7 @@ export abstract class BaseJupyterSessionConnection<
8086
this.session.connectionStatusChanged.disconnect(this.onConnectionStatusChanged, this);
8187
this.session.iopubMessage.disconnect(this.onIOPubMessage, this);
8288
this.session.unhandledMessage.disconnect(this.onUnhandledMessage, this);
89+
this.session.pendingInput.disconnect(this.onPendingInput, this);
8390
this.session.anyMessage.disconnect(this.onAnyMessage, this);
8491
}
8592
});
@@ -187,6 +194,9 @@ export abstract class BaseJupyterSessionConnection<
187194
private onAnyMessage(_: unknown, value: Kernel.IAnyMessageArgs) {
188195
this.anyMessage.emit(value);
189196
}
197+
private onPendingInput(_: unknown, value: boolean) {
198+
this.pendingInput.emit(value);
199+
}
190200
public setPath(value: string) {
191201
return this.session.setPath(value);
192202
}

src/kernels/common/baseJupyterSessionConnection.unit.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ suite('Base Jupyter Session Connection', () => {
4848
when(kernel.status).thenReturn('idle');
4949
when(kernel.connectionStatus).thenReturn('connected');
5050
when(kernel.statusChanged).thenReturn(instance(mock<ISignal<Kernel.IKernelConnection, Kernel.Status>>()));
51+
when(kernel.pendingInput).thenReturn(instance(mock<ISignal<Kernel.IKernelConnection, boolean>>()));
5152
when(kernel.iopubMessage).thenReturn(
5253
instance(
5354
mock<ISignal<Kernel.IKernelConnection, KernelMessage.IIOPubMessage<KernelMessage.IOPubMessageType>>>()
@@ -96,6 +97,7 @@ suite('Base Jupyter Session Connection', () => {
9697
when(session.statusChanged).thenReturn(
9798
new Signal<Session.ISessionConnection, Kernel.Status>(instance(session))
9899
);
100+
when(session.pendingInput).thenReturn(instance(mock<ISignal<Session.ISessionConnection, boolean>>()));
99101
when(session.unhandledMessage).thenReturn(sessionUnhandledMessage);
100102
when(session.connectionStatusChanged).thenReturn(sessionConnectionStatusChanged);
101103
when(session.anyMessage).thenReturn(sessionAnyMessage);

src/kernels/execution/cellExecutionMessageHandler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,8 @@ export class CellExecutionMessageHandler implements IDisposable {
848848
cancelToken.token
849849
)
850850
.then((v) => {
851-
this.kernel.sendInputReply({ value: v || '', status: 'ok' });
851+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
852+
this.kernel.sendInputReply({ value: v || '', status: 'ok' }, msg.header as any);
852853
}, noop);
853854

854855
this.prompts.delete(cancelToken);

src/kernels/jupyter/session/jupyterKernelSessionFactory.unit.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,15 @@ suite('New Jupyter Kernel Session Factory', () => {
206206
when(session.statusChanged).thenReturn(
207207
new Signal<Session.ISessionConnection, Kernel.Status>(instance(session))
208208
);
209+
when(session.pendingInput).thenReturn(instance(mock<ISignal<Session.ISessionConnection, boolean>>()));
209210
when(session.unhandledMessage).thenReturn(sessionUnhandledMessage);
210211
when(session.connectionStatusChanged).thenReturn(sessionConnectionStatusChanged);
211212
when(session.anyMessage).thenReturn(sessionAnyMessage);
212213
when(session.isDisposed).thenReturn(false);
213214
when(kernel.status).thenReturn('idle');
214215
when(kernel.connectionStatus).thenReturn('connected');
215216
when(kernel.statusChanged).thenReturn(instance(mock<ISignal<Kernel.IKernelConnection, Kernel.Status>>()));
217+
when(kernel.pendingInput).thenReturn(instance(mock<ISignal<Kernel.IKernelConnection, boolean>>()));
216218
when(kernel.iopubMessage).thenReturn(
217219
instance(
218220
mock<ISignal<Kernel.IKernelConnection, KernelMessage.IIOPubMessage<KernelMessage.IOPubMessageType>>>()

src/kernels/jupyter/session/jupyterLabHelper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ export class JupyterLabHelper extends ObservableDisposable {
9999

100100
const sessions: Session.IModel[] = [];
101101
const iterator = this.sessionManager.running();
102-
let session = iterator.next();
102+
let session = iterator.next().value;
103103

104104
while (session) {
105105
sessions.push(session);
106-
session = iterator.next();
106+
session = iterator.next().value;
107107
}
108108

109109
return sessions;

src/kernels/jupyter/session/jupyterSession.unit.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ suite('JupyterSession', () => {
7676
when(session.unhandledMessage).thenReturn(sessionUnhandledMessage);
7777
when(session.connectionStatusChanged).thenReturn(sessionConnectionStatusChanged);
7878
when(session.anyMessage).thenReturn(sessionAnyMessage);
79+
when(session.pendingInput).thenReturn(instance(mock<ISignal<Session.ISessionConnection, boolean>>()));
7980
when(session.isDisposed).thenReturn(false);
8081
when(kernel.status).thenReturn('idle');
8182
when(kernel.connectionStatus).thenReturn('connected');
@@ -90,6 +91,7 @@ suite('JupyterSession', () => {
9091
instance(mock<ISignal<Kernel.IKernelConnection, KernelMessage.IMessage<KernelMessage.MessageType>>>())
9192
);
9293
when(kernel.disposed).thenReturn(instance(mock<ISignal<Kernel.IKernelConnection, void>>()));
94+
when(kernel.pendingInput).thenReturn(instance(mock<ISignal<Kernel.IKernelConnection, boolean>>()));
9395
when(kernel.connectionStatusChanged).thenReturn(
9496
instance(mock<ISignal<Kernel.IKernelConnection, Kernel.ConnectionStatus>>())
9597
);

0 commit comments

Comments
 (0)