Skip to content

Commit e5a1bba

Browse files
committed
clean up the code
1 parent 9b9216a commit e5a1bba

File tree

4 files changed

+53
-43
lines changed

4 files changed

+53
-43
lines changed

src/kernels/execution/cellExecutionCreator.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
import {
4+
import type {
55
CancellationToken,
66
CellExecutionError,
77
NotebookCell,
@@ -69,7 +69,10 @@ export class NotebookCellExecutionWrapper implements NotebookCellExecution {
6969
// This ensures old outputs are removed before any new outputs arrive from the kernel
7070
if (this.clearOutputOnStartWithTime) {
7171
logger.trace(`Start cell ${this.cell.index} execution (clear output)`);
72-
this._impl.clearOutput().then(noop, noop);
72+
73+
this._impl
74+
.clearOutput()
75+
.then(noop, (err) => logger.warn(`Failed to clear output for cell ${this.cell.index}`, err));
7376
}
7477

7578
if (startTime) {

src/kernels/execution/cellExecutionCreator.unit.test.ts

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ suite('NotebookCellExecutionWrapper', () => {
2525
when(mockImpl.clearOutput(anything())).thenReturn(Promise.resolve());
2626
when(mockController.id).thenReturn('test-controller');
2727

28-
endCallback = () => {};
28+
endCallback = () => {
29+
// noop
30+
};
2931
});
3032

3133
test('When clearOutputOnStartWithTime is true, start is called before clearOutput', () => {
@@ -42,7 +44,9 @@ suite('NotebookCellExecutionWrapper', () => {
4244
start: () => {
4345
callOrder.push('start');
4446
},
45-
end: () => {},
47+
end: () => {
48+
// noop
49+
},
4650
replaceOutput: () => Promise.resolve(),
4751
appendOutput: () => Promise.resolve(),
4852
replaceOutputItems: () => Promise.resolve(),
@@ -88,7 +92,9 @@ suite('NotebookCellExecutionWrapper', () => {
8892
callOrder.push('start');
8993
capturedStartTime = startTime;
9094
},
91-
end: () => {},
95+
end: () => {
96+
// noop
97+
},
9298
replaceOutput: () => Promise.resolve(),
9399
appendOutput: () => Promise.resolve(),
94100
replaceOutputItems: () => Promise.resolve(),
@@ -125,7 +131,9 @@ suite('NotebookCellExecutionWrapper', () => {
125131
start: () => {
126132
startCallCount++;
127133
},
128-
end: () => {},
134+
end: () => {
135+
// noop
136+
},
129137
replaceOutput: () => Promise.resolve(),
130138
appendOutput: () => Promise.resolve(),
131139
replaceOutputItems: () => Promise.resolve(),
@@ -165,8 +173,12 @@ suite('NotebookCellExecutionWrapper', () => {
165173
clearOutputCallCount++;
166174
return Promise.resolve();
167175
},
168-
start: () => {},
169-
end: () => {},
176+
start: () => {
177+
// noop
178+
},
179+
end: () => {
180+
// noop
181+
},
170182
replaceOutput: () => Promise.resolve(),
171183
appendOutput: () => Promise.resolve(),
172184
replaceOutputItems: () => Promise.resolve(),
@@ -183,7 +195,7 @@ suite('NotebookCellExecutionWrapper', () => {
183195

184196
// Now manually call clearOutput to simulate re-execution
185197
// This simulates what CellExecutionCreator.getOrCreate() does when reusing a started wrapper
186-
wrapper.clearOutput();
198+
void wrapper.clearOutput();
187199

188200
// Should have called clearOutput twice now (once from start, once from manual call)
189201
assert.strictEqual(
@@ -213,7 +225,9 @@ suite('CellExecutionCreator', () => {
213225
clearOutputCallCount++;
214226
return Promise.resolve();
215227
},
216-
start: () => {},
228+
start: () => {
229+
// noop
230+
},
217231
end: () => {
218232
endCallCount++;
219233
},
@@ -231,7 +245,9 @@ suite('CellExecutionCreator', () => {
231245
clearOutputCallCount++;
232246
return Promise.resolve();
233247
},
234-
start: () => {},
248+
start: () => {
249+
// noop
250+
},
235251
end: () => {
236252
endCallCount++;
237253
},

src/notebooks/deepnote/deepnoteInitNotebookRunner.node.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
import { inject, injectable } from 'inversify';
2-
import { NotebookDocument, ProgressLocation, window, CancellationTokenSource, CancellationToken } from 'vscode';
2+
import {
3+
type NotebookDocument,
4+
ProgressLocation,
5+
window,
6+
CancellationTokenSource,
7+
type CancellationToken,
8+
l10n
9+
} from 'vscode';
10+
311
import { logger } from '../../platform/logging';
412
import { IDeepnoteNotebookManager } from '../types';
5-
import { DeepnoteProject, DeepnoteNotebook } from './deepnoteTypes';
13+
import type { DeepnoteProject, DeepnoteNotebook } from './deepnoteTypes';
614
import { IKernelProvider } from '../../kernels/types';
715
import { getDisplayPath } from '../../platform/common/platform/fs-paths';
816

@@ -134,14 +142,14 @@ export class DeepnoteInitNotebookRunner {
134142
return window.withProgress(
135143
{
136144
location: ProgressLocation.Notification,
137-
title: `🚀 Initializing project environment`,
145+
title: l10n.t(`🚀 Initializing project environment`),
138146
cancellable: false
139147
},
140148
async (notificationProgress) => {
141149
return window.withProgress(
142150
{
143151
location: ProgressLocation.Window,
144-
title: `Init: "${initNotebook.name}"`,
152+
title: l10n.t(`Init: "${initNotebook.name}"`),
145153
cancellable: false
146154
},
147155
async (windowProgress) => {

src/webviews/extension-side/dataframe/dataframeController.ts

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,42 @@
11
import { injectable } from 'inversify';
22
import {
33
commands,
4-
env,
54
l10n,
65
NotebookEdit,
7-
NotebookEditor,
8-
NotebookRendererMessaging,
6+
type NotebookEditor,
7+
type NotebookRendererMessaging,
98
notebooks,
109
window,
1110
workspace,
1211
WorkspaceEdit
1312
} from 'vscode';
1413

15-
import { IExtensionSyncActivationService } from '../../../platform/activation/types';
16-
import { IDisposable } from '../../../platform/common/types';
14+
import type { IExtensionSyncActivationService } from '../../../platform/activation/types';
15+
import type { IDisposable } from '../../../platform/common/types';
1716
import { dispose } from '../../../platform/common/utils/lifecycle';
1817
import { logger } from '../../../platform/logging';
1918

2019
type SelectPageSizeCommand = {
2120
cellId?: string;
22-
cellIndex?: number;
2321
command: 'selectPageSize';
2422
size: number;
2523
};
2624

2725
type GoToPageCommand = {
2826
cellId?: string;
29-
cellIndex?: number;
3027
command: 'goToPage';
3128
page: number;
3229
};
3330

3431
type CopyTableDataCommand = {
32+
cellId?: string;
3533
command: 'copyTableData';
3634
data: string;
3735
};
3836

3937
type ExportDataframeCommand = {
38+
cellId?: string;
4039
command: 'exportDataframe';
41-
cellIndex: number;
4240
};
4341

4442
type DataframeCommand = SelectPageSizeCommand | GoToPageCommand | CopyTableDataCommand | ExportDataframeCommand;
@@ -75,18 +73,20 @@ export class DataframeController implements IExtensionSyncActivationService {
7573
}
7674

7775
if (message.command === 'copyTableData') {
78-
return this.handleCopyTableData(message);
76+
// TODO: Implement dataframe export functionality
77+
return;
7978
}
8079

8180
if (message.command === 'exportDataframe') {
82-
return this.handleExportDataframe(editor, message);
81+
// TODO: Implement dataframe export functionality
82+
return;
8383
}
8484

8585
logger.warn(`DataframeController received unknown command:`, message);
8686
}
8787

8888
private async handleSelectPageSize(editor: NotebookEditor, message: SelectPageSizeCommand) {
89-
if (!message.cellId && message.cellIndex === undefined) {
89+
if (!message.cellId) {
9090
const errorMessage = l10n.t(
9191
'Unable to update page size: No cell identifier provided. Please re-run the cell to update the output metadata.'
9292
);
@@ -198,21 +198,4 @@ export class DataframeController implements IExtensionSyncActivationService {
198198
document: editor.notebook.uri
199199
});
200200
}
201-
202-
private async handleCopyTableData(message: CopyTableDataCommand) {
203-
logger.info(`[DataframeRenderer] copyTableData called, data length=${message.data.length} characters`);
204-
205-
await env.clipboard.writeText(message.data);
206-
}
207-
208-
private async handleExportDataframe(editor: NotebookEditor, message: ExportDataframeCommand) {
209-
const cell = editor.notebook.cellAt(message.cellIndex);
210-
211-
logger.info(
212-
`[DataframeRenderer] exportDataframe called for cell ${
213-
message.cellIndex
214-
} (${cell?.document.uri.toString()})`
215-
);
216-
// TODO: Implement dataframe export functionality
217-
}
218201
}

0 commit comments

Comments
 (0)