Skip to content

feat: add .deepnote file schema and deserializer - #28

Merged
andyjakubowski merged 6 commits into
mainfrom
andy/oss-137-add-deepnote-file-deserializer-to-deepnoteblocks-package
Oct 7, 2025
Merged

andyjakubowski merged 6 commits into
mainfrom
andy/oss-137-add-deepnote-file-deserializer-to-deepnoteblocks-package

Conversation

@andyjakubowski

@andyjakubowski andyjakubowski commented Oct 7, 2025 •

Copy link
Copy Markdown
Contributor

Closes https://linear.app/deepnote/issue/OSS-137/add-deepnote-file-deserializer-to-deepnoteblocks-package

Summary by CodeRabbit

  • New Features

    • Import Deepnote (YAML) files with schema validation and clear, user-friendly errors; public API to deserialize Deepnote files.
  • Chores

    • Added runtime dependencies for YAML parsing and schema validation.
  • Tests

    • Added comprehensive tests covering YAML parsing, successful deserialization, and validation/error scenarios.

Signed-off-by: Andy Jakubowski <hello@andyjakubowski.com>
@coderabbitai

coderabbitai Bot commented Oct 7, 2025 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Added runtime deps yaml and zod to packages/blocks. Introduced Zod schemas and inferred types for Deepnote files/blocks (deepnoteFileSchema, deepnoteFileBlockSchema and types). Added parseYaml utility that wraps yaml.parse and standardizes parse errors. Implemented deserializeDeepnoteFile(yamlContent: string) which parses YAML and validates it with Zod, throwing formatted errors on parse or validation failures. Exported DeepnoteFile type and deserializeDeepnoteFile from the package entry point. Tests for parsing and deserialization were added.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Caller
  participant Deserializer as deserializeDeepnoteFile
  participant Parser as parseYaml
  participant YAML as yaml.parse
  participant Schema as deepnoteFileSchema (zod)

  Caller->>Deserializer: deserializeDeepnoteFile(yamlContent)
  Deserializer->>Parser: parseYaml(yamlContent)
  Parser->>YAML: parse(yamlContent)
  alt parse success
    YAML-->>Parser: parsedObject
    Parser-->>Deserializer: parsedObject
    Deserializer->>Schema: safeParse(parsedObject)
    alt validation succeeds
      Schema-->>Deserializer: { success: true, data }
      Deserializer-->>Caller: return DeepnoteFile
    else validation fails
      Schema-->>Deserializer: { success: false, error }
      Deserializer-->>Caller: throw Error("Invalid Deepnote file: <path>: <message>")
    end
  else parse failure
    YAML-->>Parser: throw Error
    Parser-->>Deserializer: throw Error("Failed to parse Deepnote file: ...")
  end
Loading

Possibly related PRs

  • deepnote/deepnote-internal#18443: Adds a Deepnote file Zod schema and YAML parse/deserialize utilities (deepnoteFileSchema, parseYaml, deserializeDeepnoteFile) — strong overlap in code and intent.

Suggested reviewers

  • Artmann
  • saltenasl
  • jamesbhobbs

Pre-merge checks

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly summarizes the addition of a .deepnote file schema and deserializer, which is the main thrust of this PR. It follows conventional commit style and clearly communicates the feature to maintainers. The phrasing is concise and accurately reflects the changes made to dependencies, schema definitions, parser, deserializer, and exports.
Linked Issues Check ✅ Passed The PR implements the deserializer specified in OSS-137 by adding YAML parsing via parseYaml, a Zod-based Deepnote file schema, a deserializeDeepnoteFile function, and corresponding exports. Tests cover parsing success and failure scenarios and detailed error messaging. The changes fully address the objective to add a Deepnote file deserializer to the @deepnote/blocks package.
Out of Scope Changes Check ✅ Passed All changes in this PR directly relate to adding the .deepnote file deserializer feature, including dependency additions for yaml and zod, schema definitions, parser and deserializer functions, and tests. There are no modifications to unrelated modules or features outside the linked issue scope. The package.json updates and index exports serve only to support the deserializer functionality.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

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

@codecov

codecov Bot commented Oct 7, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.82353% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 93.55%. Comparing base (6b57f63) to head (5b24eeb).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/blocks/src/index.ts 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #28      +/-   ##
==========================================
+ Coverage   92.67%   93.55%   +0.88%     
==========================================
  Files          16       19       +3     
  Lines         505      590      +85     
  Branches      167      117      -50     
==========================================
+ Hits          468      552      +84     
- Misses         37       38       +1     

☔ 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.


return parsed
} catch (_) {
throw new Error('Failed to parse Deepnote file.')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we want to include the parse error here, or does it not contain anything useful?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

Artmann
Artmann previously approved these changes Oct 7, 2025
Signed-off-by: Andy Jakubowski <hello@andyjakubowski.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 6

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d9bc0a0 and 343a2b4.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • packages/blocks/package.json (1 hunks)
  • packages/blocks/src/deserialize-file/deepnote-file-schema.ts (1 hunks)
  • packages/blocks/src/deserialize-file/deserialize-deepnote-file.ts (1 hunks)
  • packages/blocks/src/deserialize-file/parse-yaml.ts (1 hunks)
  • packages/blocks/src/index.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-12T12:52:09.726Z
Learnt from: CR
PR: deepnote/vscode-deepnote#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-12T12:52:09.726Z
Learning: Applies to src/notebooks/deepnote/deepnoteTypes.ts : deepnoteTypes.ts should contain only type definitions

Applied to files:

  • packages/blocks/src/deserialize-file/deepnote-file-schema.ts
🧬 Code graph analysis (1)
packages/blocks/src/deserialize-file/deserialize-deepnote-file.ts (2)
packages/blocks/src/deserialize-file/deepnote-file-schema.ts (2)
  • DeepnoteFile (65-65)
  • deepnoteFileSchema (17-63)
packages/blocks/src/deserialize-file/parse-yaml.ts (1)
  • parseYaml (3-11)
🔇 Additional comments (2)
packages/blocks/src/index.ts (1)

1-1: LGTM!

Clean export addition following existing patterns.

packages/blocks/src/deserialize-file/deserialize-deepnote-file.ts (1)

7-25: Well-structured error handling.

The function correctly uses safeParse, extracts path information, and constructs clear error messages. The separation of YAML parsing and schema validation is clean.

Comment thread packages/blocks/package.json Resolved
Signed-off-by: Andy Jakubowski <hello@andyjakubowski.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between da6628b and 88b71de.

📒 Files selected for processing (2)
  • packages/blocks/src/deserialize-file/deserialize-deepnote-file.test.ts (1 hunks)
  • packages/blocks/src/deserialize-file/parse-yaml.test.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
packages/blocks/src/deserialize-file/parse-yaml.test.ts (1)
packages/blocks/src/deserialize-file/parse-yaml.ts (1)
  • parseYaml (3-12)
packages/blocks/src/deserialize-file/deserialize-deepnote-file.test.ts (2)
packages/blocks/src/deserialize-file/parse-yaml.ts (1)
  • parseYaml (3-12)
packages/blocks/src/deserialize-file/deepnote-file-schema.ts (1)
  • deepnoteFileSchema (17-63)

Signed-off-by: Andy Jakubowski <hello@andyjakubowski.com>
@andyjakubowski
andyjakubowski requested a review from Artmann October 7, 2025 12:39
coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 7, 2025
Signed-off-by: Andy Jakubowski <hello@andyjakubowski.com>

@Artmann Artmann left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚀 🗄️

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 33e589e and 5b24eeb.

📒 Files selected for processing (1)
  • packages/blocks/src/index.ts (1 hunks)

Comment thread packages/blocks/src/index.ts Resolved
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