Repository navigation
feat: Create the @deepnote/convert package for converting Jupyter notebooks to Deepnote notebooks. - #46
Conversation
…ebooks to Deepnote notebooks.
📝 WalkthroughWalkthroughAdds a new package @deepnote/convert that converts Jupyter .ipynb files into Deepnote YAML project files via a CLI and programmatic API. Introduces conversion logic (cells → Deepnote blocks with deterministic sorting keys, UUIDs/timestamps), YAML serialization, file I/O, error handling, tests, fixtures, README, and package metadata (.npmignore, package.json, codecov). Adds a CLI entry (bin.ts) and exports convertIpynbFilesToDeepnoteFile and related types. Also updates CI to run package build steps before typechecking and testing, expands cspell dictionary, and reorders .gitignore entries. Sequence Diagram(s)sequenceDiagram
actor User
participant Bin as deepnote-convert (bin.ts)
participant CLI as convert(options) (cli.ts)
participant FS as FileSystem
participant Conv as jupyter-to-deepnote
participant YAML as YAML Serializer
User->>Bin: run deepnote-convert <path> [--projectName] [-o output]
Bin->>CLI: parse flags & call convert(options)
alt input is directory
CLI->>FS: read directory, list .ipynb files
FS-->>CLI: ipynb paths
else input is single .ipynb
CLI->>FS: stat/resolve file
FS-->>CLI: ipynb path
end
CLI->>Conv: convertIpynbFilesToDeepnoteFile(paths, opts)
Conv->>FS: read each .ipynb JSON
FS-->>Conv: notebook JSON
loop per notebook
Conv->>Conv: map cells -> Deepnote blocks (id, sortingKey, executionCount, outputs)
end
Conv->>YAML: serialize DeepnoteFile to YAML
YAML-->>FS: write .deepnote output
FS-->>CLI: output path
CLI-->>User: print success and path
sequenceDiagram
participant Conv as jupyter-to-deepnote
participant Cell as IPYNB Cell
participant Block as Deepnote Block
Conv->>Cell: iterate cell
alt markdown
Cell->>Block: produce markdown block (content)
else code
Cell->>Block: produce code block (content, executionCount, outputs)
end
Block-->>Conv: block with id + sortingKey
Conv->>Conv: assemble notebook & project metadata
Possibly related PRs
Suggested reviewers
Pre-merge checks✅ Passed checks (3 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (4)packages/*/src/**/*.test.{ts,tsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
packages/*/src/**/*.{ts,tsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
packages/*/src/**/*📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧠 Learnings (1)📓 Common learnings🔇 Additional comments (1)
Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #46 +/- ##
==========================================
- Coverage 93.77% 92.91% -0.86%
==========================================
Files 21 24 +3
Lines 610 776 +166
Branches 182 222 +40
==========================================
+ Hits 572 721 +149
- Misses 38 55 +17 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| - name: Install dependencies | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Build packages |
There was a problem hiding this comment.
This is required as we have dependecies between the packages in the mono repo.
There was a problem hiding this comment.
Actionable comments posted: 10
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (15)
.github/workflows/ci.yml(2 hunks).gitignore(1 hunks)cspell.json(1 hunks)packages/convert/.npmignore(1 hunks)packages/convert/README.md(1 hunks)packages/convert/package.json(1 hunks)packages/convert/src/__fixtures__/notebook1.ipynb(1 hunks)packages/convert/src/__fixtures__/notebook2.ipynb(1 hunks)packages/convert/src/__fixtures__/simple.ipynb(1 hunks)packages/convert/src/__fixtures__/titanic-tutorial.ipynb(1 hunks)packages/convert/src/cli.test.ts(1 hunks)packages/convert/src/cli.ts(1 hunks)packages/convert/src/index.ts(1 hunks)packages/convert/src/jupyter-to-deepnote.test.ts(1 hunks)packages/convert/src/jupyter-to-deepnote.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
packages/*/src/**/*
📄 CodeRabbit inference engine (CLAUDE.md)
Place source code under packages/*/src/
Files:
packages/convert/src/__fixtures__/notebook2.ipynbpackages/convert/src/index.tspackages/convert/src/__fixtures__/notebook1.ipynbpackages/convert/src/__fixtures__/simple.ipynbpackages/convert/src/cli.tspackages/convert/src/jupyter-to-deepnote.tspackages/convert/src/cli.test.tspackages/convert/src/__fixtures__/titanic-tutorial.ipynbpackages/convert/src/jupyter-to-deepnote.test.ts
packages/*/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
packages/*/src/**/*.{ts,tsx}: Use strict type checking and prefer type safety over convenience
Use const for immutable values
Avoid any; use proper type definitions and type guards
Files:
packages/convert/src/index.tspackages/convert/src/cli.tspackages/convert/src/jupyter-to-deepnote.tspackages/convert/src/cli.test.tspackages/convert/src/jupyter-to-deepnote.test.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Follow Biome's lint rules as configured in biome.json
Use literal keys (dot notation) instead of bracket notation when possible
Prefer single quotes for strings (except when avoiding escapes)
Files:
packages/convert/src/index.tspackages/convert/src/cli.tspackages/convert/src/jupyter-to-deepnote.tspackages/convert/src/cli.test.tspackages/convert/src/jupyter-to-deepnote.test.ts
**/*.{md,yml,yaml}
📄 CodeRabbit inference engine (CLAUDE.md)
Use Prettier formatting for Markdown and YAML files
Files:
packages/convert/README.md
packages/*/src/**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
packages/*/src/**/*.test.{ts,tsx}: Place test files next to the source files with .test.ts or .test.tsx extension
Use Vitest as the testing framework for all tests
Import { describe, expect, it } from 'vitest' in tests
Use dedent from ts-dedent for multiline string comparisons in tests
Follow existing test patterns (see packages/blocks/src/blocks/*.test.ts); write clear names, group with describe(), cover edge cases, errors, special characters, and verify exact output for code-generation functions
Files:
packages/convert/src/cli.test.tspackages/convert/src/jupyter-to-deepnote.test.ts
🧠 Learnings (4)
📚 Learning: 2025-09-03T12:59:14.489Z
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/instructions/notebooks.instructions.md:0-0
Timestamp: 2025-09-03T12:59:14.489Z
Learning: Applies to src/notebooks/export/**/*.ts : Update FileConverter to handle the new export format
Applied to files:
packages/convert/src/index.tspackages/convert/src/cli.tspackages/convert/src/jupyter-to-deepnote.tspackages/convert/src/jupyter-to-deepnote.test.ts
📚 Learning: 2025-10-09T11:21:57.494Z
Learnt from: CR
PR: deepnote/vscode-deepnote#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-09T11:21:57.494Z
Learning: Applies to src/notebooks/deepnote/deepnoteDataConverter.ts : deepnoteDataConverter.ts performs Deepnote data transformations
Applied to files:
packages/convert/src/index.tspackages/convert/README.mdpackages/convert/src/cli.tspackages/convert/src/jupyter-to-deepnote.tspackages/convert/src/jupyter-to-deepnote.test.ts
📚 Learning: 2025-09-03T12:54:35.368Z
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/instructions/interactiveWindow.instructions.md:0-0
Timestamp: 2025-09-03T12:54:35.368Z
Learning: Applies to src/interactive-window/**/*.ts : Add unit and integration tests for new features and modifications; include performance and cross-platform test coverage
Applied to files:
packages/convert/src/cli.test.ts
📚 Learning: 2025-10-14T13:43:36.364Z
Learnt from: CR
PR: deepnote/deepnote#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-14T13:43:36.364Z
Learning: Applies to packages/*/src/**/*.test.{ts,tsx} : Follow existing test patterns (see packages/blocks/src/blocks/*.test.ts); write clear names, group with describe(), cover edge cases, errors, special characters, and verify exact output for code-generation functions
Applied to files:
packages/convert/src/cli.test.tspackages/convert/src/jupyter-to-deepnote.test.ts
🧬 Code graph analysis (2)
packages/convert/src/cli.ts (2)
packages/convert/src/index.ts (1)
convertIpynbFilesToDeepnoteFile(1-1)packages/convert/src/jupyter-to-deepnote.ts (1)
convertIpynbFilesToDeepnoteFile(26-84)
packages/convert/src/jupyter-to-deepnote.test.ts (1)
packages/convert/src/jupyter-to-deepnote.ts (1)
convertIpynbFilesToDeepnoteFile(26-84)
🔇 Additional comments (27)
cspell.json (1)
56-61: Dictionary additions LGTMNo issues; useful additions for this repo’s domain.
packages/convert/.npmignore (1)
1-9: Confirm sourcemaps vs excluding src/If dist .map files reference ../src, publishing without src/ breaks debugging. Either inline sources in maps, disable maps, or include src/.
packages/convert/package.json (1)
23-25: CLI shebangEnsure dist/cli.js preserves a shebang (#!/usr/bin/env node). Without it, the bin may not be executable from PATH.
packages/convert/src/__fixtures__/notebook2.ipynb (1)
1-19: Fixture LGTMClear minimal notebook for tests.
packages/convert/src/__fixtures__/notebook1.ipynb (1)
1-19: Fixture LGTMNo issues.
packages/convert/src/__fixtures__/simple.ipynb (1)
1-26: Fixture LGTMGood variety for conversion tests.
.github/workflows/ci.yml (1)
102-104: Build script scope verified
pnpm run buildinvokes the recursive build (pnpm -r run build) and covers all workspaces.packages/convert/src/cli.ts (1)
4-7: Verify ESM/CJS entrypoints in package.json
- packages/convert/package.json sets
"type": "module"butmainpoints atdist/index.cjs, and dependencies chalk@5, ora@9, uuid@13 are ESM-only → arequire()on them will ERR_REQUIRE_ESM. Remove or rebuild the CJS entry (or switchmainto the ESM build) to ensure runtime compatibility.packages/convert/src/jupyter-to-deepnote.ts (7)
1-5: LGTM!Imports follow ESM conventions and use named exports correctly.
7-24: LGTM!Interface definitions correctly model Jupyter notebook structure. The
biome-ignorefor outputs is appropriate given the varied nature of Jupyter cell outputs.
30-43: LGTM!DeepnoteFile initialization is correct with appropriate defaults.
53-69: LGTM!Cell-to-block conversion correctly handles source arrays, execution counts, and outputs. Type mapping is accurate.
71-78: LGTM!Notebook structure is correctly assembled with appropriate defaults.
81-83: LGTM!YAML serialization and file writing are correct.
86-111: LGTM!Bijective base-36 implementation is correct with proper validation and overflow protection.
packages/convert/src/jupyter-to-deepnote.test.ts (12)
1-20: LGTM!Test setup correctly mocks UUID generation for deterministic tests while preserving actual UUID functions.
22-95: LGTM!Sorting key tests comprehensively verify bijective base-36 behavior and uniqueness across a range of indices.
110-159: LGTM!Basic conversion test thoroughly validates file structure, notebook metadata, and block content with precise assertions.
161-176: LGTM!Dedicated test for array source handling makes the edge case explicit.
178-209: LGTM!Null execution_count handling is correctly tested with inline fixture.
211-242: LGTM!Multi-notebook conversion test validates correct merging and content preservation.
244-279: LGTM!Real-world notebook test validates practical conversion with appropriate spot-checks rather than exhaustive assertions.
281-306: LGTM!UUID generation test ensures all entities receive identifiers.
308-324: LGTM!Timestamp validation with round-trip check ensures ISO format compliance.
326-345: LGTM!YAML validity test ensures deserializer can parse the output.
347-390: LGTM!Output preservation test validates exact structure retention for code cell outputs.
392-422: LGTM!Markdown cell test correctly validates output field omission.
|
@coderabbitai Can you review this again with the latest changes? |
|
@Artmann: I'll review the latest changes in this PR. ✅ Actions performedReview triggered.
|
1 similar comment
|
@Artmann: I'll review the latest changes in this PR. ✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
.gitignore(1 hunks)
🔇 Additional comments (1)
.gitignore (1)
1-10: Deduplication resolved. LGTM.Entries are now canonical and non-duplicated.
There was a problem hiding this comment.
Actionable comments posted: 4
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
packages/convert/src/cli.ts(1 hunks)packages/convert/src/jupyter-to-deepnote.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
packages/*/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
packages/*/src/**/*.{ts,tsx}: Use strict type checking and prefer type safety over convenience
Use const for immutable values
Avoid any; use proper type definitions and type guards
Files:
packages/convert/src/jupyter-to-deepnote.tspackages/convert/src/cli.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Follow Biome's lint rules as configured in biome.json
Use literal keys (dot notation) instead of bracket notation when possible
Prefer single quotes for strings (except when avoiding escapes)
Files:
packages/convert/src/jupyter-to-deepnote.tspackages/convert/src/cli.ts
packages/*/src/**/*
📄 CodeRabbit inference engine (CLAUDE.md)
Place source code under packages/*/src/
Files:
packages/convert/src/jupyter-to-deepnote.tspackages/convert/src/cli.ts
🧠 Learnings (6)
📓 Common learnings
Learnt from: CR
PR: deepnote/vscode-deepnote#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-09T11:21:57.494Z
Learning: Applies to src/notebooks/deepnote/deepnoteDataConverter.ts : deepnoteDataConverter.ts performs Deepnote data transformations
📚 Learning: 2025-10-09T11:21:57.494Z
Learnt from: CR
PR: deepnote/vscode-deepnote#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-09T11:21:57.494Z
Learning: Applies to src/notebooks/deepnote/deepnoteDataConverter.ts : deepnoteDataConverter.ts performs Deepnote data transformations
Applied to files:
packages/convert/src/jupyter-to-deepnote.tspackages/convert/src/cli.ts
📚 Learning: 2025-09-03T12:59:14.489Z
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/instructions/notebooks.instructions.md:0-0
Timestamp: 2025-09-03T12:59:14.489Z
Learning: Applies to src/notebooks/export/**/*.ts : Update FileConverter to handle the new export format
Applied to files:
packages/convert/src/jupyter-to-deepnote.ts
📚 Learning: 2025-09-03T12:59:14.489Z
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/instructions/notebooks.instructions.md:0-0
Timestamp: 2025-09-03T12:59:14.489Z
Learning: Applies to src/notebooks/export/**/*.ts : On conversion failures, provide detailed error reporting with suggested fixes
Applied to files:
packages/convert/src/jupyter-to-deepnote.ts
📚 Learning: 2025-09-03T12:56:39.535Z
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/instructions/kernel-jupyter.instructions.md:0-0
Timestamp: 2025-09-03T12:56:39.535Z
Learning: Applies to src/kernels/jupyter/interpreter/**/*.ts : Verify nbconvert availability for export features, handling platform-specific requirements
Applied to files:
packages/convert/src/jupyter-to-deepnote.ts
📚 Learning: 2025-09-03T12:59:14.489Z
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/instructions/notebooks.instructions.md:0-0
Timestamp: 2025-09-03T12:59:14.489Z
Learning: Applies to src/notebooks/export/**/*.ts : Gracefully handle file system issues (permissions/space) during export operations
Applied to files:
packages/convert/src/jupyter-to-deepnote.ts
🧬 Code graph analysis (1)
packages/convert/src/cli.ts (2)
packages/convert/src/jupyter-to-deepnote.ts (1)
convertIpynbFilesToDeepnoteFile(26-82)packages/convert/src/index.ts (1)
convertIpynbFilesToDeepnoteFile(2-2)
There was a problem hiding this comment.
Actionable comments posted: 5
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
cspell.json(1 hunks)packages/convert/src/jupyter-to-deepnote.test.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
packages/*/src/**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
packages/*/src/**/*.test.{ts,tsx}: Place test files next to the source files with .test.ts or .test.tsx extension
Use Vitest as the testing framework for all tests
Import { describe, expect, it } from 'vitest' in tests
Use dedent from ts-dedent for multiline string comparisons in tests
Follow existing test patterns (see packages/blocks/src/blocks/*.test.ts); write clear names, group with describe(), cover edge cases, errors, special characters, and verify exact output for code-generation functions
Files:
packages/convert/src/jupyter-to-deepnote.test.ts
packages/*/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
packages/*/src/**/*.{ts,tsx}: Use strict type checking and prefer type safety over convenience
Use const for immutable values
Avoid any; use proper type definitions and type guards
Files:
packages/convert/src/jupyter-to-deepnote.test.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Follow Biome's lint rules as configured in biome.json
Use literal keys (dot notation) instead of bracket notation when possible
Prefer single quotes for strings (except when avoiding escapes)
Files:
packages/convert/src/jupyter-to-deepnote.test.ts
packages/*/src/**/*
📄 CodeRabbit inference engine (CLAUDE.md)
Place source code under packages/*/src/
Files:
packages/convert/src/jupyter-to-deepnote.test.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
PR: deepnote/vscode-deepnote#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-09T11:21:57.494Z
Learning: Applies to src/notebooks/deepnote/deepnoteDataConverter.ts : deepnoteDataConverter.ts performs Deepnote data transformations
📚 Learning: 2025-10-14T13:43:36.364Z
Learnt from: CR
PR: deepnote/deepnote#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-14T13:43:36.364Z
Learning: Applies to packages/*/src/**/*.test.{ts,tsx} : Follow existing test patterns (see packages/blocks/src/blocks/*.test.ts); write clear names, group with describe(), cover edge cases, errors, special characters, and verify exact output for code-generation functions
Applied to files:
packages/convert/src/jupyter-to-deepnote.test.ts
📚 Learning: 2025-09-03T12:54:35.368Z
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/instructions/interactiveWindow.instructions.md:0-0
Timestamp: 2025-09-03T12:54:35.368Z
Learning: Applies to src/interactive-window/**/*.ts : Add unit and integration tests for new features and modifications; include performance and cross-platform test coverage
Applied to files:
packages/convert/src/jupyter-to-deepnote.test.ts
🧬 Code graph analysis (1)
packages/convert/src/jupyter-to-deepnote.test.ts (2)
packages/convert/src/index.ts (1)
convertIpynbFilesToDeepnoteFile(2-2)packages/convert/src/jupyter-to-deepnote.ts (1)
convertIpynbFilesToDeepnoteFile(29-89)
| counter++ | ||
| return `test-uuid-${counter.toString().padStart(3, '0')}` |
There was a problem hiding this comment.
I wouldn't use counter tbf because if i add a new test at the beginning of the file it will require me to regenerate all of the snapshots after that test because the counter would be incremented in those
We'll use this in the VS Code extension to help users migrate from Jupyter notebooks.
Summary by CodeRabbit
Release Notes
New Features
Documentation
Chores
Summary by CodeRabbit
New Features
Documentation
Tests
Chores