Skip to content

Conversation

@saltenasl
Copy link
Contributor

@saltenasl saltenasl commented Jan 14, 2026

Summary

  • Add convertBlockToJupyterCell function for streaming export of individual Deepnote blocks to Jupyter cells
  • Export the function and JupyterCell type for TypeScript consumers

Motivation

Consumers need to export large notebooks to Jupyter format in a streaming fashion—processing blocks one at a time rather than loading the entire notebook into memory.

Usage

import { convertBlockToJupyterCell } from '@deepnote/convert'
import type { JupyterCell } from '@deepnote/convert'

for await (const block of blockStream) {
  const cell: JupyterCell = convertBlockToJupyterCell(block)
  outputStream.write(JSON.stringify(cell))
}

Summary by CodeRabbit

Release Notes

  • New Features

    • New capability to convert individual Deepnote items to Jupyter format with full metadata preservation including identifiers, type information, and source data
    • Supports code, markdown, and SQL content types
  • Tests

    • Comprehensive test coverage added for single-item and multi-item conversion scenarios

✏️ Tip: You can customize this high-level summary in your review settings.

@saltenasl saltenasl requested a review from a team as a code owner January 14, 2026 09:56
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 14, 2026

📝 Walkthrough

Walkthrough

The package version increments to 2.2.0. A previously internal per-block converter function is renamed, promoted to the public API as convertBlockToJupyterCell, and re-exported through the main index. The function converts individual Deepnote blocks to Jupyter cells. convertBlocksToJupyterNotebook is updated to call this new public function. Comprehensive tests validate the conversion for various block types and metadata preservation.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title accurately describes the main change: adding a new per-block Jupyter export function with clear naming.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Jan 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.57%. Comparing base (7f68999) to head (a1dd7e9).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #215   +/-   ##
=======================================
  Coverage   91.57%   91.57%           
=======================================
  Files          41       41           
  Lines        2041     2041           
  Branches      630      630           
=======================================
  Hits         1869     1869           
  Misses        172      172           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/convert/src/deepnote-to-jupyter.ts (1)

183-183: TODO noted.

Consider tracking outputs_reference as a follow-up issue.

Want me to open an issue for this?

🤖 Fix all issues with AI agents
In `@packages/convert/src/deepnote-to-jupyter.test.ts`:
- Around line 293-441: Add edge-case tests that cover blocks with empty content
and blocks with missing/undefined metadata: create DeepnoteBlock fixtures where
content is '' and where metadata is omitted or set to undefined, call
convertBlockToJupyterCell (and optionally convertBlocksToJupyterNotebook for a
list case) and assert expected behavior (cell.source becomes '' or empty
array/string as appropriate, cell.metadata exists and preserves deepnote_*
fields only when present, and no crashes occur). Include references to
convertBlockToJupyterCell, convertBlocksToJupyterNotebook, and DeepnoteBlock in
the new tests.
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 7f68999 and a1dd7e9.

📒 Files selected for processing (4)
  • packages/convert/package.json
  • packages/convert/src/deepnote-to-jupyter.test.ts
  • packages/convert/src/deepnote-to-jupyter.ts
  • packages/convert/src/index.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Place test files next to source files with .test.ts or .test.tsx extension
Use strict type checking in TypeScript files
Prefer type safety over convenience in TypeScript
Use const for immutable values
Avoid any types - use proper type definitions
Follow Biome's rules (configured in biome.json)
Use literal keys instead of bracket notation when possible
Prefer single quotes for strings (except when avoiding escapes)
Keep code clean and readable following Biome standards

Files:

  • packages/convert/src/index.ts
  • packages/convert/src/deepnote-to-jupyter.test.ts
  • packages/convert/src/deepnote-to-jupyter.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.test.{ts,tsx}: Use Vitest as the testing framework
Follow existing test patterns in the codebase (see packages/blocks/src/blocks/*.test.ts)
Test edge cases, error handling, and special characters

Files:

  • packages/convert/src/deepnote-to-jupyter.test.ts
🔇 Additional comments (9)
packages/convert/package.json (1)

3-3: Version bump looks correct.

Minor version increment (2.1.3 → 2.2.0) aligns with adding convertBlockToJupyterCell as a new, backward-compatible public API.

packages/convert/src/index.ts (1)

5-10: Export addition is clean.

convertBlockToJupyterCell properly added to public API. JupyterCell type already exported at line 89 for typing the return value.

packages/convert/src/deepnote-to-jupyter.ts (3)

52-52: Clean delegation.

convertBlocksToJupyterNotebook now calls the new public per-block converter, maintaining single responsibility.


127-146: Good documentation.

JSDoc with streaming example clearly communicates the intended use case.


147-188: Implementation looks solid.

Property access via in checks handles the union type correctly. Metadata spread with explicit overrides ensures custom fields take precedence.

packages/convert/src/deepnote-to-jupyter.test.ts (4)

293-314: Good test structure.

Covers cell type, source, execution count, outputs, and metadata mapping.


368-399: Nice parity test.

Ensures per-block conversion matches batch conversion output—prevents drift between the two APIs.


401-420: Input block test covers metadata preservation.

Verifies deepnote_variable_name and deepnote_variable_value pass through.


422-440: Execution timing coverage is thorough.

Tests executionStartedAt, executionFinishedAt, and contentHash preservation.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

"name": "@deepnote/convert",
"version": "2.1.3",
"version": "2.2.0",
"description": "",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, i just include bumps in these to save time on waiting for approvals, release immediately after it gets merged.

Worst case scenario - there will be a conflict in this line and i'll need to update it when it happens

@saltenasl saltenasl merged commit db20dc9 into main Jan 14, 2026
20 checks passed
@saltenasl saltenasl deleted the ls/convert-block-by-block branch January 14, 2026 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants