Skip to content

Commit 3a757ba

Browse files
committed
hardcode the variable name
1 parent a7cb1ca commit 3a757ba

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/notebooks/deepnote/deepnoteNotebookCommandListener.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export function safeParseDeepnoteVariableNameFromContentJson(content: string): s
8686
}
8787
}
8888

89-
export function getNextDeepnoteVariableName(cells: NotebookCell[], prefix: 'df' | 'query' | 'input' | 'chart'): string {
89+
export function getNextDeepnoteVariableName(cells: NotebookCell[], prefix: 'df' | 'query' | 'input'): string {
9090
const deepnoteVariableNames = cells.reduce<string[]>((acc, cell) => {
9191
const contentValue = safeParseDeepnoteVariableNameFromContentJson(cell.document.getText());
9292

@@ -276,7 +276,6 @@ export class DeepnoteNotebookCommandListener implements IExtensionSyncActivation
276276
const selection = editor.selection;
277277

278278
const insertIndex = selection ? selection.end : document.cellCount;
279-
const deepnoteVariableName = getNextDeepnoteVariableName(document.getCells(), 'df');
280279

281280
const defaultVisualizationSpec = {
282281
mark: 'line',
@@ -289,7 +288,7 @@ export class DeepnoteNotebookCommandListener implements IExtensionSyncActivation
289288
};
290289

291290
const cellContent = {
292-
variable: deepnoteVariableName,
291+
variable: 'df_1',
293292
spec: defaultVisualizationSpec,
294293
filters: []
295294
};

src/notebooks/deepnote/deepnoteNotebookCommandListener.unit.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ suite('DeepnoteNotebookCommandListener', () => {
102102
const TEST_INPUTS: Array<{
103103
description: string;
104104
cells: NotebookCell[];
105-
prefix: 'df' | 'query' | 'input' | 'chart';
105+
prefix: 'df' | 'query' | 'input';
106106
expected: string;
107107
}> = [
108108
// Tests with 'input' prefix
@@ -1064,7 +1064,7 @@ suite('DeepnoteNotebookCommandListener', () => {
10641064
assert.equal(notebookEdit.newCells[0].languageId, 'json', 'Should be JSON cell');
10651065
});
10661066

1067-
test('should generate correct variable name when existing chart variables exist', async () => {
1067+
test('should use hardcoded variable name df_1', async () => {
10681068
// Setup mocks with existing df variables
10691069
const existingCells = [
10701070
createMockCell('{ "deepnote_variable_name": "df_1" }'),
@@ -1080,13 +1080,13 @@ suite('DeepnoteNotebookCommandListener', () => {
10801080
const notebookEdit = capturedNotebookEdits![0] as any;
10811081
const newCell = notebookEdit.newCells[0];
10821082

1083-
// Verify variable name is df_3
1083+
// Verify variable name is always df_1
10841084
const content = JSON.parse(newCell.value);
1085-
assert.equal(content.variable, 'df_3', 'Should generate next variable name');
1085+
assert.equal(content.variable, 'df_1', 'Should always use df_1');
10861086
});
10871087

1088-
test('should ignore other variable types when generating chart variable name', async () => {
1089-
// Setup mocks with input and df variables
1088+
test('should always use df_1 regardless of existing variables', async () => {
1089+
// Setup mocks with various existing variables
10901090
const existingCells = [
10911091
createMockCell('{ "deepnote_variable_name": "input_10" }'),
10921092
createMockCell('{ "deepnote_variable_name": "df_5" }'),
@@ -1102,9 +1102,9 @@ suite('DeepnoteNotebookCommandListener', () => {
11021102
const notebookEdit = capturedNotebookEdits![0] as any;
11031103
const newCell = notebookEdit.newCells[0];
11041104

1105-
// Verify variable name is df_6 (uses highest df_ number)
1105+
// Verify variable name is always df_1
11061106
const content = JSON.parse(newCell.value);
1107-
assert.equal(content.variable, 'df_6', 'Should consider all df variables');
1107+
assert.equal(content.variable, 'df_1', 'Should always use df_1');
11081108
});
11091109

11101110
test('should insert at correct position in the middle of notebook', async () => {

0 commit comments

Comments
 (0)