Skip to content

Commit b99e42e

Browse files
authored
refactor: Migrate to serialization function from @deepnote/blocks instead of direct yaml serialization (#330)
1 parent e57ab2e commit b99e42e

27 files changed

Lines changed: 771 additions & 421 deletions

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Extensions: Show Recommended Extensions
4141

4242
Then install all the extensions listed under "Workspace Recommendations".
4343

44-
On Apple Silicon, you will have to use system versions of `libsodium` and `libzmq` instead of the bundled ones:
44+
On Apple Silicon, you will have to use system versions of `libsodium` and `libzmq` instead of the bundled ones. Also, you'll need to use Python 3.11 or older.
4545

4646
```shell
4747
brew update

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2673,8 +2673,8 @@
26732673
},
26742674
"dependencies": {
26752675
"@c4312/evt": "^0.1.1",
2676-
"@deepnote/blocks": "^1.4.0",
2677-
"@deepnote/convert": "^1.3.0",
2676+
"@deepnote/blocks": "^4.3.0",
2677+
"@deepnote/convert": "^3.2.0",
26782678
"@deepnote/database-integrations": "^1.3.0",
26792679
"@deepnote/sql-language-server": "^3.0.0",
26802680
"@enonic/fnv-plus": "^1.3.0",

src/notebooks/deepnote/converters/chartBigNumberBlockConverter.unit.test.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ suite('ChartBigNumberBlockConverter', () => {
180180
});
181181

182182
test('uses default value when metadata is invalid', () => {
183-
const block: DeepnoteBlock = {
183+
const block = {
184184
blockGroup: 'test-group',
185185
content: '',
186186
id: 'block-123',
@@ -189,7 +189,7 @@ suite('ChartBigNumberBlockConverter', () => {
189189
},
190190
sortingKey: 'a0',
191191
type: 'big-number'
192-
};
192+
} as unknown as DeepnoteBlock;
193193

194194
const cell = converter.convertToCell(block);
195195

@@ -199,14 +199,14 @@ suite('ChartBigNumberBlockConverter', () => {
199199
});
200200

201201
test('uses default value when metadata is empty', () => {
202-
const block: DeepnoteBlock = {
202+
const block = {
203203
blockGroup: 'test-group',
204204
content: '',
205205
id: 'block-123',
206206
metadata: {},
207207
sortingKey: 'a0',
208208
type: 'big-number'
209-
};
209+
} as DeepnoteBlock;
210210

211211
const cell = converter.convertToCell(block);
212212

@@ -251,6 +251,8 @@ suite('ChartBigNumberBlockConverter', () => {
251251
metadata: {
252252
existing: 'value',
253253
deepnote_big_number_value: 'old_value',
254+
deepnote_big_number_title: '',
255+
deepnote_big_number_format: '',
254256
[DEEPNOTE_VSCODE_RAW_CONTENT_KEY]: 'old raw content'
255257
},
256258
sortingKey: 'a0',
@@ -379,7 +381,9 @@ suite('ChartBigNumberBlockConverter', () => {
379381
id: 'block-123',
380382
metadata: {
381383
existing: 'value',
382-
deepnote_big_number_value: 'old_value'
384+
deepnote_big_number_value: 'old_value',
385+
deepnote_big_number_title: '',
386+
deepnote_big_number_format: ''
383387
},
384388
sortingKey: 'a0',
385389
type: 'big-number'
@@ -394,14 +398,14 @@ suite('ChartBigNumberBlockConverter', () => {
394398
});
395399

396400
test('applies defaults when metadata is missing', () => {
397-
const block: DeepnoteBlock = {
401+
const block = {
398402
blockGroup: 'test-group',
399403
content: 'old content',
400404
id: 'block-123',
401-
metadata: {},
405+
metadata: undefined,
402406
sortingKey: 'a0',
403407
type: 'big-number'
404-
};
408+
} as unknown as DeepnoteBlock;
405409
const cell = new NotebookCellData(NotebookCellKind.Code, 'my_value', 'python');
406410

407411
converter.applyChangesToBlock(block, cell);
@@ -428,7 +432,8 @@ suite('ChartBigNumberBlockConverter', () => {
428432
metadata: {
429433
custom: 'value',
430434
deepnote_big_number_title: 'title',
431-
deepnote_big_number_value: 'old_value'
435+
deepnote_big_number_value: 'old_value',
436+
deepnote_big_number_format: ''
432437
},
433438
outputs: [],
434439
sortingKey: 'a0',

src/notebooks/deepnote/converters/codeBlockConverter.unit.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ suite('CodeBlockConverter', () => {
4343
content: 'print("hello")',
4444
id: 'block-123',
4545
sortingKey: 'a0',
46+
metadata: {},
4647
type: 'code'
4748
};
4849

@@ -59,6 +60,7 @@ suite('CodeBlockConverter', () => {
5960
content: '',
6061
id: 'block-123',
6162
sortingKey: 'a0',
63+
metadata: {},
6264
type: 'code'
6365
};
6466

@@ -85,6 +87,7 @@ suite('CodeBlockConverter', () => {
8587
content: 'import numpy as np\nimport pandas as pd\n\nprint("hello")',
8688
id: 'block-123',
8789
sortingKey: 'a0',
90+
metadata: {},
8891
type: 'code'
8992
};
9093

@@ -101,6 +104,7 @@ suite('CodeBlockConverter', () => {
101104
content: 'old content',
102105
id: 'block-123',
103106
sortingKey: 'a0',
107+
metadata: {},
104108
type: 'code'
105109
};
106110
const cell = new NotebookCellData(NotebookCellKind.Code, 'new content', 'python');
@@ -116,6 +120,7 @@ suite('CodeBlockConverter', () => {
116120
content: 'old content',
117121
id: 'block-123',
118122
sortingKey: 'a0',
123+
metadata: {},
119124
type: 'code'
120125
};
121126
const cell = new NotebookCellData(NotebookCellKind.Code, '', 'python');

0 commit comments

Comments
 (0)