-
Notifications
You must be signed in to change notification settings - Fork 4
feat: Implement deepnote big number chart support and renderer #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jamesbhobbs
merged 58 commits into
main
from
tomaskislan/grn-4762-support-big-number-blocks
Oct 23, 2025
Merged
Changes from 5 commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
a422532
feat: Set up a custom renderer for data frames.
Artmann 3f9c6af
wip
Artmann e334698
feat: Implement deepnote big number chart support and renderer
tkislan 87f4a09
Merge remote-tracking branch 'origin/chris/display-data-frames' into …
tkislan 62297c2
refactor: Clean up debug logs and improve big number block conversion…
tkislan 7878345
feat: Pass block metadata to cell outputs for renderer to access
tkislan a12d042
feat: Set up a custom renderer for data frames.
Artmann c19acd4
wip
Artmann 066229a
add the table state.
Artmann e36b9c0
page size handling
Artmann 558035f
add page navigation
Artmann 5113db6
Generate Python code before executing the cell.
Artmann 1ba9ab4
clean up
Artmann a51a150
pr feedback.
Artmann 98d7fe6
Update build/esbuild/build.ts
Artmann a476bfd
feat: Move DEEPNOTE_VSCODE_RAW_CONTENT_KEY into constants file
tkislan 3a4d579
feedback
Artmann 40ede24
feat: Add chart big number converter tests
tkislan d220422
Reformat test code
tkislan 78d3cb7
Refactor ChartBigNumberBlockConverter tests to use deepStrictEqual fo…
tkislan 4fa78e2
docs and metadata changes.
Artmann e8ce411
Merge remote-tracking branch 'origin/chris/display-data-frames' into …
tkislan 8ae05ab
use the latest blocks package.
Artmann 3597ce3
Merge branch 'main' into chris/display-data-frames
Artmann 9fec8d4
add the packages permission
Artmann 0537364
simplify execution flow.
Artmann 9b9216a
remove copyright header
Artmann e5a1bba
clean up the code
Artmann e7cccb9
Merge branch 'main' into chris/display-data-frames
Artmann 895fe09
revert controller changes
Artmann 54ca963
pr feedback
Artmann 8309267
Merge branch 'main' into chris/display-data-frames
Artmann df330bc
pr feedback
Artmann 8b88881
fix the tests
Artmann 8386006
guard metadata spread against undefined.
Artmann 8121bfa
Merge remote-tracking branch 'origin/chris/display-data-frames' into …
tkislan 3bdf030
Merge remote-tracking branch 'origin/main' into tomaskislan/grn-4762-…
tkislan d9afa1a
fix: Merge cleanup
tkislan e2b6c36
More merge cleanup
tkislan 722ab50
Fix test
tkislan 628ab6e
feat: Add big number chart json config execution support
tkislan ed5329d
fix: Enhance error handling for big number metadata parsing and impro…
tkislan 6649ca8
refactor: Simplify chart big number renderer by directly rendering to…
tkislan a3007ac
Merge remote-tracking branch 'origin/main' into tomaskislan/grn-4762-…
tkislan b25656b
Fix import
tkislan 8014bc3
fix: Change deepnote_big_number_comparison_type to string type for be…
tkislan 85c8b70
fix: Remove constants, accidentaly added to wrong branch
tkislan 68567e0
Merge branch 'main' into tomaskislan/grn-4762-support-big-number-blocks
tkislan 067f757
Merge remote-tracking branch 'origin/main' into tomaskislan/grn-4762-…
tkislan cc3f23c
Fix imports
tkislan 6ee3612
fix: Remove unused code
tkislan 95fd687
feat(big-number): Integrate react-error-boundary for error handling a…
tkislan 05ab7a0
Update test snapshots
tkislan 5f05be1
Merge branch 'main' into tomaskislan/grn-4762-support-big-number-blocks
jamesbhobbs 8d83d0c
fix: Fix spell check in test
tkislan 60442ec
Merge remote-tracking branch 'origin/main' into tomaskislan/grn-4762-…
tkislan 236cccd
Merge branch 'main' into tomaskislan/grn-4762-support-big-number-blocks
tkislan f8dcd85
Merge branch 'main' into tomaskislan/grn-4762-support-big-number-blocks
jamesbhobbs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| import { | ||
| CancellationToken, | ||
| NotebookCell, | ||
| NotebookCellExecution, | ||
| NotebookCellOutput, | ||
| NotebookCellOutputItem, | ||
| NotebookController | ||
| } from 'vscode'; | ||
|
|
||
| import { KernelController } from '../kernelController'; | ||
|
|
||
| /** | ||
| * DeepnoteController extends KernelController to intercept cell execution | ||
| * and prepend initialization code to each cell execution. | ||
| */ | ||
| export class DeepnoteController extends KernelController { | ||
| constructor(controller: NotebookController) { | ||
| super(controller); | ||
| } | ||
|
|
||
| public override createNotebookCellExecution(cell: NotebookCell): NotebookCellExecution { | ||
| const execution = super.createNotebookCellExecution(cell); | ||
| return new DeepnoteNotebookCellExecution(execution, cell); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Wrapper around NotebookCellExecution that prepends initialization code. | ||
| * This is implemented by delegating all calls to the underlying execution object. | ||
| * | ||
| * Note: This wrapper currently just delegates to the underlying execution. | ||
| * The actual code interception will be implemented at the execution layer. | ||
| */ | ||
| class DeepnoteNotebookCellExecution implements NotebookCellExecution { | ||
| constructor( | ||
| private readonly execution: NotebookCellExecution, | ||
| public readonly cell: NotebookCell | ||
| ) { | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // Prepend code will be: print("Hello world") | ||
| // This will be implemented at the CellExecution layer | ||
| } | ||
|
|
||
| get executionOrder(): number | undefined { | ||
| return this.execution.executionOrder; | ||
| } | ||
|
|
||
| set executionOrder(value: number | undefined) { | ||
| this.execution.executionOrder = value; | ||
| } | ||
|
|
||
| get token(): CancellationToken { | ||
| return this.execution.token; | ||
| } | ||
|
|
||
| public start(startTime?: number): void { | ||
| this.execution.start(startTime); | ||
| } | ||
|
|
||
| public end(success: boolean | undefined, endTime?: number): void { | ||
| this.execution.end(success, endTime); | ||
| } | ||
|
|
||
| public clearOutput(cell?: NotebookCell): Thenable<void> { | ||
| return this.execution.clearOutput(cell); | ||
| } | ||
|
|
||
| public replaceOutput(out: NotebookCellOutput | readonly NotebookCellOutput[], cell?: NotebookCell): Thenable<void> { | ||
| return this.execution.replaceOutput(out, cell); | ||
| } | ||
|
|
||
| public appendOutput(out: NotebookCellOutput | readonly NotebookCellOutput[], cell?: NotebookCell): Thenable<void> { | ||
| return this.execution.appendOutput(out, cell); | ||
| } | ||
|
|
||
| public replaceOutputItems( | ||
| items: NotebookCellOutputItem | readonly NotebookCellOutputItem[], | ||
| output: NotebookCellOutput | ||
| ): Thenable<void> { | ||
| return this.execution.replaceOutputItems(items, output); | ||
| } | ||
|
|
||
| public appendOutputItems( | ||
| items: NotebookCellOutputItem | readonly NotebookCellOutputItem[], | ||
| output: NotebookCellOutput | ||
| ): Thenable<void> { | ||
| return this.execution.appendOutputItems(items, output); | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/notebooks/deepnote/converters/chartBigNumberBlockConverter.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import { NotebookCellData, NotebookCellKind } from 'vscode'; | ||
|
|
||
| import type { BlockConverter } from './blockConverter'; | ||
| import type { DeepnoteBlock } from '../deepnoteTypes'; | ||
| import { DeepnoteBigNumberMetadataSchema } from '../deepnoteSchemas'; | ||
| import { parseJsonWithFallback } from '../dataConversionUtils'; | ||
| import { z } from 'zod'; | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| export const DEEPNOTE_VSCODE_RAW_CONTENT_KEY = 'deepnote_jupyter_raw_content'; | ||
| const DEFAULT_BIG_NUMBER_CONFIG = DeepnoteBigNumberMetadataSchema.parse({}); | ||
|
|
||
| export class ChartBigNumberBlockConverter implements BlockConverter { | ||
| applyChangesToBlock(block: DeepnoteBlock, cell: NotebookCellData): void { | ||
| block.content = ''; | ||
|
|
||
| const config = DeepnoteBigNumberMetadataSchema.safeParse(parseJsonWithFallback(cell.value)); | ||
|
|
||
| if (config.success !== true) { | ||
| block.metadata = { | ||
| ...block.metadata, | ||
| [DEEPNOTE_VSCODE_RAW_CONTENT_KEY]: cell.value | ||
| }; | ||
| return; | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if (block.metadata != null) { | ||
| delete block.metadata[DEEPNOTE_VSCODE_RAW_CONTENT_KEY]; | ||
| } | ||
|
|
||
| block.metadata = { | ||
| ...(block.metadata ?? {}), | ||
| ...config.data | ||
| }; | ||
| } | ||
|
|
||
| canConvert(blockType: string): boolean { | ||
| return blockType.toLowerCase() === 'big-number'; | ||
| } | ||
|
|
||
| convertToCell(block: DeepnoteBlock): NotebookCellData { | ||
| const deepnoteJupyterRawContentResult = z.string().safeParse(block.metadata?.[DEEPNOTE_VSCODE_RAW_CONTENT_KEY]); | ||
| const deepnoteBigNumberMetadataResult = DeepnoteBigNumberMetadataSchema.safeParse(block.metadata); | ||
|
|
||
| if (deepnoteBigNumberMetadataResult.error != null) { | ||
| console.error('Error parsing deepnote big number metadata:', deepnoteBigNumberMetadataResult.error); | ||
| console.debug('Metadata:', JSON.stringify(block.metadata)); | ||
| } | ||
|
|
||
| const configStr = deepnoteJupyterRawContentResult.success | ||
| ? deepnoteJupyterRawContentResult.data | ||
| : deepnoteBigNumberMetadataResult.success | ||
| ? JSON.stringify(deepnoteBigNumberMetadataResult.data, null, 2) | ||
| : JSON.stringify(DEFAULT_BIG_NUMBER_CONFIG); | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| const cell = new NotebookCellData(NotebookCellKind.Code, configStr, 'json'); | ||
| console.log(cell); | ||
| return cell; | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| getSupportedTypes(): string[] { | ||
| return ['big-number']; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export const CHART_BIG_NUMBER_MIME_TYPE = 'application/vnd.deepnote.chart.big-number+json'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import { z } from 'zod'; | ||
|
|
||
| export const DeepnoteChartBigNumberOutputSchema = z.object({ | ||
| title: z.string().nullish(), | ||
| value: z.string().nullish(), | ||
|
|
||
| comparisonTitle: z.string().nullish(), | ||
| comparisonValue: z.string().nullish() | ||
| }); | ||
tkislan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| export const DeepnoteBigNumberMetadataSchema = z.object({ | ||
| deepnote_big_number_title: z | ||
| .string() | ||
| .nullish() | ||
| .transform((val) => val ?? null), | ||
| deepnote_big_number_value: z | ||
| .string() | ||
| .nullish() | ||
| .transform((val) => val ?? null), | ||
| deepnote_big_number_format: z | ||
| .string() | ||
| .nullish() | ||
| .transform((val) => val ?? null), | ||
tkislan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| deepnote_big_number_comparison_type: z | ||
| .enum(['absolute-value', 'percentage-change', 'absolute-change']) | ||
| .nullish() | ||
| .transform((val) => val ?? null), | ||
| deepnote_big_number_comparison_title: z | ||
| .string() | ||
| .nullish() | ||
| .transform((val) => val ?? null), | ||
| deepnote_big_number_comparison_value: z | ||
| .string() | ||
| .nullish() | ||
| .transform((val) => val ?? null), | ||
| deepnote_big_number_comparison_format: z | ||
| .string() | ||
| .nullish() | ||
| .transform((val) => val ?? null), | ||
| deepnote_big_number_comparison_enabled: z | ||
| .boolean() | ||
| .nullish() | ||
| .transform((val) => val ?? null) | ||
| }); | ||
|
|
||
| export type DeepnoteChartBigNumberOutput = z.infer<typeof DeepnoteChartBigNumberOutputSchema>; | ||
| export type DeepnoteBigNumberMetadata = z.infer<typeof DeepnoteBigNumberMetadataSchema>; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.