-
Notifications
You must be signed in to change notification settings - Fork 4
feat: Support Deepnote input blocks #42
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
Merged
Changes from all commits
Commits
Show all changes
76 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 debe3a3
feat: Support Deepnote input blocks
tkislan a476bfd
feat: Move DEEPNOTE_VSCODE_RAW_CONTENT_KEY into constants file
tkislan b6752ca
Merge branch 'tomaskislan/grn-4762-support-big-number-blocks' into to…
tkislan 3a4d579
feedback
Artmann 01569a0
feat: Add Deepnote input blocks converters
tkislan 402f077
refactor: Remove debug logs and refine metadata parsing in Deepnote c…
tkislan 40ede24
feat: Add chart big number converter tests
tkislan d220422
Reformat test code
tkislan 78d3cb7
Refactor ChartBigNumberBlockConverter tests to use deepStrictEqual fo…
tkislan 79b34ba
Remove debug console.log
tkislan e48a37f
Merge branch 'tomaskislan/grn-4762-support-big-number-blocks' into to…
tkislan 4fa78e2
docs and metadata changes.
Artmann c1becf8
fix: Spread operator object fallback
tkislan 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 4908fed
Merge remote-tracking branch 'origin/tomaskislan/grn-4762-support-big…
tkislan 067f757
Merge remote-tracking branch 'origin/main' into tomaskislan/grn-4762-…
tkislan cc3f23c
Fix imports
tkislan 88c55a0
Merge remote-tracking branch 'origin/tomaskislan/grn-4762-support-big…
tkislan 8ba67da
fix: Fix imports
tkislan 6ee3612
fix: Remove unused code
tkislan f2c01ee
Merge remote-tracking branch 'origin/tomaskislan/grn-4762-support-big…
tkislan 95fd687
feat(big-number): Integrate react-error-boundary for error handling a…
tkislan 05ab7a0
Update test snapshots
tkislan 4c1c4e2
Merge remote-tracking branch 'origin/tomaskislan/grn-4762-support-big…
tkislan 6337c84
feat: Update input create default values to match those in deepnote app
tkislan 5f05be1
Merge branch 'main' into tomaskislan/grn-4762-support-big-number-blocks
jamesbhobbs 5d14ba3
Merge branch 'tomaskislan/grn-4762-support-big-number-blocks' into to…
jamesbhobbs a1711c4
feat: Display input block type in notebook cell status bar
tkislan 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 ed680fc
Merge remote-tracking branch 'origin/tomaskislan/grn-4762-support-big…
tkislan 6691448
Merge branch 'tomaskislan/grn-4776-support-input-blocks' of github.co…
tkislan 81ae526
Merge remote-tracking branch 'origin/main' into tomaskislan/grn-4776-…
tkislan 4c5e886
Merge branch 'main' into tomaskislan/grn-4776-support-input-blocks
tkislan 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,201 @@ | ||
| import { NotebookCellData, NotebookCellKind } from 'vscode'; | ||
| import { z } from 'zod'; | ||
|
|
||
| import type { BlockConverter } from './blockConverter'; | ||
| import type { DeepnoteBlock } from '../../../platform/deepnote/deepnoteTypes'; | ||
| import { | ||
| DeepnoteTextInputMetadataSchema, | ||
| DeepnoteTextareaInputMetadataSchema, | ||
| DeepnoteSelectInputMetadataSchema, | ||
| DeepnoteSliderInputMetadataSchema, | ||
| DeepnoteCheckboxInputMetadataSchema, | ||
| DeepnoteDateInputMetadataSchema, | ||
| DeepnoteDateRangeInputMetadataSchema, | ||
| DeepnoteFileInputMetadataSchema, | ||
| DeepnoteButtonMetadataSchema | ||
| } from '../deepnoteSchemas'; | ||
| import { parseJsonWithFallback } from '../dataConversionUtils'; | ||
| import { DEEPNOTE_VSCODE_RAW_CONTENT_KEY } from './constants'; | ||
|
|
||
| export abstract class BaseInputBlockConverter<T extends z.ZodObject> implements BlockConverter { | ||
| abstract schema(): T; | ||
| abstract getSupportedType(): string; | ||
| abstract defaultConfig(): z.infer<T>; | ||
|
|
||
| applyChangesToBlock(block: DeepnoteBlock, cell: NotebookCellData): void { | ||
| block.content = ''; | ||
|
|
||
| const config = this.schema().safeParse(parseJsonWithFallback(cell.value)); | ||
|
|
||
| if (config.success !== true) { | ||
| block.metadata = { | ||
| ...(block.metadata ?? {}), | ||
| [DEEPNOTE_VSCODE_RAW_CONTENT_KEY]: cell.value | ||
| }; | ||
| return; | ||
| } | ||
|
|
||
| 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() === this.getSupportedType(); | ||
| } | ||
|
|
||
| convertToCell(block: DeepnoteBlock): NotebookCellData { | ||
| const deepnoteJupyterRawContentResult = z.string().safeParse(block.metadata?.[DEEPNOTE_VSCODE_RAW_CONTENT_KEY]); | ||
| const deepnoteMetadataResult = this.schema().safeParse(block.metadata); | ||
|
|
||
| if (deepnoteMetadataResult.error != null) { | ||
| console.error('Error parsing deepnote input metadata:', deepnoteMetadataResult.error); | ||
| console.debug('Metadata:', JSON.stringify(block.metadata)); | ||
| } | ||
|
|
||
| const configStr = deepnoteJupyterRawContentResult.success | ||
| ? deepnoteJupyterRawContentResult.data | ||
| : deepnoteMetadataResult.success | ||
| ? JSON.stringify(deepnoteMetadataResult.data, null, 2) | ||
| : JSON.stringify(this.defaultConfig(), null, 2); | ||
|
|
||
| const cell = new NotebookCellData(NotebookCellKind.Code, configStr, 'json'); | ||
|
|
||
| return cell; | ||
| } | ||
|
|
||
| getSupportedTypes(): string[] { | ||
| return [this.getSupportedType()]; | ||
| } | ||
| } | ||
|
|
||
| export class InputTextBlockConverter extends BaseInputBlockConverter<typeof DeepnoteTextInputMetadataSchema> { | ||
| private readonly DEFAULT_INPUT_TEXT_CONFIG = DeepnoteTextInputMetadataSchema.parse({}); | ||
|
|
||
| schema() { | ||
| return DeepnoteTextInputMetadataSchema; | ||
| } | ||
| getSupportedType() { | ||
| return 'input-text'; | ||
| } | ||
| defaultConfig() { | ||
| return this.DEFAULT_INPUT_TEXT_CONFIG; | ||
| } | ||
| } | ||
|
|
||
| export class InputTextareaBlockConverter extends BaseInputBlockConverter<typeof DeepnoteTextareaInputMetadataSchema> { | ||
| private readonly DEFAULT_INPUT_TEXTAREA_CONFIG = DeepnoteTextareaInputMetadataSchema.parse({}); | ||
|
|
||
| schema() { | ||
| return DeepnoteTextareaInputMetadataSchema; | ||
| } | ||
| getSupportedType() { | ||
| return 'input-textarea'; | ||
| } | ||
| defaultConfig() { | ||
| return this.DEFAULT_INPUT_TEXTAREA_CONFIG; | ||
| } | ||
| } | ||
|
|
||
| export class InputSelectBlockConverter extends BaseInputBlockConverter<typeof DeepnoteSelectInputMetadataSchema> { | ||
| private readonly DEFAULT_INPUT_SELECT_CONFIG = DeepnoteSelectInputMetadataSchema.parse({}); | ||
|
|
||
| schema() { | ||
| return DeepnoteSelectInputMetadataSchema; | ||
| } | ||
| getSupportedType() { | ||
| return 'input-select'; | ||
| } | ||
| defaultConfig() { | ||
| return this.DEFAULT_INPUT_SELECT_CONFIG; | ||
| } | ||
| } | ||
|
|
||
| export class InputSliderBlockConverter extends BaseInputBlockConverter<typeof DeepnoteSliderInputMetadataSchema> { | ||
| private readonly DEFAULT_INPUT_SLIDER_CONFIG = DeepnoteSliderInputMetadataSchema.parse({}); | ||
|
|
||
| schema() { | ||
| return DeepnoteSliderInputMetadataSchema; | ||
| } | ||
| getSupportedType() { | ||
| return 'input-slider'; | ||
| } | ||
| defaultConfig() { | ||
| return this.DEFAULT_INPUT_SLIDER_CONFIG; | ||
| } | ||
| } | ||
|
|
||
| export class InputCheckboxBlockConverter extends BaseInputBlockConverter<typeof DeepnoteCheckboxInputMetadataSchema> { | ||
| private readonly DEFAULT_INPUT_CHECKBOX_CONFIG = DeepnoteCheckboxInputMetadataSchema.parse({}); | ||
|
|
||
| schema() { | ||
| return DeepnoteCheckboxInputMetadataSchema; | ||
| } | ||
| getSupportedType() { | ||
| return 'input-checkbox'; | ||
| } | ||
| defaultConfig() { | ||
| return this.DEFAULT_INPUT_CHECKBOX_CONFIG; | ||
| } | ||
| } | ||
|
|
||
| export class InputDateBlockConverter extends BaseInputBlockConverter<typeof DeepnoteDateInputMetadataSchema> { | ||
| private readonly DEFAULT_INPUT_DATE_CONFIG = DeepnoteDateInputMetadataSchema.parse({}); | ||
|
|
||
| schema() { | ||
| return DeepnoteDateInputMetadataSchema; | ||
| } | ||
| getSupportedType() { | ||
| return 'input-date'; | ||
| } | ||
| defaultConfig() { | ||
| return this.DEFAULT_INPUT_DATE_CONFIG; | ||
| } | ||
| } | ||
|
|
||
| export class InputDateRangeBlockConverter extends BaseInputBlockConverter<typeof DeepnoteDateRangeInputMetadataSchema> { | ||
| private readonly DEFAULT_INPUT_DATE_RANGE_CONFIG = DeepnoteDateRangeInputMetadataSchema.parse({}); | ||
|
|
||
| schema() { | ||
| return DeepnoteDateRangeInputMetadataSchema; | ||
| } | ||
| getSupportedType() { | ||
| return 'input-date-range'; | ||
| } | ||
| defaultConfig() { | ||
| return this.DEFAULT_INPUT_DATE_RANGE_CONFIG; | ||
| } | ||
| } | ||
|
|
||
| export class InputFileBlockConverter extends BaseInputBlockConverter<typeof DeepnoteFileInputMetadataSchema> { | ||
| private readonly DEFAULT_INPUT_FILE_CONFIG = DeepnoteFileInputMetadataSchema.parse({}); | ||
|
|
||
| schema() { | ||
| return DeepnoteFileInputMetadataSchema; | ||
| } | ||
| getSupportedType() { | ||
| return 'input-file'; | ||
| } | ||
| defaultConfig() { | ||
| return this.DEFAULT_INPUT_FILE_CONFIG; | ||
| } | ||
| } | ||
|
|
||
| export class ButtonBlockConverter extends BaseInputBlockConverter<typeof DeepnoteButtonMetadataSchema> { | ||
| private readonly DEFAULT_BUTTON_CONFIG = DeepnoteButtonMetadataSchema.parse({}); | ||
|
|
||
| schema() { | ||
| return DeepnoteButtonMetadataSchema; | ||
| } | ||
| getSupportedType() { | ||
| return 'button'; | ||
| } | ||
| defaultConfig() { | ||
| return this.DEFAULT_BUTTON_CONFIG; | ||
| } | ||
| } | ||
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.