Skip to content

Commit 2f15899

Browse files
committed
Update other cells in cell execution
1 parent 516f5f1 commit 2f15899

File tree

5 files changed

+9
-45
lines changed

5 files changed

+9
-45
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: 6 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,
@@ -389,8 +393,7 @@ export class CellExecution {
389393
} else if (jupyterLab.KernelMessage.isDisplayDataMsg(msg)) {
390394
await this.handleDisplayData(msg as KernelMessage.IDisplayDataMsg, clearState);
391395
} else if (jupyterLab.KernelMessage.isUpdateDisplayDataMsg(msg)) {
392-
// No new data to update UI, hence do not send updates.
393-
shouldUpdate = false;
396+
await handleUpdateDisplayDataMessage(msg, this.editor);
394397
} else if (jupyterLab.KernelMessage.isClearOutputMsg(msg)) {
395398
await this.handleClearOutput(msg as KernelMessage.IClearOutputMsg, clearState);
396399
} else if (jupyterLab.KernelMessage.isErrorMsg(msg)) {

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

Lines changed: 3 additions & 31 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 { INotebookContentProvider } from '../../notebook/types';
1715
import { IDataScienceErrorHandler, INotebook, INotebookEditorProvider } from '../../types';
@@ -169,17 +167,6 @@ export class KernelExecution implements IDisposable {
169167
return kernel;
170168
}
171169

172-
private async onIoPubMessage(document: NotebookDocument, msg: KernelMessage.IIOPubMessage) {
173-
// tslint:disable-next-line:no-require-imports
174-
const jupyterLab = require('@jupyterlab/services') as typeof import('@jupyterlab/services');
175-
const editor = this.vscNotebook.notebookEditors.find((e) => e.document === document);
176-
if (jupyterLab.KernelMessage.isUpdateDisplayDataMsg(msg) && editor) {
177-
if (await handleUpdateDisplayDataMessage(msg, editor)) {
178-
this.contentProvider.notifyChangesToDocument(document);
179-
}
180-
}
181-
}
182-
183170
private async executeIndividualCell(
184171
kernelPromise: Promise<IKernel>,
185172
cellExecution: CellExecution
@@ -188,20 +175,9 @@ export class KernelExecution implements IDisposable {
188175
throw new Error('No notebook object');
189176
}
190177

191-
// Register for IO pub messages
192-
const ioRegistration = this.notebook.session.onIoPubMessage(
193-
this.onIoPubMessage.bind(this, cellExecution.cell.notebook)
194-
);
195178
cellExecution.token.onCancellationRequested(
196-
() => {
197-
ioRegistration.dispose();
198-
if (cellExecution.completed) {
199-
return;
200-
}
201-
202-
// Interrupt kernel only if we need to cancel a cell execution.
203-
this.commandManager.executeCommand(Commands.NotebookEditorInterruptKernel).then(noop, noop);
204-
},
179+
// Interrupt kernel only if we need to cancel a cell execution.
180+
() => this.commandManager.executeCommand(Commands.NotebookEditorInterruptKernel).then(noop, noop),
205181
this,
206182
this.disposables
207183
);
@@ -210,11 +186,7 @@ export class KernelExecution implements IDisposable {
210186
await cellExecution.start(kernelPromise, this.notebook);
211187

212188
// The result promise will resolve when complete.
213-
try {
214-
return await cellExecution.result;
215-
} finally {
216-
ioRegistration.dispose();
217-
}
189+
return cellExecution.result;
218190
}
219191

220192
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)