Skip to content

Commit 52ddfbd

Browse files
committed
Update other cells in cell execution
1 parent 8349588 commit 52ddfbd

File tree

5 files changed

+10
-43
lines changed

5 files changed

+10
-43
lines changed

src/client/datascience/baseJupyterSession.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@ export abstract class BaseJupyterSession implements IJupyterSession {
6868
public get isConnected(): boolean {
6969
return this.connected;
7070
}
71-
public get onIoPubMessage() {
72-
return this.ioPubEventEmitter.event;
73-
}
7471
protected onStatusChangedEvent: EventEmitter<ServerStatus> = new EventEmitter<ServerStatus>();
7572
protected statusHandler: Slot<ISessionWithSocket, Kernel.Status>;
7673
protected connected: boolean = false;

src/client/datascience/jupyter/kernels/cellExecution.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ import { noop } from '../../../common/utils/misc';
1818
import { StopWatch } from '../../../common/utils/stopWatch';
1919
import { sendTelemetryEvent } from '../../../telemetry';
2020
import { Telemetry } from '../../constants';
21-
import { updateCellExecutionCount, updateCellWithErrorStatus } from '../../notebook/helpers/executionHelpers';
21+
import {
22+
handleUpdateDisplayDataMessage,
23+
updateCellExecutionCount,
24+
updateCellWithErrorStatus
25+
} from '../../notebook/helpers/executionHelpers';
2226
import {
2327
cellOutputToVSCCellOutput,
2428
clearCellForExecution,
@@ -370,12 +374,12 @@ export class CellExecution {
370374
await this.handleStreamMessage(msg as KernelMessage.IStreamMsg, clearState);
371375
} else if (jupyterLab.KernelMessage.isDisplayDataMsg(msg)) {
372376
await this.handleDisplayData(msg as KernelMessage.IDisplayDataMsg, clearState);
377+
} else if (jupyterLab.KernelMessage.isUpdateDisplayDataMsg(msg)) {
378+
await handleUpdateDisplayDataMessage(msg, this.editor);
373379
} else if (jupyterLab.KernelMessage.isClearOutputMsg(msg)) {
374380
await this.handleClearOutput(msg as KernelMessage.IClearOutputMsg, clearState);
375381
} else if (jupyterLab.KernelMessage.isErrorMsg(msg)) {
376382
await this.handleError(msg as KernelMessage.IErrorMsg, clearState);
377-
} else if (jupyterLab.KernelMessage.isUpdateDisplayDataMsg(msg)) {
378-
// Noop.
379383
} else if (jupyterLab.KernelMessage.isCommOpenMsg(msg)) {
380384
// Noop.
381385
} else if (jupyterLab.KernelMessage.isCommMsgMsg(msg)) {

src/client/datascience/jupyter/kernels/kernelExecution.ts

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33

44
'use strict';
55

6-
import { KernelMessage } from '@jupyterlab/services';
76
import { NotebookCell, NotebookCellRunState, NotebookDocument } from 'vscode';
87
import { IApplicationShell, ICommandManager, IVSCodeNotebook } from '../../../common/application/types';
98
import { IDisposable } from '../../../common/types';
109
import { noop } from '../../../common/utils/misc';
1110
import { IInterpreterService } from '../../../interpreter/contracts';
1211
import { captureTelemetry } from '../../../telemetry';
1312
import { Commands, Telemetry, VSCodeNativeTelemetry } from '../../constants';
14-
import { handleUpdateDisplayDataMessage } from '../../notebook/helpers/executionHelpers';
1513
import { MultiCancellationTokenSource } from '../../notebook/helpers/multiCancellationToken';
1614
import { IDataScienceErrorHandler, INotebook, INotebookEditorProvider } from '../../types';
1715
import { CellExecution, CellExecutionFactory } from './cellExecution';
@@ -161,15 +159,6 @@ export class KernelExecution implements IDisposable {
161159
return kernel;
162160
}
163161

164-
private async onIoPubMessage(document: NotebookDocument, msg: KernelMessage.IIOPubMessage) {
165-
// tslint:disable-next-line:no-require-imports
166-
const jupyterLab = require('@jupyterlab/services') as typeof import('@jupyterlab/services');
167-
const editor = this.vscNotebook.notebookEditors.find((e) => e.document === document);
168-
if (jupyterLab.KernelMessage.isUpdateDisplayDataMsg(msg) && editor) {
169-
await handleUpdateDisplayDataMessage(msg, editor);
170-
}
171-
}
172-
173162
private async executeIndividualCell(
174163
kernelPromise: Promise<IKernel>,
175164
cellExecution: CellExecution
@@ -178,20 +167,9 @@ export class KernelExecution implements IDisposable {
178167
throw new Error('No notebook object');
179168
}
180169

181-
// Register for IO pub messages
182-
const ioRegistration = this.notebook.session.onIoPubMessage(
183-
this.onIoPubMessage.bind(this, cellExecution.cell.notebook)
184-
);
185170
cellExecution.token.onCancellationRequested(
186-
() => {
187-
ioRegistration.dispose();
188-
if (cellExecution.completed) {
189-
return;
190-
}
191-
192-
// Interrupt kernel only if we need to cancel a cell execution.
193-
this.commandManager.executeCommand(Commands.NotebookEditorInterruptKernel).then(noop, noop);
194-
},
171+
// Interrupt kernel only if we need to cancel a cell execution.
172+
() => this.commandManager.executeCommand(Commands.NotebookEditorInterruptKernel).then(noop, noop),
195173
this,
196174
this.disposables
197175
);
@@ -200,11 +178,7 @@ export class KernelExecution implements IDisposable {
200178
await cellExecution.start(kernelPromise, this.notebook);
201179

202180
// The result promise will resolve when complete.
203-
try {
204-
return await cellExecution.result;
205-
} finally {
206-
ioRegistration.dispose();
207-
}
181+
return cellExecution.result;
208182
}
209183

210184
private async validateKernel(document: NotebookDocument): Promise<void> {

src/client/datascience/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,6 @@ export interface IJupyterPasswordConnect {
320320
export const IJupyterSession = Symbol('IJupyterSession');
321321
export interface IJupyterSession extends IAsyncDisposable {
322322
onSessionStatusChanged: Event<ServerStatus>;
323-
onIoPubMessage: Event<KernelMessage.IIOPubMessage>;
324323
readonly status: ServerStatus;
325324
readonly workingDirectory: string;
326325
readonly kernelSocket: Observable<KernelSocketInformation | undefined>;

src/test/datascience/mockJupyterSession.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ export class MockJupyterSession implements IJupyterSession {
2525
private dict: Record<string, ICell>;
2626
private restartedEvent: EventEmitter<void> = new EventEmitter<void>();
2727
private onStatusChangedEvent: EventEmitter<ServerStatus> = new EventEmitter<ServerStatus>();
28-
private onIoPubMessageEvent: EventEmitter<KernelMessage.IIOPubMessage> = new EventEmitter<
29-
KernelMessage.IIOPubMessage
30-
>();
3128
private timedelay: number;
3229
private executionCount: number = 0;
3330
private outstandingRequestTokenSources: CancellationTokenSource[] = [];
@@ -58,10 +55,6 @@ export class MockJupyterSession implements IJupyterSession {
5855
}
5956
return this.onStatusChangedEvent.event;
6057
}
61-
public get onIoPubMessage(): Event<KernelMessage.IIOPubMessage> {
62-
return this.onIoPubMessageEvent.event;
63-
}
64-
6558
public get status(): ServerStatus {
6659
return this._status;
6760
}

0 commit comments

Comments
 (0)