Skip to content

docs: oss docs - #69

Closed
Yggdrasill501 wants to merge 2 commits into
mainfrom
filipzirnt/mar/ossdocs
Closed

Yggdrasill501 wants to merge 2 commits into
mainfrom
filipzirnt/mar/ossdocs

Conversation

@Yggdrasill501

@Yggdrasill501 Yggdrasill501 commented Oct 29, 2025 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Documentation
    • Added comprehensive guides for Deepnote project organization, local and cloud workflows, and file format reference.
    • Added migration guides from Jupyter, PyCharm, and VS Code Jupyter to Deepnote.
    • Added setup and usage documentation for VS Code and JupyterLab extensions.
    • Added reference documentation for blocks, SQL queries, and supported code block types.

@Yggdrasill501
Yggdrasill501 requested a review from a team as a code owner October 29, 2025 02:44
@Yggdrasill501
Yggdrasill501 marked this pull request as draft October 29, 2025 02:44
@coderabbitai

coderabbitai Bot commented Oct 29, 2025 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR adds 20 documentation files covering Deepnote's open-source ecosystem and local tooling. Documentation includes guides for the @deepnote/blocks and @deepnote/convert packages, the .deepnote YAML format specification, local development setups (VS Code extension, JupyterLab extension, Toolkit), cloud migration workflows, notebook conversion between formats, and comprehensive references for supported block types. No code or public APIs were modified.

Possibly related PRs

Suggested reviewers

  • saltenasl
  • jamesbhobbs
  • Artmann

Pre-merge checks

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title Check ❓ Inconclusive The title "docs: oss docs" is related to the changeset, which adds 20 new documentation files for OSS tools and concepts. However, the title is vague and generic. "oss docs" doesn't convey what was actually documented—whether it's setup guides, migration paths, tool references, format specifications, or something else. While "docs:" correctly identifies this as a documentation change, the remainder lacks specificity and doesn't meaningfully summarize the content for someone scanning commit history. Consider a more specific title that hints at the documentation's scope, such as "docs: add oss setup, migration, and reference guides" or "docs: add comprehensive deepnote oss documentation." This would help teammates quickly understand that the PR adds a full suite of guides, not just generic OSS information.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

@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: 15

📜 Review details

Configuration used: CodeRabbit 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 c19d0da and 40143c2.

📒 Files selected for processing (20)
  • docs/oss/blocks-package.md (1 hunks)
  • docs/oss/converting-notebooks.md (1 hunks)
  • docs/oss/deepnote-format.md (1 hunks)
  • docs/oss/deepnote-in-jupyterlab.md (1 hunks)
  • docs/oss/deepnote.code-workspace (1 hunks)
  • docs/oss/jupyter-to-deepnote.md (1 hunks)
  • docs/oss/local-setup.md (1 hunks)
  • docs/oss/local-to-cloud-workflows.md (1 hunks)
  • docs/oss/migrating-to-cloud.md (1 hunks)
  • docs/oss/migrating-to-ipynb.md (1 hunks)
  • docs/oss/organizing-notebooks.md (1 hunks)
  • docs/oss/pycharm-to-deepnote.md (1 hunks)
  • docs/oss/reading-deepnote-files.md (1 hunks)
  • docs/oss/sql-blocks.md (1 hunks)
  • docs/oss/supported-code-blocks.md (1 hunks)
  • docs/oss/vscode-extension.md (1 hunks)
  • docs/oss/vscode-jupyter-to-deepnote.md (1 hunks)
  • docs/oss/vscode-projects.md (1 hunks)
  • docs/oss/vscode-running.md (1 hunks)
  • docs/oss/vscode-supported-blocks.md (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{md,yml,yaml}

📄 CodeRabbit inference engine (CLAUDE.md)

Use Prettier formatting for Markdown and YAML files

Files:

  • docs/oss/local-to-cloud-workflows.md
  • docs/oss/vscode-projects.md
  • docs/oss/organizing-notebooks.md
  • docs/oss/blocks-package.md
  • docs/oss/local-setup.md
  • docs/oss/vscode-jupyter-to-deepnote.md
  • docs/oss/vscode-extension.md
  • docs/oss/deepnote-in-jupyterlab.md
  • docs/oss/supported-code-blocks.md
  • docs/oss/migrating-to-cloud.md
  • docs/oss/deepnote-format.md
  • docs/oss/converting-notebooks.md
  • docs/oss/vscode-supported-blocks.md
  • docs/oss/migrating-to-ipynb.md
  • docs/oss/pycharm-to-deepnote.md
  • docs/oss/sql-blocks.md
  • docs/oss/jupyter-to-deepnote.md
  • docs/oss/reading-deepnote-files.md
  • docs/oss/vscode-running.md
🪛 GitHub Actions: CI
docs/oss/deepnote.code-workspace

[error] 1-20: Prettier formatting check failed. The file would be reformatted. Run 'prettier --write docs/oss/deepnote.code-workspace' to fix code style issues.

🪛 Gitleaks (8.28.0)
docs/oss/supported-code-blocks.md

[high] 205-205: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🪛 markdownlint-cli2 (0.18.1)
docs/oss/organizing-notebooks.md

125-125: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


126-126: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


131-131: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


135-135: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


136-136: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


143-143: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


147-147: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


148-148: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


162-162: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


163-163: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


223-223: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


235-235: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


240-240: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


251-251: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


261-261: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


278-278: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


294-294: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


309-309: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


342-342: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


377-377: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


395-395: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


398-398: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


406-406: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


445-445: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


481-481: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


501-501: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


524-524: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


577-577: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


592-592: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


632-632: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


650-650: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


658-658: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


685-685: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


838-838: Bare URL used

(MD034, no-bare-urls)


895-895: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

docs/oss/local-setup.md

125-125: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


126-126: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


131-131: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


135-135: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


136-136: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


143-143: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


147-147: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


148-148: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


162-162: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


163-163: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


223-223: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


235-235: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


240-240: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


251-251: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


261-261: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


278-278: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


294-294: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


309-309: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


342-342: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


377-377: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


395-395: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


398-398: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


406-406: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)

docs/oss/vscode-jupyter-to-deepnote.md

152-152: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


173-173: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


184-184: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


188-188: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


189-189: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


205-205: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


211-211: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


217-217: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


223-223: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


260-260: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


274-274: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


285-285: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


298-298: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


317-317: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


334-334: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


334-334: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


344-344: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


344-344: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


365-365: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


365-365: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


375-375: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


375-375: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


397-397: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


418-418: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


475-475: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


487-487: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


524-524: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


536-536: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


577-577: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


593-593: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


616-616: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


635-635: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


660-660: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


682-682: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


760-760: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


789-789: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


826-826: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


841-841: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


849-849: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


860-860: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


868-868: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


951-951: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

docs/oss/vscode-extension.md

152-152: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


173-173: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


184-184: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


188-188: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


189-189: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


205-205: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


211-211: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


217-217: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


223-223: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


260-260: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


274-274: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


285-285: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


298-298: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


317-317: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


334-334: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


334-334: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


344-344: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


344-344: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


365-365: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


365-365: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


375-375: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


375-375: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


397-397: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


418-418: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


475-475: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


487-487: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


524-524: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


536-536: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


577-577: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


593-593: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


616-616: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


635-635: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


660-660: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


682-682: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


760-760: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


789-789: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


826-826: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


841-841: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


849-849: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)

docs/oss/deepnote-in-jupyterlab.md

17-17: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


49-49: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


139-139: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


154-154: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


172-172: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


197-197: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


206-206: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


326-326: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


326-326: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


338-338: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


361-361: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


421-421: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


433-433: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


439-439: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


456-456: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


461-461: Hard tabs
Column: 1

(MD010, no-hard-tabs)


462-462: Hard tabs
Column: 1

(MD010, no-hard-tabs)


465-465: Hard tabs
Column: 1

(MD010, no-hard-tabs)


468-468: Hard tabs
Column: 1

(MD010, no-hard-tabs)


469-469: Hard tabs
Column: 1

(MD010, no-hard-tabs)


470-470: Hard tabs
Column: 1

(MD010, no-hard-tabs)


473-473: Hard tabs
Column: 1

(MD010, no-hard-tabs)


477-477: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


493-493: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


505-505: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


529-529: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


540-540: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


558-558: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


570-570: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


595-595: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


631-631: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


648-648: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


663-663: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


685-685: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


711-711: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


722-722: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


798-798: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


817-817: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


855-855: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


874-874: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


879-879: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


884-884: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


968-968: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

docs/oss/supported-code-blocks.md

31-31: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


46-46: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


65-65: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


108-108: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


126-126: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


147-147: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


180-180: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


193-193: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


204-204: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


215-215: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


228-228: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


242-242: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


253-253: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


266-266: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


277-277: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


288-288: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


306-306: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


322-322: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


327-327: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


346-346: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


357-357: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


373-373: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


387-387: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


398-398: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


411-411: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


422-422: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


427-427: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


434-434: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


445-445: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


459-459: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


471-471: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


477-477: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


484-484: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


496-496: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


515-515: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


526-526: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


535-535: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


544-544: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


553-553: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


560-560: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


586-586: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


599-599: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


625-625: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


647-647: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


661-661: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


673-673: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


688-688: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


701-701: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


712-712: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


725-725: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


747-747: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


760-760: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


769-769: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


778-778: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


793-793: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


803-803: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


820-820: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


830-830: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


840-840: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


891-891: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


905-905: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


917-917: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


926-926: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


935-935: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)

docs/oss/migrating-to-cloud.md

152-152: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


173-173: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


184-184: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


188-188: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


189-189: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


205-205: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


211-211: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


217-217: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


223-223: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


260-260: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


274-274: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


285-285: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


298-298: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


317-317: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


334-334: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


334-334: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


344-344: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


344-344: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


365-365: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


365-365: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


375-375: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


375-375: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


397-397: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


418-418: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


475-475: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


487-487: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


524-524: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


536-536: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


577-577: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


593-593: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


616-616: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


635-635: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


660-660: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


682-682: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


760-760: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


789-789: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


826-826: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


841-841: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


849-849: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


860-860: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


868-868: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


951-951: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

docs/oss/vscode-supported-blocks.md

33-33: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


60-60: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


73-73: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


83-83: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


89-89: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


93-93: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


99-99: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


103-103: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


109-109: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


113-113: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


119-119: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


127-127: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


133-133: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


137-137: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


143-143: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


147-147: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


153-153: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


158-158: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


164-164: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


191-191: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


218-218: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


242-242: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


302-302: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


307-307: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


322-322: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


327-327: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


398-398: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


408-408: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


448-448: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


461-461: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


498-498: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


559-559: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


587-587: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)

docs/oss/pycharm-to-deepnote.md

69-69: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


91-91: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


134-134: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


134-134: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


149-149: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


149-149: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


161-161: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


161-161: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


179-179: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


209-209: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


243-243: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


272-272: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


346-346: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


380-380: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


453-453: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


466-466: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


482-482: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


535-535: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


544-544: Ordered list item prefix
Expected: 1; Actual: 2; Style: 1/1/1

(MD029, ol-prefix)


545-545: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


572-572: Ordered list item prefix
Expected: 1; Actual: 3; Style: 1/1/1

(MD029, ol-prefix)


573-573: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


588-588: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


606-606: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


630-630: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


662-662: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


680-680: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


680-680: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


689-689: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


704-704: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


718-718: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


802-802: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


802-802: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


811-811: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


811-811: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


821-821: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


821-821: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


833-833: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


849-849: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


869-869: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


902-902: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


921-921: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


942-942: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


949-949: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


955-955: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


963-963: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


981-981: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

docs/oss/sql-blocks.md

153-153: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


169-169: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


190-190: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


234-234: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


246-246: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


274-274: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


315-315: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


350-350: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


350-350: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


362-362: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


362-362: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


372-372: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


372-372: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


389-389: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


390-390: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


401-401: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


402-402: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


415-415: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


416-416: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


432-432: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


443-443: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


464-464: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


479-479: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


492-492: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


518-518: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


537-537: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


562-562: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


584-584: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


584-584: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


600-600: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)

docs/oss/jupyter-to-deepnote.md

125-125: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


126-126: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


131-131: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


135-135: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


136-136: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


143-143: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


147-147: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


148-148: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


162-162: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


163-163: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


223-223: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


235-235: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


240-240: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


251-251: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


261-261: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


278-278: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


294-294: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


309-309: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


342-342: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


377-377: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


395-395: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


398-398: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


406-406: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


445-445: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


481-481: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


501-501: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


524-524: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


577-577: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


592-592: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


632-632: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


650-650: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


658-658: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


685-685: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


838-838: Bare URL used

(MD034, no-bare-urls)


895-895: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

docs/oss/reading-deepnote-files.md

435-435: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


441-441: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


447-447: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


454-454: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


462-462: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


473-473: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


485-485: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


494-494: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


499-499: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


537-537: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


546-546: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


554-554: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


606-606: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


718-718: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


735-735: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)

docs/oss/vscode-running.md

26-26: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


31-31: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


36-36: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


37-37: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


184-184: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


211-211: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


251-251: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


289-289: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


289-289: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


348-348: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


357-357: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


385-385: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


412-412: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


426-426: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


510-510: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


523-523: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


539-539: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


543-543: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


547-547: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


550-550: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


554-554: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


557-557: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


561-561: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


564-564: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


579-579: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


594-594: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


611-611: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


617-617: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


635-635: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


647-647: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


654-654: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


665-665: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


675-675: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


684-684: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


693-693: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


701-701: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


709-709: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


739-739: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


759-759: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


778-778: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


867-867: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


909-909: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


915-915: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


921-921: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


927-927: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


933-933: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


950-950: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

🔇 Additional comments (7)
docs/oss/vscode-projects.md (1)

1-1021: Comprehensive project guide.

Well-structured documentation covering project setup, organization, workflows, and collaboration. Image placeholders are appropriate for documentation.

docs/oss/local-setup.md (1)

13-13: Address internal comment.

Comment suggests making the overview table "more human friendly" - consider revising before publication.

docs/oss/vscode-supported-blocks.md (1)

1-610: Thorough block type reference.

Comprehensive documentation of supported blocks. Run Prettier to address formatting.

docs/oss/migrating-to-ipynb.md (1)

27-28: Add referenced content.

Comments indicate missing link and visual content. Address before publication if needed.

docs/oss/vscode-jupyter-to-deepnote.md (1)

1-951: Detailed migration guide.

Comprehensive coverage of VS Code Jupyter to Deepnote migration with practical examples and troubleshooting.

docs/oss/local-to-cloud-workflows.md (1)

1-1112: Comprehensive migration workflow guide.

Well-organized with phased approach, practical examples, and automation scripts.

docs/oss/jupyter-to-deepnote.md (1)

1-895: Solid Jupyter migration guide.

Clear feature comparisons, practical examples, and comprehensive troubleshooting section.

Comment on lines +1 to +675
---
title: Deepnote Blocks Package
description: Complete reference for the @deepnote/blocks package - TypeScript types, utilities, and Python code generation for Deepnote notebook blocks.
noIndex: false
noContent: false
---

# Deepnote Blocks Package

The `@deepnote/blocks` package is the core TypeScript library that defines Deepnote's block system. It provides type definitions, validation schemas, and utilities for working with all Deepnote block types, including Python code generation and markdown conversion.

## Overview

This package enables:

- **Type-safe block definitions** for all Deepnote block types
- **Python code generation** from blocks for local execution
- **Markdown conversion** for text-based blocks
- **Block validation** using Zod schemas
- **File serialization/deserialization** for `.deepnote` files

## Installation

```bash
npm install @deepnote/blocks
# or
pnpm add @deepnote/blocks
# or
yarn add @deepnote/blocks
```

## Core Concepts

### Block Structure

Every Deepnote block follows a common structure:

```typescript
interface DeepnoteBlock {
id: string // Unique block identifier
type: string // Block type (e.g., 'code', 'sql', 'markdown')
sortingKey: string // Base-36 encoded position for ordering
blockGroup?: string // Optional grouping identifier
content?: string // Block content (code, text, query, etc.)
executionCount?: number // Number of times executed
version?: number // Block schema version
metadata?: Record<string, any> // Block-specific metadata
outputs?: any[] // Execution outputs (for executable blocks)
}
```

### Block Categories

Blocks are organized into several categories:

1. **Executable Blocks**: Code, SQL
2. **Input Blocks**: Text, Textarea, Checkbox, Select, Slider, File, Date, Date Range
3. **Display Blocks**: Visualization, Big Number, Button
4. **Text Blocks**: Headings, Paragraphs, Bullets, Todos, Callouts
5. **Media Blocks**: Image, Separator

## Python Code Generation

The primary use case for this package is generating executable Python code from Deepnote blocks for local execution.

### Basic Usage

```typescript
import { createPythonCode } from '@deepnote/blocks'

// Generate Python code from any executable block
const pythonCode = createPythonCode(block)
```

### Code Blocks

<!-- Code blocks are the simplest - they contain Python code directly: -->

```typescript
import type { CodeBlock } from '@deepnote/blocks'

const codeBlock: CodeBlock = {
id: 'block-001',
type: 'code',
sortingKey: '1',
content: `
import pandas as pd
df = pd.read_csv('data.csv')
df.head()
`,
metadata: {},
}

const pythonCode = createPythonCode(codeBlock)
// Output:
// if '_dntk' in globals():
// _dntk.dataframe_utils.configure_dataframe_formatter('{}')
// else:
// _deepnote_current_table_attrs = '{}'
//
// import pandas as pd
// df = pd.read_csv('data.csv')
// df.head()
```

### Table State Configuration

Code blocks can include table state metadata for DataFrame display configuration:

```typescript
const codeBlockWithTableState: CodeBlock = {
id: 'block-002',
type: 'code',
sortingKey: '2',
content: 'df',
metadata: {
deepnote_table_state: {
sortBy: [],
filters: [],
pageSize: 50,
pageIndex: 0,
columnOrder: ['id', 'name', 'value'],
hiddenColumnIds: ['internal_id'],
columnDisplayNames: [],
conditionalFilters: [],
cellFormattingRules: [],
wrappedTextColumnIds: [],
},
},
}
```

### SQL Blocks

SQL blocks execute database queries and assign results to Python variables:

```typescript
import type { SqlBlock } from '@deepnote/blocks'

const sqlBlock: SqlBlock = {
id: 'block-003',
type: 'sql',
sortingKey: '3',
content: 'SELECT * FROM users WHERE active = true',
metadata: {
deepnote_variable_name: 'active_users',
sql_integration_id: 'snowflake-connection-123',
deepnote_return_variable_type: 'dataframe', // or 'query_preview'
},
}

const pythonCode = createPythonCode(sqlBlock)
// Output:
// if '_dntk' in globals():
// _dntk.dataframe_utils.configure_dataframe_formatter('{}')
// else:
// _deepnote_current_table_attrs = '{}'
//
// active_users = _dntk.execute_sql(
// 'SELECT * FROM users WHERE active = true',
// 'SQL_SNOWFLAKE_CONNECTION_123',
// audit_sql_comment='',
// sql_cache_mode='cache_disabled',
// return_variable_type='dataframe'
// )
// active_users
```

### Input Blocks

Input blocks generate Python variable assignments:

#### Text Input

```typescript
import type { InputTextBlock } from '@deepnote/blocks'

const textInput: InputTextBlock = {
id: 'block-004',
type: 'input-text',
sortingKey: '4',
content: '',
metadata: {
deepnote_variable_name: 'user_name',
deepnote_variable_value: 'John Doe',
},
}

const pythonCode = createPythonCode(textInput)
// Output: user_name = 'John Doe'
```

#### Checkbox Input

```typescript
import type { InputCheckboxBlock } from '@deepnote/blocks'

const checkboxInput: InputCheckboxBlock = {
id: 'block-005',
type: 'input-checkbox',
sortingKey: '5',
content: '',
metadata: {
deepnote_variable_name: 'is_enabled',
deepnote_variable_value: true,
},
}

const pythonCode = createPythonCode(checkboxInput)
// Output: is_enabled = True
```

#### Select Input

```typescript
import type { InputSelectBlock } from '@deepnote/blocks'

const selectInput: InputSelectBlock = {
id: 'block-006',
type: 'input-select',
sortingKey: '6',
content: '',
metadata: {
deepnote_variable_name: 'selected_region',
deepnote_variable_value: 'US-West',
deepnote_variable_options: ['US-East', 'US-West', 'EU', 'Asia'],
deepnote_allow_multiple_values: false,
},
}

const pythonCode = createPythonCode(selectInput)
// Output: selected_region = 'US-West'

// Multi-select example
const multiSelectInput: InputSelectBlock = {
id: 'block-007',
type: 'input-select',
sortingKey: '7',
content: '',
metadata: {
deepnote_variable_name: 'selected_regions',
deepnote_variable_value: ['US-West', 'EU'],
deepnote_allow_multiple_values: true,
},
}

const pythonCode2 = createPythonCode(multiSelectInput)
// Output: selected_regions = ['US-West', 'EU']
```

#### Slider Input

```typescript
import type { InputSliderBlock } from '@deepnote/blocks'

const sliderInput: InputSliderBlock = {
id: 'block-008',
type: 'input-slider',
sortingKey: '8',
content: '',
metadata: {
deepnote_variable_name: 'threshold',
deepnote_variable_value: '0.75',
deepnote_slider_min_value: 0,
deepnote_slider_max_value: 1,
deepnote_slider_step: 0.05,
},
}

const pythonCode = createPythonCode(sliderInput)
// Output: threshold = 0.75
```

#### Date Range Input

Date range inputs support multiple formats:

```typescript
import type { InputDateRangeBlock } from '@deepnote/blocks'

// Relative date range (past 7 days)
const relativeDateRange: InputDateRangeBlock = {
id: 'block-009',
type: 'input-date-range',
sortingKey: '9',
content: '',
metadata: {
deepnote_variable_name: 'date_range',
deepnote_variable_value: 'past7days',
},
}

const pythonCode = createPythonCode(relativeDateRange)
// Output:
// from datetime import datetime as _deepnote_datetime, timedelta as _deepnote_timedelta
// date_range = [
// _deepnote_datetime.now().date() - _deepnote_timedelta(days=7),
// _deepnote_datetime.now().date()
// ]

// Absolute date range
const absoluteDateRange: InputDateRangeBlock = {
id: 'block-010',
type: 'input-date-range',
sortingKey: '10',
content: '',
metadata: {
deepnote_variable_name: 'custom_range',
deepnote_variable_value: ['2024-01-01', '2024-12-31'],
},
}

// Custom days range
const customDaysRange: InputDateRangeBlock = {
id: 'block-011',
type: 'input-date-range',
sortingKey: '11',
content: '',
metadata: {
deepnote_variable_name: 'last_30_days',
deepnote_variable_value: 'customDays30',
},
}
```

**Supported relative ranges:**
- `'past7days'` - Last 7 days
- `'past14days'` - Last 14 days
- `'pastMonth'` - Last 30 days
- `'past3months'` - Last 90 days
- `'past6months'` - Last 180 days
- `'pastYear'` - Last 365 days
- `'customDaysN'` - Last N days (e.g., `'customDays45'`)

### Visualization Blocks

Visualization blocks use Vega-Lite specifications:

```typescript
import type { VisualizationBlock } from '@deepnote/blocks'

const chartBlock: VisualizationBlock = {
id: 'block-012',
type: 'visualization',
sortingKey: '12',
content: '',
metadata: {
deepnote_variable_name: 'sales_chart',
deepnote_chart_spec: {
$schema: 'https://vega.github.io/schema/vega-lite/v5.json',
data: { name: 'df' },
mark: 'bar',
encoding: {
x: { field: 'month', type: 'ordinal' },
y: { field: 'sales', type: 'quantitative' },
},
},
},
}

const pythonCode = createPythonCode(chartBlock)
// Output:
// from deepnote_toolkit import chart
// sales_chart = chart(df, {...})
```

### Button Blocks

Button blocks can trigger variable updates:

```typescript
import type { ButtonBlock } from '@deepnote/blocks'

const buttonBlock: ButtonBlock = {
id: 'block-013',
type: 'button',
sortingKey: '13',
content: 'Refresh Data',
metadata: {
deepnote_button_variable_name: 'refresh_trigger',
deepnote_button_variable_value: 'timestamp',
},
}

// Requires execution context
const pythonCode = createPythonCode(buttonBlock, {
timestamp: '2024-01-27T12:00:00Z',
})
// Output: refresh_trigger = '2024-01-27T12:00:00Z'
```

### Big Number Blocks

Big number blocks display KPIs with Jinja2 templates:

```typescript
import type { BigNumberBlock } from '@deepnote/blocks'

const bigNumberBlock: BigNumberBlock = {
id: 'block-014',
type: 'big-number',
sortingKey: '14',
content: '',
metadata: {
deepnote_variable_name: 'total_revenue',
deepnote_big_number_template: '{{ value | currency }}',
deepnote_big_number_value_source: 'df["revenue"].sum()',
},
}

const pythonCode = createPythonCode(bigNumberBlock)
// Output:
// from deepnote_toolkit import big_number
// total_revenue = big_number(df["revenue"].sum(), template='{{ value | currency }}')
```

## Markdown Conversion

Text blocks can be converted to and from markdown:

```typescript
import { createMarkdown, stripMarkdown } from '@deepnote/blocks'

// Heading blocks
const h1Block = {
type: 'text-cell-h1',
content: 'Main Title',
// ...
}
createMarkdown(h1Block) // "# Main Title"

// Bullet lists
const bulletBlock = {
type: 'text-cell-bullet',
content: 'List item',
// ...
}
createMarkdown(bulletBlock) // "- List item"

// Todo items
const todoBlock = {
type: 'text-cell-todo',
content: 'Complete task',
metadata: { checked: true },
// ...
}
createMarkdown(todoBlock) // "- [x] Complete task"

// Callouts
const calloutBlock = {
type: 'text-cell-callout',
content: 'Important note',
metadata: { color: 'blue' },
// ...
}
createMarkdown(calloutBlock) // "> Important note"

// Strip markdown formatting
stripMarkdown(h1Block) // "Main Title"
```

## Block Type Guards

The package provides type guard functions for runtime type checking:

```typescript
import {
isCodeBlock,
isSqlBlock,
isInputBlock,
isInputTextBlock,
isInputCheckboxBlock,
isVisualizationBlock,
isTextBlock,
} from '@deepnote/blocks'

function processBlock(block: DeepnoteBlock) {
if (isCodeBlock(block)) {
// TypeScript knows block is CodeBlock
console.log('Code:', block.content)
} else if (isSqlBlock(block)) {
// TypeScript knows block is SqlBlock
console.log('Query:', block.content)
console.log('Variable:', block.metadata.deepnote_variable_name)
} else if (isInputTextBlock(block)) {
// TypeScript knows block is InputTextBlock
console.log('Input value:', block.metadata.deepnote_variable_value)
}
}
```

## File Schema Validation

The package includes Zod schemas for validating `.deepnote` files:

```typescript
import { deepnoteFileSchema, type DeepnoteFile } from '@deepnote/blocks'

// Validate a Deepnote file
const fileData = {
metadata: {
createdAt: '2025-01-27T12:00:00Z',
},
version: '1.0.0',
project: {
id: 'project-123',
name: 'My Project',
notebooks: [
{
id: 'notebook-001',
name: 'Analysis',
blocks: [],
executionMode: 'block',
isModule: false,
},
],
integrations: [],
settings: {},
},
}

const result = deepnoteFileSchema.safeParse(fileData)
if (result.success) {
const validFile: DeepnoteFile = result.data
console.log('Valid Deepnote file')
} else {
console.error('Validation errors:', result.error)
}
```

## Error Handling

The package throws specific errors for unsupported operations:

```typescript
import { createPythonCode, UnsupportedBlockTypeError } from '@deepnote/blocks'

try {
const pythonCode = createPythonCode(block)
} catch (error) {
if (error instanceof UnsupportedBlockTypeError) {
console.error('Block type not supported for Python generation:', error.message)
}
}
```

## Advanced Usage

### Custom Block Processing

```typescript
import { createPythonCode, type DeepnoteBlock } from '@deepnote/blocks'

function processNotebook(blocks: DeepnoteBlock[]): string {
const pythonCode = blocks
.filter(block => {
// Only process executable blocks
return ['code', 'sql', 'input-text', 'input-checkbox'].includes(block.type)
})
.map(block => {
try {
return createPythonCode(block)
} catch (error) {
console.warn(`Skipping block ${block.id}: ${error.message}`)
return null
}
})
.filter(code => code !== null)
.join('\n\n')

return pythonCode
}
```

### Batch Conversion

```typescript
import { createPythonCode } from '@deepnote/blocks'
import type { DeepnoteFile } from '@deepnote/blocks'

function convertProjectToPython(deepnoteFile: DeepnoteFile): Map<string, string> {
const notebookScripts = new Map<string, string>()

for (const notebook of deepnoteFile.project.notebooks) {
const pythonCode = notebook.blocks
.map(block => {
try {
return createPythonCode(block)
} catch {
return null
}
})
.filter(code => code !== null)
.join('\n\n')

notebookScripts.set(notebook.name, pythonCode)
}

return notebookScripts
}
```

## TypeScript Types Reference

### Core Types

```typescript
// Base block interface
interface DeepnoteBlock {
id: string
type: string
sortingKey: string
blockGroup?: string
content?: string
executionCount?: number
version?: number
metadata?: Record<string, any>
outputs?: any[]
}

// Executable block metadata
interface ExecutableBlockMetadata {
deepnote_cell_height?: number
deepnote_to_be_reexecuted?: boolean
// ... other execution-related metadata
}

// Table state for DataFrames
interface TableState {
sortBy: any[]
filters: any[]
pageSize: number
pageIndex: number
columnOrder: string[]
hiddenColumnIds: string[]
columnDisplayNames: any[]
conditionalFilters: any[]
cellFormattingRules: any[]
wrappedTextColumnIds: string[]
}
```

### Block-Specific Types

See the [Supported Code Blocks](./supported-code-blocks.md) documentation for detailed type definitions for each block type.

## Best Practices

1. **Type Safety**: Always use TypeScript types for block definitions
2. **Validation**: Validate blocks with Zod schemas before processing
3. **Error Handling**: Wrap `createPythonCode` calls in try-catch blocks
4. **Variable Naming**: Use `sanitizePythonVariableName` for user-provided variable names
5. **Metadata**: Store block-specific configuration in the `metadata` field
6. **Sorting**: Use base-36 encoded strings for `sortingKey` to maintain order

## Related Documentation

- [Supported Code Blocks](./supported-code-blocks.md) - Complete reference for all block types
- [Deepnote Format](./deepnote-format.md) - File format specification
- [Converting Notebooks](./converting-notebooks.md) - Jupyter ↔ Deepnote conversion

## Resources

- [GitHub Repository](https://github.com/deepnote/deepnote)
- [Package Source](https://github.com/deepnote/deepnote/tree/main/packages/blocks)
- [NPM Package](https://www.npmjs.com/package/@deepnote/blocks)


<!-- Note: Explain what big nubmer is,

Expalin different types of blocks we have
exaplain the date formats
add link to our vega lite fork
add screenshots etc
block guards to best practices

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.

🛠️ Refactor suggestion | 🟠 Major

Apply Prettier formatting and remove incomplete TODO section.

Issues:

  1. ~50+ MD031 violations—add blank lines around fenced code blocks
  2. ~3 MD040 violations—specify language for code fences (e.g., \``typescript→```python, ```yaml`)
  3. Lines 669–675: Remove incomplete TODO comments (<!-- Note: Explain what big nubmer is...) or convert to a GitHub issue for tracked follow-up
🤖 Prompt for AI Agents
In docs/oss/blocks-package.md around lines 1 to 675, the file needs formatting
fixes: run Prettier (or the repo's markdown formatter) to normalize whitespace
and line wrapping, ensure there is a blank line before and after every fenced
code block to fix MD031, add explicit language identifiers on all code fences
(e.g., ```typescript, ```python, ```yaml) to fix MD040, and remove the
incomplete TODO HTML comment at lines 669–675 (or extract its contents to a new
GitHub issue and delete the comment) so no dangling notes remain.

Comment on lines +1 to +383
---
title: Converting Jupyter notebooks to Deepnote format
description: Learn how to convert Jupyter Notebook files (`.ipynb`) to Deepnote project files (`.deepnote`) using the `@deepnote/convert` tool.
noIndex: false
noContent: false
---

# How to convert Jupyter notebooks to Deepnote format

This guide explains how to convert Jupyter Notebook files (`.ipynb`) to Deepnote project files (`.deepnote`) using the `@deepnote/convert` tool.

## Overview

The `@deepnote/convert` package provides a command-line tool and programmatic API for converting standard Jupyter notebooks into Deepnote's open-source format. This allows you to:

- Migrate existing Jupyter notebooks to Deepnote format
- Convert single notebooks or entire directories
- Preserve code, markdown, outputs, and execution counts
- Create multi-notebook Deepnote projects

## Installation How to install Jupyter to deepnote converter

### Global installation (recommended for CLI)

Install the tool globally to use the `deepnote-convert` command from anywhere:

```bash
npm install -g @deepnote/convert
```

### Local installation (for programmatic use)

Install as a project dependency:

```bash
npm install @deepnote/convert
```

Or using other package managers:

```bash
# Using pnpm
pnpm add @deepnote/convert

# Using yarn
yarn add @deepnote/convert
```

### Requirements

- **Node.js**: Version 18 or higher

## CLI usage

The package provides a `deepnote-convert` command-line tool for converting notebooks.

### Convert a single notebook

Convert a single `.ipynb` file to a `.deepnote` file:

```bash
deepnote-convert path/to/notebook.ipynb
```

This creates a `notebook.deepnote` file in the current directory containing a single-notebook project.

**Example:**

```bash
deepnote-convert analysis.ipynb
# Creates: analysis.deepnote
```

### Convert a directory of notebooks

Convert all `.ipynb` files in a directory to a single `.deepnote` project:

```bash
deepnote-convert path/to/notebooks/
```

This creates a multi-notebook project where each `.ipynb` file becomes a separate notebook within the project.

**Example:**

```bash
deepnote-convert ./ml-experiments
# Creates: ml-experiments.deepnote (containing all notebooks from the directory)
```

### CLI options

#### `--projectName <name>`

Set a custom name for the Deepnote project:

```bash
deepnote-convert notebook.ipynb --projectName "My Analysis"
```

If not specified, the project name defaults to:
- The filename (without extension) for single files
- The directory name for directories

#### `-o, --outputPath <path>`

Specify where to save the output `.deepnote` file:

```bash
# Save to a specific file
deepnote-convert notebook.ipynb -o output/project.deepnote

# Save to a directory (filename will be auto-generated)
deepnote-convert notebook.ipynb -o output/
```

If not specified, the output file is saved in the current directory.

### CLI Examples

```bash
# Convert with custom project name
deepnote-convert titanic.ipynb --projectName "Titanic Analysis"

# Convert directory with custom output location
deepnote-convert ./analysis --projectName "Data Science Project" -o ./output

# Convert multiple notebooks from a folder
deepnote-convert ~/notebooks/ml-experiments -o ~/projects/

# Convert and specify both name and output
deepnote-convert data.ipynb --projectName "Data Exploration" -o projects/exploration.deepnote
```

## Programmatic usage

You can use the conversion function programmatically in Node.js or TypeScript applications.

### Basic example

```typescript
import { convertIpynbFilesToDeepnoteFile } from '@deepnote/convert'

await convertIpynbFilesToDeepnoteFile(
['path/to/notebook.ipynb'],
{
outputPath: 'output.deepnote',
projectName: 'My Project'
}
)
```

### Convert multiple notebooks

```typescript
import { convertIpynbFilesToDeepnoteFile } from '@deepnote/convert'

// Convert multiple notebooks into a single project
await convertIpynbFilesToDeepnoteFile(
[
'notebooks/data-cleaning.ipynb',
'notebooks/analysis.ipynb',
'notebooks/visualization.ipynb'
],
{
outputPath: 'projects/data-pipeline.deepnote',
projectName: 'Data Pipeline'
}
)
```

### With Error Handling

```typescript
import { convertIpynbFilesToDeepnoteFile } from '@deepnote/convert'

try {
await convertIpynbFilesToDeepnoteFile(
['notebook.ipynb'],
{
outputPath: 'output.deepnote',
projectName: 'My Analysis'
}
)
console.log('Conversion successful!')
} catch (error) {
console.error('Conversion failed:', error.message)
}
```

### API Reference

#### `convertIpynbFilesToDeepnoteFile(inputFilePaths, options)`

Converts Jupyter Notebook files to a Deepnote project file.

**Parameters:**

- `inputFilePaths` (string[]): Array of paths to `.ipynb` files to convert
- `options` (ConvertIpynbFilesToDeepnoteFileOptions):
- `outputPath` (string): Path where the `.deepnote` file will be saved
- `projectName` (string): Name for the Deepnote project

**Returns:** Promise<void>

**Throws:** Error if file reading or parsing fails

## Conversion Details

### What Gets Converted

The conversion process preserves:

- ✅ **Code cells**: Python/R/SQL code with syntax
- ✅ **Markdown cells**: Text, headers, lists, images, LaTeX
- ✅ **Cell outputs**: Execution results, plots, tables
- ✅ **Execution counts**: Cell execution order
- ✅ **Cell metadata**: Custom metadata attached to cells

### Project Structure

The resulting `.deepnote` file contains:

```yaml
metadata:
createdAt: "2024-01-01T00:00:00.000Z"
project:
id: "unique-project-id"
name: "Project Name"
notebooks:
- id: "notebook-id"
name: "Notebook Name"
blocks:
- id: "block-id"
type: "code" | "markdown"
content: "cell content"
outputs: [...]
executionCount: 1
version: "1.0.0"
```

### Cell Type Mapping

| Jupyter Cell Type | Deepnote Block Type |
|-------------------|---------------------|
| `code` | `code` |
| `markdown` | `markdown` |
| `raw` | Not supported |

### Limitations

- **Raw cells**: Raw cells are not currently converted
- **Widgets**: Interactive widgets may not be fully preserved
- **Extensions**: Jupyter extensions and custom cell types are not supported
- **Kernel metadata**: Kernel-specific metadata is not preserved

## Use Cases

### Migrating Existing Projects

Convert an entire project directory:

```bash
deepnote-convert ~/jupyter-projects/data-analysis \
--projectName "Data Analysis Project" \
-o ~/deepnote-projects/
```

### Batch Conversion Script

Create a script to convert multiple projects:

```typescript
import { convertIpynbFilesToDeepnoteFile } from '@deepnote/convert'
import { readdir } from 'node:fs/promises'
import { join } from 'node:path'

async function convertAllNotebooks(inputDir: string, outputDir: string) {
const files = await readdir(inputDir)
const ipynbFiles = files
.filter(f => f.endsWith('.ipynb'))
.map(f => join(inputDir, f))

for (const file of ipynbFiles) {
const name = file.replace('.ipynb', '')
await convertIpynbFilesToDeepnoteFile(
[file],
{
outputPath: join(outputDir, `${name}.deepnote`),
projectName: name
}
)
}
}
```

### CI/CD Integration

Integrate conversion into your build pipeline:

```yaml
# .github/workflows/convert-notebooks.yml
name: Convert Notebooks
on: [push]

jobs:
convert:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- run: npm install -g @deepnote/convert
- run: deepnote-convert notebooks/ -o dist/
- uses: actions/upload-artifact@v3
with:
name: deepnote-projects
path: dist/*.deepnote
```

## Troubleshooting

### Common Issues

#### "Failed to read file"

**Cause**: File path is incorrect or file doesn't exist

**Solution**: Verify the file path and ensure the file exists:

```bash
ls -la path/to/notebook.ipynb
```

#### "Failed to parse: invalid JSON"

**Cause**: The `.ipynb` file is corrupted or not valid JSON

**Solution**: Validate the notebook file:

```bash
# Check if it's valid JSON
cat notebook.ipynb | python -m json.tool
```

#### "ENOENT: no such file or directory"

**Cause**: Output directory doesn't exist

**Solution**: The tool creates parent directories automatically, but ensure you have write permissions:

```bash
# Check permissions
ls -ld output/
```

### Getting Help

- **GitHub Issues**: [github.com/deepnote/deepnote/issues](https://github.com/deepnote/deepnote/issues)
- **Documentation**: See [deepnote-format.md](./deepnote-format.md) for format details

## Next Steps

After converting your notebooks:

1. **Open in Deepnote**: Load the `.deepnote` file in the Deepnote application
2. **Verify conversion**: Check that all cells and outputs are preserved
3. **Configure environment**: Set up Python packages and environment variables
4. **Run notebooks**: Execute cells to ensure everything works

## Related Documentation

- [Deepnote Format Specification](./deepnote-format.md) - Details on the `.deepnote` file format
- [Local Setup Guide](./local-setup.md) - Running Deepnote locally
- [@deepnote/blocks Package](../../packages/blocks/README.md) - Working with Deepnote blocks programmatically

## License

Apache-2.0

<!-- Deepnote extends jupyter in bla bla ways etc...Deepnote is a drop-in replacement for Jupyter. To programmatically upgrade to Deepnote without replacing your workflow, you can easily use our CLI tool ... -->

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.

🛠️ Refactor suggestion | 🟠 Major

Apply Prettier formatting; fix duplicate heading.

  1. ~35+ MD031 violations—add blank lines around code fences throughout
  2. Line 21: Heading reads awkwardly: "Installation How to install Jupyter to deepnote converter"
    • Should be: ## Installation (or split into ## Installation and subsection ### Global installation)
🤖 Prompt for AI Agents
docs/oss/converting-notebooks.md lines ~1-383: The file has many missing blank
lines around fenced code blocks (MD031) and an awkward/duplicate heading at line
~21; run Prettier or format the Markdown, ensure every ``` fenced code block has
a blank line before and after the fence, and replace the heading "Installation
How to install Jupyter to deepnote converter" with a clear top-level subsection
"## Installation" and then add separate subsections "### Global installation
(recommended for CLI)" and "### Local installation (for programmatic use)" as
shown in the surrounding content; after edits, run a markdown linter/Prettier to
fix remaining spacing and heading consistency.

Comment on lines +1 to +370
---
title: Introduction to Deepnote YAML file format
description: Learn about the Deepnote file format, its structure, and key differences from Jupyter notebooks.
noIndex: false
noContent: false
---

# Introduction to Deepnote YAML file format, and difference between Deepnote & Jupyter

Deepnote uses a human-readable YAML format (`.deepnote` files) to store notebooks and projects. This format is designed to be version-control friendly, easily readable, and extensible while maintaining compatibility with the Jupyter ecosystem.

## What is a `.deepnote` file?

A `.deepnote` file is a YAML-formatted document that represents an entire Deepnote project, including:

- **Project metadata** (creation date, modification date, version)
- **One or more notebooks** with their blocks and execution state
- **Project settings** (environment configuration, dependencies, integrations)
- **Execution modes** and working directories

Unlike Jupyter's JSON-based `.ipynb` format, Deepnote's YAML format prioritizes human readability and git-friendly diffs, making collaboration and version control significantly easier.

## File structure overview

A typical `.deepnote` file has the following top-level structure:

```yaml
metadata:
createdAt: '2025-01-27T12:00:00Z'
modifiedAt: '2025-01-27T14:30:00Z'
exportedAt: '2025-01-27T15:00:00Z'
checksum: 'abc123...'

version: '1.0.0'

project:
id: 'project-uuid'
name: 'My Data Analysis Project'
initNotebookId: 'notebook-uuid'

notebooks:
- id: 'notebook-uuid'
name: 'Analysis Notebook'
blocks: [...]
executionMode: 'block'
isModule: false
workingDirectory: '/work'

integrations:
- id: 'integration-uuid'
name: 'Snowflake Connection'
type: 'snowflake'

settings:
environment:
pythonVersion: '3.11'
customImage: 'my-custom-image:latest'
requirements:
- 'pandas>=2.0.0'
- 'numpy>=1.24.0'
sqlCacheMaxAge: 3600
```

## Key components

### Metadata section

The metadata section contains file-level information:

- **`createdAt`**: ISO 8601 timestamp of when the project was created
- **`modifiedAt`**: ISO 8601 timestamp of the last modification
- **`exportedAt`**: ISO 8601 timestamp of when the file was exported
- **`checksum`**: Optional hash for file integrity verification

### Version

The `version` field specifies the Deepnote file format version (e.g., `'1.0.0'`). This ensures backward compatibility as the format evolves.

### Project section

The project section is the core of the file, containing:

#### Project properties

- **`id`**: Unique identifier for the project
- **`name`**: Human-readable project name
- **`initNotebookId`**: Optional ID of the notebook to open by default

#### Notebooks Array

Each notebook in the project contains:

- **`id`**: Unique identifier for the notebook
- **`name`**: Notebook name
- **`blocks`**: Array of blocks (code, markdown, SQL, charts, etc.)
- **`executionMode`**: Either `'block'` (execute individual blocks) or `'downstream'` (execute dependent blocks)
- **`isModule`**: Boolean indicating if the notebook is a reusable module
- **`workingDirectory`**: Optional working directory path (defaults to `/work`)

#### Integrations Array

Connected data sources and external services:

- **`id`**: Integration identifier
- **`name`**: Human-readable integration name
- **`type`**: Integration type (e.g., `'snowflake'`, `'bigquery'`, `'postgres'`)

#### Settings Object

Project-wide configuration:

- **`environment`**: Python version and custom Docker images
- **`requirements`**: Python package dependencies
- **`sqlCacheMaxAge`**: SQL query cache duration in seconds

### Block structure

Each block in a notebook has the following structure:

```yaml
- id: 'block-uuid'
type: 'code' # or 'markdown', 'sql', 'chart', 'input', etc.
sortingKey: '1'
blockGroup: 'group-uuid'
content: |
import pandas as pd
df = pd.read_csv('data.csv')
df.head()
executionCount: 1
version: 1
metadata:
custom_field: 'value'
outputs:
- output_type: 'execute_result'
data:
text/plain: '...'
```

**Block properties:**

- **`id`**: Unique block identifier
- **`type`**: Block type (`'code'`, `'markdown'`, `'sql'`, `'chart'`, `'input'`, etc.)
- **`sortingKey`**: Base-36 encoded position for ordering blocks
- **`blockGroup`**: Optional grouping identifier for related blocks
- **`content`**: The actual code, markdown, or query content
- **`executionCount`**: Number of times the block has been executed
- **`version`**: Block schema version
- **`metadata`**: Arbitrary key-value pairs for block-specific settings
- **`outputs`**: Array of execution outputs (for code and SQL blocks)

## Deepnote vs. Jupyter: Key differences

While Deepnote maintains compatibility with Jupyter, there are important differences:

### File format

| Feature | Jupyter (`.ipynb`) | Deepnote (`.deepnote`) |
|---------|-------------------|------------------------|
| **Format** | JSON | YAML |
| **Readability** | Machine-optimized | Human-optimized |
| **Git diffs** | Noisy, hard to review | Clean, easy to review |
| **Multiple notebooks** | One file per notebook | Multiple notebooks per project |
| **Project settings** | Not included | Included in file |

<!-- Add picture of the differnece in github, and integrations part -->

### Project-level organization

**Jupyter:**
- Each notebook is a separate `.ipynb` file
- No native project concept
- Dependencies managed separately (e.g., `requirements.txt`)
- No built-in integration management

**Deepnote:**
- Single `.deepnote` file contains entire project
- Multiple notebooks organized together
- Dependencies and settings embedded in the file
- Integration configurations included
- Module system for reusable notebooks

### Block types

**Jupyter:**
- Code cells (Python, R, Julia, etc.)
- Markdown cells
- Raw cells

**Deepnote:**
- All Jupyter cell types supported
- **Additional block types:**
- SQL blocks with native database connectivity
- Chart blocks with visual query builder
- Input blocks for interactive parameters
- Big number blocks for KPIs
- Rich text blocks with advanced formatting

### Execution modes

**Jupyter:**
- Sequential execution only
- Cells executed in order or individually

**Deepnote:**
- **Block mode**: Execute blocks independently
- **Downstream mode**: Automatically execute dependent blocks
- Dependency tracking between blocks

### Metadata and settings

**Jupyter:**
```json
{
"metadata": {
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
}
}
```

**Deepnote:**
```yaml
project:
settings:
environment:
pythonVersion: '3.11'
customImage: 'custom-image:latest'
requirements:
- 'pandas>=2.0.0'
sqlCacheMaxAge: 3600
```

<!-- ### Collaboration features

**Jupyter:**
- No native collaboration support
- Requires external tools (JupyterHub, Git)
- Merge conflicts common

**Deepnote:**
- Real-time collaboration built-in
- YAML format reduces merge conflicts
- Comments and version history integrated
- Project-level permissions -->

### Output storage

**Jupyter:**
- Outputs embedded in notebook JSON
- Can make files very large
- Binary data base64-encoded

**Deepnote:**
- Outputs stored in YAML format
- Cleaner representation
- Better for version control
- Optional output persistence

## Converting Between Formats

### Jupyter to Deepnote

Use the `@deepnote/convert` package to convert Jupyter notebooks:

```bash
# Convert a single notebook
deepnote-convert notebook.ipynb

# Convert multiple notebooks into one project
deepnote-convert ./notebooks/ --projectName "My Project"

# Specify output location
deepnote-convert notebook.ipynb -o output.deepnote
```

**What gets converted:**
- ✅ Code cells → Code blocks
- ✅ Markdown cells → Markdown blocks
- ✅ Cell outputs → Block outputs
- ✅ Execution counts → Execution counts
- ✅ Cell metadata → Block metadata

**What doesn't convert:**
- ⚠️ Jupyter widgets (may need manual adjustment)
- ⚠️ Custom cell magics (may need adaptation)
- ⚠️ Kernel-specific features

### Deepnote to Jupyter

Export from Deepnote to `.ipynb` format:

```bash
# Using Deepnote UI: Notebook menu → Download as .ipynb
```

**Conversion notes:**
- SQL blocks → Converted to code cells with string representation
- Chart blocks → Converted to markdown with chart description
- Input blocks → Converted to code cells with default values
- Rich text blocks → Converted to standard markdown

## Example: Complete Deepnote File

Here's a minimal but complete example:

```yaml
metadata:
createdAt: '2025-01-27T12:00:00Z'

version: '1.0.0'

project:
id: 'abc-123-def-456'
name: 'Sales Analysis'

notebooks:
- id: 'notebook-001'
name: 'Q4 Analysis'
executionMode: 'block'
isModule: false
blocks:
- id: 'block-001'
type: 'markdown'
sortingKey: '1'
content: |
# Q4 Sales Analysis

This notebook analyzes sales data for Q4 2024.
version: 1
metadata: {}

- id: 'block-002'
type: 'code'
sortingKey: '2'
content: |
import pandas as pd

df = pd.read_csv('sales_q4.csv')
print(f"Total rows: {len(df)}")
executionCount: 1
version: 1
metadata: {}
outputs:
- output_type: 'stream'
name: 'stdout'
text: 'Total rows: 1523\n'

integrations: []

settings:
environment:
pythonVersion: '3.11'
requirements:
- 'pandas>=2.0.0'
```

## Next Steps

- **[Working with Notebooks](./notebooks.md)**: Learn how to create and manage notebooks in Deepnote
- **[Importing and Exporting](./importing-and-exporting-jupyter-notebooks.md)**: Convert between Jupyter and Deepnote formats
- **[Project Settings](./projects.md)**: Configure your project environment and dependencies
- **[Integrations](./integrations.md)**: Connect to data sources and external services

## Resources

- [Deepnote GitHub Repository](https://github.com/deepnote/deepnote)
- [@deepnote/convert Package](https://www.npmjs.com/package/@deepnote/convert)
- [Deepnote File Schema](https://github.com/deepnote/deepnote/blob/main/packages/blocks/src/deserialize-file/deepnote-file-schema.ts)

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.

🛠️ Refactor suggestion | 🟠 Major

Add blank lines around fenced code blocks per Prettier formatting.

This file has ~28 markdown linting violations (primarily MD031). Apply Prettier to auto-format or manually add blank lines before/after code fences throughout. Example:

- ```yaml
+ 
+ ```yaml
  metadata:
- ```
+ ```
+ 

Also: Line 165 is a commented TODO about adding a GitHub diff screenshot—consider removing if not actionable or opening a separate issue to track it.

🤖 Prompt for AI Agents
In docs/oss/deepnote-format.md around lines 1-370, the file has multiple
Markdown linting violations (MD031) due to missing blank lines before/after
fenced code blocks and contains a commented TODO at line 165; run Prettier (or
manually) to insert a blank line before and after every fenced code block
throughout the file to satisfy MD031, and either remove the non-actionable TODO
on line 165 or convert it into a tracked issue reference (e.g., add an Issue
link or move the note to a separate checklist) so the comment is not left as
inline TODO in the docs.

Comment on lines +1 to +968
---
title: Using Deepnote Format in JupyterLab
description: Complete guide to working with Deepnote's YAML format in JupyterLab, including conversion, compatibility, and workflow integration.
noIndex: false
noContent: false
---

# Using Deepnote Format in JupyterLab

This guide explains how to work with Deepnote's `.deepnote` files in JupyterLab, convert between formats, and integrate Deepnote into your JupyterLab workflow.

## Understanding the Formats

### Jupyter Format (.ipynb)

**Structure:**
```json
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": ["print('hello')"]
}
],
"metadata": {
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
```

**Characteristics:**
- JSON format
- Machine-optimized
- Noisy git diffs
- Single notebook per file
- Outputs embedded

### Deepnote Format (.deepnote)

**Structure:**
```yaml
metadata:
createdAt: '2025-01-27T12:00:00Z'

version: '1.0.0'

project:
id: 'project-001'
name: 'My Analysis'

notebooks:
- id: 'notebook-001'
name: 'Analysis'
blocks:
- id: 'block-001'
type: code
content: |
print('hello')
executionCount: 1
```

**Characteristics:**
- YAML format
- Human-readable
- Clean git diffs
- Multiple notebooks per file
- Project-level organization

<!-- IMAGE: Side-by-side comparison of .ipynb vs .deepnote file structure -->
<!-- FILE: format-comparison.png -->
<!-- CAPTION: Jupyter .ipynb vs Deepnote .deepnote format -->

## Why Use Deepnote Format in JupyterLab?

### Advantages

**Version Control:**
- ✅ Clean, readable diffs
- ✅ Easy to review changes
- ✅ Better merge conflict resolution
- ✅ Human-readable format

**Organization:**
- ✅ Multiple notebooks in one file
- ✅ Project-level settings
- ✅ Shared dependencies
- ✅ Integrated integrations

**Collaboration:**
- ✅ Better for code review
- ✅ Easier to understand changes
- ✅ Clear structure
- ✅ Documentation-friendly

**Portability:**
- ✅ Works in JupyterLab
- ✅ Works in VS Code
- ✅ Works in Deepnote Cloud
- ✅ Easy to edit manually

### When to Use Each Format

**Use .ipynb when:**
- Working exclusively in Jupyter ecosystem
- Need compatibility with older tools
- Using Jupyter-specific extensions
- Sharing with Jupyter-only users

**Use .deepnote when:**
- Working with teams
- Need better version control
- Want project-level organization
- Planning to use Deepnote Cloud
- Need multiple notebooks in one project

## Converting Between Formats

### Installing the Converter

```bash
# Install Node.js converter
npm install -g @deepnote/convert

# Or install Python converter
pip install deepnote-convert
```

### Converting .ipynb to .deepnote

**Single Notebook:**
```bash
# Basic conversion
deepnote-convert notebook.ipynb

# Specify output
deepnote-convert notebook.ipynb -o output.deepnote

# With project name
deepnote-convert notebook.ipynb --projectName "My Project"

# Clear outputs
deepnote-convert notebook.ipynb --clearOutputs
```

**Multiple Notebooks:**
```bash
# Convert all notebooks in directory
deepnote-convert notebooks/*.ipynb --projectName "Analysis Project"

# Convert to separate files
for file in notebooks/*.ipynb; do
deepnote-convert "$file" -o "deepnote/$(basename $file .ipynb).deepnote"
done

# Batch convert with custom names
deepnote-convert \
notebook1.ipynb \
notebook2.ipynb \
notebook3.ipynb \
--projectName "Complete Analysis"
```

**Python Script:**
```python
from deepnote_convert import convert_notebook

# Convert single file
convert_notebook(
'notebook.ipynb',
'notebook.deepnote',
project_name='My Project',
clear_outputs=True
)

# Convert multiple files
notebooks = ['nb1.ipynb', 'nb2.ipynb', 'nb3.ipynb']
for nb in notebooks:
output = nb.replace('.ipynb', '.deepnote')
convert_notebook(nb, output)
```

<!-- IMAGE: Screenshot of conversion process in terminal -->
<!-- FILE: conversion-terminal.png -->
<!-- CAPTION: Converting notebooks from .ipynb to .deepnote -->

### Converting .deepnote to .ipynb

**Export from Deepnote:**
```bash
# Using deepnote-cli (if available)
deepnote-cli export notebook.deepnote -o notebook.ipynb

# Or manually parse YAML and convert
python convert_deepnote_to_ipynb.py notebook.deepnote
```

**Python Conversion Script:**
```python
import yaml
import json

def deepnote_to_ipynb(deepnote_file, output_file):
"""Convert .deepnote to .ipynb format."""

# Load Deepnote file
with open(deepnote_file, 'r') as f:
deepnote_data = yaml.safe_load(f)

# Extract first notebook
notebook = deepnote_data['project']['notebooks'][0]

# Convert blocks to cells
cells = []
for block in notebook['blocks']:
if block['type'] == 'code':
cell = {
'cell_type': 'code',
'execution_count': block.get('executionCount'),
'metadata': block.get('metadata', {}),
'outputs': block.get('outputs', []),
'source': block['content'].split('\n')
}
elif block['type'].startswith('text-cell'):
cell = {
'cell_type': 'markdown',
'metadata': {},
'source': [block['content']]
}
else:
continue # Skip unsupported block types

cells.append(cell)

# Create Jupyter notebook structure
ipynb = {
'cells': cells,
'metadata': {
'kernelspec': {
'name': 'python3',
'display_name': 'Python 3'
},
'language_info': {
'name': 'python',
'version': '3.11.0'
}
},
'nbformat': 4,
'nbformat_minor': 5
}

# Save as .ipynb
with open(output_file, 'w') as f:
json.dump(ipynb, f, indent=2)

# Usage
deepnote_to_ipynb('notebook.deepnote', 'notebook.ipynb')
```

## Opening .deepnote Files in JupyterLab

### Method 1: Convert First (Recommended)

```bash
# Convert to .ipynb
deepnote-convert notebook.deepnote -o notebook.ipynb

# Open in JupyterLab
jupyter lab notebook.ipynb
```

### Method 2: Custom Viewer Extension

**Create JupyterLab Extension:**

```typescript
// src/index.ts
import { JupyterFrontEnd } from '@jupyterlab/application';
import { IDocumentWidget } from '@jupyterlab/docregistry';

// Register .deepnote file type
const extension = {
id: 'deepnote-viewer',
autoStart: true,
activate: (app: JupyterFrontEnd) => {
app.docRegistry.addFileType({
name: 'deepnote',
extensions: ['.deepnote'],
mimeTypes: ['text/yaml'],
iconClass: 'jp-MaterialIcon jp-NotebookIcon'
});
}
};

export default extension;
```

**Note:** Full extension development is beyond this guide's scope. For now, convert to .ipynb format.

### Method 3: Manual Editing

```bash
# Open as YAML file
jupyter lab notebook.deepnote

# JupyterLab will open it as text
# You can edit the YAML directly
```

<!-- IMAGE: Screenshot of .deepnote file opened in JupyterLab -->
<!-- FILE: deepnote-in-jupyterlab.png -->
<!-- CAPTION: Viewing .deepnote file in JupyterLab -->

## Working with Both Formats

### Hybrid Workflow

**Setup:**
```
project/
├── notebooks/
│ ├── analysis.ipynb # JupyterLab working copy
│ └── analysis.deepnote # Deepnote format for Git
├── scripts/
│ ├── convert.sh
│ └── sync.py
└── requirements.txt
```

**Conversion Script:**
```bash
#!/bin/bash
# convert.sh - Convert between formats

case "$1" in
to-deepnote)
for file in notebooks/*.ipynb; do
deepnote-convert "$file" -o "${file%.ipynb}.deepnote"
done
;;
to-ipynb)
for file in notebooks/*.deepnote; do
python scripts/convert_to_ipynb.py "$file"
done
;;
*)
echo "Usage: $0 {to-deepnote|to-ipynb}"
exit 1
;;
esac
```

**Sync Script:**
```python
# sync.py - Keep formats in sync
import os
import subprocess
from pathlib import Path

def sync_notebooks(direction='to-deepnote'):
"""Sync notebooks between formats."""
notebooks_dir = Path('notebooks')

if direction == 'to-deepnote':
# Convert .ipynb to .deepnote
for ipynb in notebooks_dir.glob('*.ipynb'):
deepnote = ipynb.with_suffix('.deepnote')
print(f"Converting {ipynb.name} → {deepnote.name}")
subprocess.run([
'deepnote-convert',
str(ipynb),
'-o', str(deepnote)
])

elif direction == 'to-ipynb':
# Convert .deepnote to .ipynb
for deepnote in notebooks_dir.glob('*.deepnote'):
ipynb = deepnote.with_suffix('.ipynb')
print(f"Converting {deepnote.name} → {ipynb.name}")
# Use your conversion function
deepnote_to_ipynb(str(deepnote), str(ipynb))

if __name__ == '__main__':
import sys
direction = sys.argv[1] if len(sys.argv) > 1 else 'to-deepnote'
sync_notebooks(direction)
```

**Git Hooks:**

```bash
# .git/hooks/pre-commit
#!/bin/bash
# Convert .ipynb to .deepnote before commit

for file in notebooks/*.ipynb; do
if [ -f "$file" ]; then
deepnote="${file%.ipynb}.deepnote"
deepnote-convert "$file" -o "$deepnote" --clearOutputs
git add "$deepnote"
fi
done
```

<!-- IMAGE: Diagram showing hybrid workflow -->
<!-- FILE: hybrid-workflow-diagram.png -->
<!-- CAPTION: Hybrid workflow: JupyterLab + Deepnote format -->

## JupyterLab Workflow Integration

### Daily Workflow

**Morning (Start Work):**
```bash
# 1. Pull latest changes
git pull origin main

# 2. Convert .deepnote to .ipynb
./scripts/convert.sh to-ipynb

# 3. Start JupyterLab
jupyter lab
```

**During Work:**
```bash
# Work in JupyterLab with .ipynb files
# Edit, run, test as normal
```

**Evening (End Work):**
```bash
# 1. Convert .ipynb to .deepnote
./scripts/convert.sh to-deepnote

# 2. Stage Deepnote files for commit
git add notebooks/*.deepnote

# 3. Commit changes
git commit -m "Update analysis notebooks"

# 4. Push to remote
git push origin main
```

### Automated Workflow

**Using Makefile:**
```makefile
# Makefile
.PHONY: start sync commit

start:
./scripts/convert.sh to-ipynb
jupyter lab

sync:
./scripts/convert.sh to-deepnote

commit: sync
git add notebooks/*.deepnote
git commit -m "Update notebooks"
git push origin main

clean:
rm -f notebooks/*.ipynb
```

**Usage:**
```bash
# Start working
make start

# Sync and commit
make commit

# Clean working copies
make clean
```

## Handling Deepnote-Specific Features

### SQL Blocks

**In Deepnote:**
```yaml
blocks:
- type: sql
content: |
SELECT * FROM users
WHERE active = true
metadata:
deepnote_variable_name: active_users
sql_integration_id: postgres-prod
```

**In JupyterLab (after conversion):**
```python
# Converted to code cell with comment
# SQL Block: active_users
# Integration: postgres-prod

# You'll need to add connection code:
import psycopg2
import pandas as pd

conn = psycopg2.connect(...)
active_users = pd.read_sql("""
SELECT * FROM users
WHERE active = true
""", conn)
```

**Recommendation:**
- Keep SQL in Deepnote format for cloud execution
- Convert to Python for local JupyterLab work
- Or use both: SQL blocks in Deepnote, Python in JupyterLab

### Input Blocks

**In Deepnote:**
```yaml
blocks:
- type: input-slider
metadata:
deepnote_variable_name: threshold
deepnote_variable_value: '0.5'
deepnote_slider_min_value: 0
deepnote_slider_max_value: 1
```

**In JupyterLab (after conversion):**
```python
# Converted to code cell with variable assignment
threshold = 0.5

# Or use ipywidgets
import ipywidgets as widgets
threshold_slider = widgets.FloatSlider(
value=0.5,
min=0,
max=1,
description='Threshold:'
)
display(threshold_slider)
```

### Visualization Blocks

**In Deepnote:**
```yaml
blocks:
- type: visualization
metadata:
deepnote_chart_spec:
mark: bar
encoding:
x: {field: category}
y: {field: value}
```

**In JupyterLab (after conversion):**
```python
# Converted to code cell with plotting code
import matplotlib.pyplot as plt

df.plot(kind='bar', x='category', y='value')
plt.show()

# Or use Altair (closer to Vega-Lite)
import altair as alt

alt.Chart(df).mark_bar().encode(
x='category',
y='value'
)
```

<!-- IMAGE: Screenshot showing converted blocks in JupyterLab -->
<!-- FILE: converted-blocks-jupyterlab.png -->
<!-- CAPTION: Deepnote blocks converted to JupyterLab cells -->

## Version Control Best Practices

### Git Configuration

**.gitignore:**
```gitignore
# JupyterLab
.ipynb_checkpoints/
*.ipynb

# Keep Deepnote format
!*.deepnote

# Python
__pycache__/
*.pyc
.venv/

# Data
data/raw/*
data/processed/*

# Outputs
outputs/*
```

**Why ignore .ipynb?**
- Noisy diffs
- Large file sizes (with outputs)
- Binary-like format
- Merge conflicts

**Why keep .deepnote?**
- Clean diffs
- Human-readable
- Better for review
- Smaller file sizes

### Viewing Diffs

**Jupyter Format (.ipynb):**
```diff
"cells": [
{
- "execution_count": 1,
+ "execution_count": 2,
"outputs": [
{
- "data": {"text/plain": "[1, 2, 3]"},
+ "data": {"text/plain": "[1, 2, 3, 4]"},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
```

**Deepnote Format (.deepnote):**
```diff
blocks:
- content: |
- result = [1, 2, 3]
+ result = [1, 2, 3, 4]
type: code
```

<!-- IMAGE: Git diff comparison showing .ipynb vs .deepnote -->
<!-- FILE: git-diff-comparison.png -->
<!-- CAPTION: Git diffs: .ipynb (noisy) vs .deepnote (clean) -->

### Code Review

**Reviewing .deepnote Changes:**
```bash
# View changes
git diff notebooks/analysis.deepnote

# Review specific blocks
git diff notebooks/analysis.deepnote | grep -A 10 "content:"

# Compare with previous version
git diff HEAD~1 notebooks/analysis.deepnote
```

**Better Code Review:**
- Easy to see what changed
- Clear block-by-block changes
- No noise from outputs
- Human-readable format

## Multi-Notebook Projects

### Project Structure

**Single .deepnote File:**
```yaml
project:
name: 'Data Analysis Project'

notebooks:
- id: 'nb-001'
name: 'Data Loading'
blocks: [...]

- id: 'nb-002'
name: 'Data Cleaning'
blocks: [...]

- id: 'nb-003'
name: 'Analysis'
blocks: [...]

settings:
environment:
pythonVersion: '3.11'
requirements:
- 'pandas>=2.0.0'
- 'numpy>=1.24.0'
```

**Converting to JupyterLab:**
```bash
# Extract individual notebooks
python extract_notebooks.py project.deepnote

# Creates:
# - data_loading.ipynb
# - data_cleaning.ipynb
# - analysis.ipynb
```

**Extraction Script:**
```python
# extract_notebooks.py
import yaml
import json
from pathlib import Path

def extract_notebooks(deepnote_file, output_dir='notebooks'):
"""Extract individual notebooks from .deepnote file."""

# Load Deepnote file
with open(deepnote_file, 'r') as f:
data = yaml.safe_load(f)

# Create output directory
Path(output_dir).mkdir(exist_ok=True)

# Extract each notebook
for notebook in data['project']['notebooks']:
# Convert blocks to cells
cells = []
for block in notebook['blocks']:
if block['type'] == 'code':
cell = {
'cell_type': 'code',
'execution_count': block.get('executionCount'),
'metadata': {},
'outputs': block.get('outputs', []),
'source': block['content'].split('\n')
}
cells.append(cell)
elif block['type'].startswith('text-cell'):
cell = {
'cell_type': 'markdown',
'metadata': {},
'source': [block['content']]
}
cells.append(cell)

# Create .ipynb structure
ipynb = {
'cells': cells,
'metadata': {
'kernelspec': {
'name': 'python3',
'display_name': 'Python 3'
}
},
'nbformat': 4,
'nbformat_minor': 5
}

# Save notebook
name = notebook['name'].lower().replace(' ', '_')
output_file = Path(output_dir) / f"{name}.ipynb"
with open(output_file, 'w') as f:
json.dump(ipynb, f, indent=2)

print(f"Created: {output_file}")

if __name__ == '__main__':
import sys
deepnote_file = sys.argv[1] if len(sys.argv) > 1 else 'project.deepnote'
extract_notebooks(deepnote_file)
```

<!-- IMAGE: Screenshot showing multiple notebooks extracted from one .deepnote file -->
<!-- FILE: extracted-notebooks.png -->
<!-- CAPTION: Multiple notebooks extracted from single .deepnote file -->

## Troubleshooting

### Issue: Conversion Fails

**Problem:** `deepnote-convert` fails with errors

**Solution:**
```bash
# Check notebook is valid
jupyter nbconvert --to notebook --execute notebook.ipynb

# Clear outputs first
jupyter nbconvert --clear-output --inplace notebook.ipynb

# Try conversion again
deepnote-convert notebook.ipynb

# Check for corrupted cells
python -m json.tool notebook.ipynb > /dev/null
```

### Issue: Lost Metadata

**Problem:** Metadata lost during conversion

**Solution:**
```python
# Preserve custom metadata
def convert_with_metadata(ipynb_file, deepnote_file):
# Load .ipynb
with open(ipynb_file) as f:
ipynb = json.load(f)

# Extract custom metadata
custom_meta = ipynb.get('metadata', {}).get('custom', {})

# Convert
subprocess.run(['deepnote-convert', ipynb_file, '-o', deepnote_file])

# Add custom metadata back
with open(deepnote_file) as f:
deepnote = yaml.safe_load(f)

deepnote['project']['metadata'] = custom_meta

with open(deepnote_file, 'w') as f:
yaml.dump(deepnote, f)
```

### Issue: SQL Blocks Don't Work

**Problem:** SQL blocks don't execute in JupyterLab

**Solution:**
- SQL blocks are Deepnote-specific
- Convert to Python code with database connections
- Or use JupyterLab SQL magic: `%%sql`
- Or keep SQL blocks for Deepnote Cloud execution

### Issue: Input Blocks Missing

**Problem:** Input blocks don't appear after conversion

**Solution:**
```python
# Input blocks convert to variable assignments
# In JupyterLab, replace with ipywidgets

import ipywidgets as widgets
from IPython.display import display

# Create widget
slider = widgets.FloatSlider(value=0.5, min=0, max=1)
display(slider)

# Use value
threshold = slider.value
```

## Best Practices

### 1. Choose Your Primary Format

**Option A: Deepnote Primary**
- Work in Deepnote Cloud
- Export to .ipynb for JupyterLab
- Commit .deepnote to Git

**Option B: JupyterLab Primary**
- Work in JupyterLab with .ipynb
- Convert to .deepnote for Git
- Sync to Deepnote Cloud

**Option C: Hybrid**
- Develop in JupyterLab (.ipynb)
- Convert to .deepnote for version control
- Deploy to Deepnote Cloud for sharing

### 2. Automate Conversions

```bash
# Add to .git/hooks/pre-commit
#!/bin/bash
for file in notebooks/*.ipynb; do
deepnote-convert "$file" -o "${file%.ipynb}.deepnote" --clearOutputs
git add "${file%.ipynb}.deepnote"
done
```

### 3. Document Your Workflow

```markdown
# Project Workflow

## For Developers
1. Work in JupyterLab with .ipynb files
2. Convert to .deepnote before committing
3. Push .deepnote files to Git

## For Reviewers
1. Review .deepnote files (clean diffs)
2. Convert to .ipynb for testing
3. Approve changes

## For Deployment
1. Use .deepnote files in Deepnote Cloud
2. Scheduled runs use cloud version
3. Share via Deepnote
```

### 4. Keep Formats in Sync

```python
# sync_check.py - Verify formats are in sync
import os
from pathlib import Path

def check_sync(notebooks_dir='notebooks'):
"""Check if .ipynb and .deepnote are in sync."""

issues = []

for ipynb in Path(notebooks_dir).glob('*.ipynb'):
deepnote = ipynb.with_suffix('.deepnote')

if not deepnote.exists():
issues.append(f"Missing: {deepnote.name}")
continue

# Check modification times
if ipynb.stat().st_mtime > deepnote.stat().st_mtime:
issues.append(f"Out of sync: {ipynb.name} newer than {deepnote.name}")

if issues:
print("⚠️ Sync issues found:")
for issue in issues:
print(f" - {issue}")
return False
else:
print("✓ All notebooks in sync")
return True

if __name__ == '__main__':
check_sync()
```

## Related Documentation

- [Reading .deepnote Files](./reading-deepnote-files.md) - File format details
- [Deepnote Format](./deepnote-format.md) - Format specification
- [Moving from Jupyter to Deepnote](./jupyter-to-deepnote.md) - Migration guide
- [Organizing Notebooks into Projects](./organizing-notebooks.md) - Project structure

## Conclusion

Using Deepnote format in JupyterLab provides the best of both worlds: the familiar JupyterLab interface for development and Deepnote's superior format for version control and collaboration. With proper conversion workflows and automation, you can seamlessly work between both environments.

**Choose your workflow and automate it! 🔄**

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.

🛠️ Refactor suggestion | 🟠 Major

Apply Prettier formatting to fix Markdown style violations.

Multiple formatting issues identified:

  • MD031 (~40+ occurrences): Add blank lines around fenced code blocks (lines 17, 49, 139, 154, etc.)
  • MD036 (~15+ occurrences): Replace **Label:** patterns with proper headings (lines 874, 879, 884, 968)
  • MD010 (~7 occurrences): Hard tabs found in Makefile example—replace with spaces (lines 461–473)
  • MD022 (~1 occurrence): Heading spacing (line 841)
  • MD040 (~1 occurrence): Code block language missing (line 326)

Run Prettier:

npx prettier --write docs/oss/deepnote-in-jupyterlab.md
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)

17-17: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


49-49: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


139-139: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


154-154: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


172-172: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


197-197: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


206-206: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


326-326: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


326-326: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


338-338: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


361-361: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


421-421: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


433-433: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


439-439: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


456-456: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


461-461: Hard tabs
Column: 1

(MD010, no-hard-tabs)


462-462: Hard tabs
Column: 1

(MD010, no-hard-tabs)


465-465: Hard tabs
Column: 1

(MD010, no-hard-tabs)


468-468: Hard tabs
Column: 1

(MD010, no-hard-tabs)


469-469: Hard tabs
Column: 1

(MD010, no-hard-tabs)


470-470: Hard tabs
Column: 1

(MD010, no-hard-tabs)


473-473: Hard tabs
Column: 1

(MD010, no-hard-tabs)


477-477: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


493-493: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


505-505: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


529-529: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


540-540: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


558-558: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


570-570: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


595-595: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


631-631: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


648-648: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


663-663: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


685-685: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


711-711: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


722-722: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


798-798: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


817-817: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


855-855: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


874-874: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


879-879: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


884-884: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


968-968: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

🤖 Prompt for AI Agents
In docs/oss/deepnote-in-jupyterlab.md (lines 1–968) the file fails Markdown
style checks: many fenced code blocks need surrounding blank lines (MD031),
several bold "Label:" patterns should be converted to proper headings (MD036),
the Makefile example contains hard tabs that must be replaced with spaces
(MD010), a heading spacing issue needs fixing (MD022), and at least one fenced
code block needs a language tag (MD040); fix by adding blank lines before/after
each fenced code block, replace instances like "**Label:**" with an appropriate
markdown heading (e.g., "### Label"), convert tabs to 2 or 4 spaces in the
Makefile snippet, ensure headings have a blank line before them, add the correct
language identifier to the code block missing it, then run Prettier to format
the file (npx prettier --write docs/oss/deepnote-in-jupyterlab.md) and commit
the changes.

Comment on lines +1 to +20
{
"folders": [
{
"path": "../.."
},
{
"path": "../../../deepnote-internal"
},
{
"path": "../../../deepnote-toolkit"
},
{
"path": "../../../vscode-deepnote"
},
{
"path": "../../../jupyterlab-deepnote"
}
],
"settings": {}
} No newline at end of 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.

⚠️ Potential issue | 🔴 Critical

Fix Prettier formatting.

Pipeline check failed. Run the formatter:

prettier --write docs/oss/deepnote.code-workspace
🧰 Tools
🪛 GitHub Actions: CI

[error] 1-20: Prettier formatting check failed. The file would be reformatted. Run 'prettier --write docs/oss/deepnote.code-workspace' to fix code style issues.

🤖 Prompt for AI Agents
In docs/oss/deepnote.code-workspace lines 1-20 the file is incorrectly formatted
causing the Prettier pipeline check to fail; run the project formatter (e.g.
prettier --write docs/oss/deepnote.code-workspace) or your editor’s Prettier
action to reformat the JSON file, then stage and commit the updated file so the
CI check passes.

Comment on lines +1 to +805
---
title: Reading .deepnote Files in Your IDE
description: Complete guide to understanding, reading, and working with Deepnote's YAML file format in your favorite IDE or text editor.
noIndex: false
noContent: false
---

# Reading .deepnote Files in Your IDE

Deepnote uses a human-readable YAML format (`.deepnote` files) that you can open and edit in any text editor or IDE. This guide will help you understand the file structure and work with Deepnote notebooks locally.

## Why YAML Format?

Unlike Jupyter's JSON format, Deepnote's YAML format is designed to be:

- **Human-readable** - Easy to read and understand
- **Git-friendly** - Clean diffs for version control
- **Easy to edit** - Modify notebooks in any text editor
- **Structured** - Clear hierarchy and organization
- **Extensible** - Easy to add new features

## Opening .deepnote Files

### In Your IDE

`.deepnote` files are plain text YAML files. You can open them in:

- **VS Code** - Best experience with YAML extension
- **IntelliJ/WebStorm** - Built-in YAML support
- **Sublime Text** - With YAML syntax highlighting
- **Vim/Neovim** - With YAML plugins
- **Emacs** - With yaml-mode
- **Any text editor** - Works as plain text

### Recommended VS Code Extensions

For the best experience in VS Code, install:

1. **YAML** by Red Hat
- Syntax highlighting
- Schema validation
- Auto-completion
- Error detection

2. **Deepnote** (official extension)
- Native `.deepnote` file support
- Block execution
- Output rendering

## File Structure Overview

A `.deepnote` file has three main sections:

```yaml
metadata: # File-level metadata
createdAt: '2025-01-27T12:00:00Z'
modifiedAt: '2025-01-27T14:30:00Z'

version: '1.0.0' # File format version

project: # Project content
id: 'project-uuid'
name: 'My Project'
notebooks: [...]
integrations: [...]
settings: {...}
```

## Understanding the Metadata Section

The metadata section contains file-level information:

```yaml
metadata:
createdAt: '2025-01-27T12:00:00Z' # When project was created
modifiedAt: '2025-01-27T14:30:00Z' # Last modification time
exportedAt: '2025-01-27T15:00:00Z' # When file was exported
checksum: 'abc123def456...' # Optional integrity hash
```

**What You Can Do:**
- ✅ Read timestamps to track changes
- ✅ Use checksum for file integrity verification
- ⚠️ Avoid manually editing (auto-generated)

## Understanding the Project Section

### Project Properties

```yaml
project:
id: 'abc-123-def-456' # Unique project identifier
name: 'Sales Analysis Q4' # Human-readable name
initNotebookId: 'notebook-001' # Default notebook to open
```

**Editing Tips:**
- ✅ Change `name` to rename your project
- ⚠️ Don't change `id` (breaks references)
- ✅ Set `initNotebookId` to change default notebook

### Notebooks Array

Each project can contain multiple notebooks:

```yaml
project:
notebooks:
- id: 'notebook-001'
name: 'Data Loading'
executionMode: 'block'
isModule: false
workingDirectory: '/work'
blocks: [...]

- id: 'notebook-002'
name: 'Analysis'
executionMode: 'downstream'
isModule: false
blocks: [...]
```

**Key Properties:**
- `id` - Unique notebook identifier
- `name` - Notebook display name
- `executionMode` - `'block'` or `'downstream'`
- `isModule` - Whether notebook is reusable
- `workingDirectory` - Working directory path
- `blocks` - Array of notebook blocks

**Editing Tips:**
- ✅ Rename notebooks by changing `name`
- ✅ Change execution mode
- ✅ Mark notebooks as modules
- ⚠️ Don't change `id` values

### Integrations Array

Connected data sources and services:

```yaml
project:
integrations:
- id: 'integration-001'
name: 'Production Database'
type: 'postgres'

- id: 'integration-002'
name: 'Data Warehouse'
type: 'snowflake'
```

**Integration Types:**
- `postgres`, `mysql`, `mariadb`
- `snowflake`, `bigquery`, `redshift`
- `databricks`, `clickhouse`
- `mongodb`, `elasticsearch`

**Editing Tips:**
- ✅ Add new integrations
- ✅ Rename integrations
- ⚠️ Connection details stored separately (environment variables)

### Settings Object

Project-wide configuration:

```yaml
project:
settings:
environment:
pythonVersion: '3.11'
customImage: 'my-custom-image:latest'

requirements:
- 'pandas>=2.0.0'
- 'numpy>=1.24.0'
- 'scikit-learn>=1.3.0'

sqlCacheMaxAge: 3600 # SQL cache duration in seconds
```

**Editing Tips:**
- ✅ Change Python version
- ✅ Add/remove package requirements
- ✅ Adjust SQL cache settings
- ✅ Specify custom Docker images

## Understanding Blocks

Blocks are the core content of notebooks. Each block has a common structure:

```yaml
blocks:
- id: 'block-001' # Unique block identifier
type: 'code' # Block type
sortingKey: '1' # Position in notebook
blockGroup: 'group-uuid' # Optional grouping
content: | # Block content
import pandas as pd
df = pd.read_csv('data.csv')
executionCount: 1 # Times executed
version: 1 # Block schema version
metadata: # Block-specific settings
deepnote_table_state: {...}
outputs: # Execution outputs
- output_type: 'execute_result'
data: {...}
```

### Block Types

**Executable Blocks:**
- `code` - Python code
- `sql` - SQL queries

**Input Blocks:**
- `input-text` - Single-line text
- `input-textarea` - Multi-line text
- `input-checkbox` - Boolean
- `input-select` - Dropdown
- `input-slider` - Numeric slider
- `input-file` - File selector
- `input-date` - Date picker
- `input-date-range` - Date range

**Display Blocks:**
- `visualization` - Charts
- `big-number` - KPIs
- `button` - Interactive buttons

**Text Blocks:**
- `text-cell-h1`, `text-cell-h2`, `text-cell-h3` - Headings
- `text-cell-p` - Paragraphs
- `text-cell-bullet` - Bullet lists
- `text-cell-todo` - Todo items
- `text-cell-callout` - Callouts

**Media Blocks:**
- `image` - Images
- `separator` - Horizontal rules

### Reading Code Blocks

```yaml
- id: 'block-001'
type: code
sortingKey: '1'
content: |
import pandas as pd

# Load data
df = pd.read_csv('sales_data.csv')

# Basic analysis
print(f"Total rows: {len(df)}")
print(f"Total sales: ${df['amount'].sum():,.2f}")
executionCount: 3
metadata:
deepnote_cell_height: 200
```

**What to Look For:**
- `content` - The actual Python code
- `executionCount` - How many times it's been run
- `metadata.deepnote_cell_height` - Cell display height

### Reading SQL Blocks

```yaml
- id: 'block-002'
type: sql
sortingKey: '2'
content: |
SELECT
customer_id,
SUM(amount) as total_spent,
COUNT(*) as order_count
FROM orders
WHERE order_date >= '2024-01-01'
GROUP BY customer_id
ORDER BY total_spent DESC
LIMIT 100
metadata:
deepnote_variable_name: top_customers
sql_integration_id: postgres-prod
deepnote_return_variable_type: dataframe
```

**What to Look For:**
- `content` - The SQL query
- `deepnote_variable_name` - Python variable name for results
- `sql_integration_id` - Which database to query
- `deepnote_return_variable_type` - Output format

### Reading Input Blocks

```yaml
- id: 'block-003'
type: input-date-range
sortingKey: '3'
content: ''
metadata:
deepnote_variable_name: analysis_period
deepnote_variable_value: past7days
```

**What to Look For:**
- `deepnote_variable_name` - Python variable name
- `deepnote_variable_value` - Current value
- Additional metadata for options, ranges, etc.

### Reading Text Blocks

```yaml
- id: 'block-004'
type: text-cell-h1
sortingKey: '4'
content: 'Q4 Sales Analysis'
metadata:
formattedRanges: []

- id: 'block-005'
type: text-cell-p
sortingKey: '5'
content: 'This notebook analyzes sales trends for Q4 2024.'
metadata: {}
```

**What to Look For:**
- `content` - The text content
- `formattedRanges` - Text formatting (bold, italic, links)

## Block Ordering

Blocks are ordered using the `sortingKey` field with base-36 encoding:

```yaml
blocks:
- id: 'block-001'
sortingKey: '1' # First block

- id: 'block-002'
sortingKey: '2' # Second block

- id: 'block-003'
sortingKey: '1a' # Inserted between 1 and 2

- id: 'block-004'
sortingKey: '3' # Third block
```

**Understanding Sorting Keys:**
- Base-36 encoding: `0-9`, `a-z`
- Lexicographic ordering
- Allows insertion without renumbering
- Example sequence: `1`, `2`, `3`, `4`, `5`, ..., `9`, `a`, `b`, ..., `z`, `10`, `11`

## Reading Block Outputs

Blocks can store their execution outputs:

```yaml
outputs:
- output_type: 'stream'
name: 'stdout'
text: 'Total rows: 1523\n'

- output_type: 'execute_result'
execution_count: 1
data:
text/plain: ' id name value\n0 1 Alice 100\n1 2 Bob 200'
text/html: '<table>...</table>'

- output_type: 'display_data'
data:
image/png: 'iVBORw0KGgoAAAANSUhEUg...'
```

**Output Types:**
- `stream` - Text output (stdout/stderr)
- `execute_result` - Return values
- `display_data` - Rich media (plots, images)
- `error` - Error messages

## Practical Examples

### Example 1: Finding All SQL Queries

Search for all SQL blocks in your notebook:

```bash
# Using grep
grep -A 10 "type: sql" notebook.deepnote

# Using yq (YAML query tool)
yq '.project.notebooks[].blocks[] | select(.type == "sql") | .content' notebook.deepnote
```

### Example 2: Listing All Variables

Find all variables defined in input blocks:

```bash
yq '.project.notebooks[].blocks[] | select(.type | startswith("input-")) | .metadata.deepnote_variable_name' notebook.deepnote
```

### Example 3: Checking Python Version

```bash
yq '.project.settings.environment.pythonVersion' notebook.deepnote
```

### Example 4: Listing Dependencies

```bash
yq '.project.settings.requirements[]' notebook.deepnote
```

### Example 5: Finding Specific Code

Search for code containing specific text:

```bash
yq '.project.notebooks[].blocks[] | select(.type == "code" and (.content | contains("pandas"))) | .content' notebook.deepnote
```

## Editing .deepnote Files

### Safe Edits

These edits are generally safe:

✅ **Change project name:**
```yaml
project:
name: 'New Project Name' # Safe to edit
```

✅ **Change notebook names:**
```yaml
notebooks:
- name: 'New Notebook Name' # Safe to edit
```

✅ **Update block content:**
```yaml
blocks:
- content: | # Safe to edit
# Your updated code here
```

✅ **Modify settings:**
```yaml
settings:
requirements: # Safe to add/remove
- 'pandas>=2.0.0'
- 'new-package>=1.0.0'
```

✅ **Change metadata values:**
```yaml
metadata:
deepnote_variable_name: 'new_name' # Safe to edit
deepnote_variable_value: 'new_value' # Safe to edit
```

### Dangerous Edits

Avoid these edits unless you know what you're doing:

⚠️ **Don't change IDs:**
```yaml
project:
id: 'abc-123' # DON'T CHANGE - breaks references

notebooks:
- id: 'notebook-001' # DON'T CHANGE

blocks:
- id: 'block-001' # DON'T CHANGE
```

⚠️ **Don't break YAML syntax:**
```yaml
# Bad - missing quotes
content: This will break

# Good - proper quoting
content: 'This is safe'
```

⚠️ **Don't modify version:**
```yaml
version: '1.0.0' # DON'T CHANGE - format version
```

⚠️ **Be careful with sorting keys:**
```yaml
sortingKey: '1' # Changing this affects block order
```

## Validating .deepnote Files

### Using Schema Validation

The `@deepnote/blocks` package includes Zod schemas for validation:

```typescript
import { deepnoteFileSchema } from '@deepnote/blocks'

const fileData = // ... load your YAML file
const result = deepnoteFileSchema.safeParse(fileData)

if (result.success) {
console.log('Valid Deepnote file')
} else {
console.error('Validation errors:', result.error)
}
```

### Using YAML Linters

Check YAML syntax:

```bash
# Using yamllint
yamllint notebook.deepnote

# Using yq
yq eval notebook.deepnote > /dev/null
```

### Common Validation Errors

**Missing required fields:**
```yaml
# Error: Missing 'id' field
blocks:
- type: code
content: 'print("hello")'
# Missing: id, sortingKey
```

**Invalid types:**
```yaml
# Error: executionCount should be number
blocks:
- id: 'block-001'
executionCount: 'one' # Should be: 1
```

**Invalid YAML syntax:**
```yaml
# Error: Improper indentation
blocks:
- id: 'block-001'
type: code
content: 'print("hello")' # Wrong indentation
```

## Working with Multiple Notebooks

A single `.deepnote` file can contain multiple notebooks:

```yaml
project:
notebooks:
- id: 'notebook-001'
name: 'Data Loading'
blocks: [...]

- id: 'notebook-002'
name: 'Data Processing'
blocks: [...]

- id: 'notebook-003'
name: 'Visualization'
blocks: [...]
```

**Use Cases:**
- Organize related analyses
- Separate data loading from analysis
- Create reusable modules
- Build data pipelines

## Module Notebooks

Mark notebooks as modules for reuse:

```yaml
notebooks:
- id: 'notebook-utils'
name: 'Utility Functions'
isModule: true # This notebook is a module
blocks:
- type: code
content: |
def clean_data(df):
# Cleaning logic
return df
```

**Using Modules:**
```python
# In another notebook
from utility_functions import clean_data

df = clean_data(raw_df)
```

## Version Control Best Practices

### Git-Friendly Format

The YAML format produces clean diffs:

```diff
blocks:
- id: 'block-001'
type: code
content: |
- print("Hello")
+ print("Hello, World!")
```

### .gitignore Recommendations

```gitignore
# Ignore output files
*.pyc
__pycache__/

# Ignore environment files
.env
.venv/

# Keep .deepnote files
!*.deepnote
```

### Commit Messages

Use descriptive commit messages:

```bash
git commit -m "Add SQL query for customer analysis"
git commit -m "Update data loading notebook with new source"
git commit -m "Fix pandas version in requirements"
```

## Troubleshooting

### File Won't Open

**Problem:** IDE shows errors when opening `.deepnote` file

**Solutions:**
1. Check YAML syntax with `yamllint`
2. Verify file encoding is UTF-8
3. Check for special characters
4. Validate against schema

### Blocks Not Executing

**Problem:** Blocks don't run in VS Code extension

**Solutions:**
1. Check block type is supported
2. Verify Python environment is set up
3. Check for missing dependencies
4. Review block metadata

### Corrupted File

**Problem:** File appears corrupted or unreadable

**Solutions:**
1. Check git history for last working version
2. Validate YAML syntax
3. Compare with backup
4. Use schema validation to identify issues

### Merge Conflicts

**Problem:** Git merge conflicts in `.deepnote` file

**Solutions:**
1. Use YAML-aware merge tools
2. Resolve conflicts in block order carefully
3. Validate file after merge
4. Test execution after resolving

## Advanced Tips

### Using jq/yq for Analysis

Extract specific information:

```bash
# Count blocks by type
yq '.project.notebooks[].blocks[].type' notebook.deepnote | sort | uniq -c

# Find all SQL queries
yq '.project.notebooks[].blocks[] | select(.type == "sql") | .content' notebook.deepnote

# List all variables
yq '.project.notebooks[].blocks[].metadata.deepnote_variable_name' notebook.deepnote | grep -v null

# Get total block count
yq '.project.notebooks[].blocks | length' notebook.deepnote
```

### Programmatic Reading

**Python:**
```python
import yaml

with open('notebook.deepnote', 'r') as f:
data = yaml.safe_load(f)

# Access project name
print(data['project']['name'])

# Iterate through blocks
for notebook in data['project']['notebooks']:
for block in notebook['blocks']:
if block['type'] == 'code':
print(f"Code block: {block['id']}")
```

**Node.js:**
```javascript
const yaml = require('js-yaml')
const fs = require('fs')

const data = yaml.load(fs.readFileSync('notebook.deepnote', 'utf8'))

// Access notebooks
data.project.notebooks.forEach(notebook => {
console.log(`Notebook: ${notebook.name}`)
})
```

### Creating Templates

Create reusable notebook templates:

```yaml
metadata:
createdAt: '2025-01-27T12:00:00Z'

version: '1.0.0'

project:
id: 'template-001'
name: 'Data Analysis Template'

notebooks:
- id: 'notebook-001'
name: 'Analysis'
executionMode: 'block'
blocks:
- id: 'block-001'
type: text-cell-h1
sortingKey: '1'
content: 'Data Analysis'
metadata: {}

- id: 'block-002'
type: code
sortingKey: '2'
content: |
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

# Your analysis here
metadata: {}

settings:
environment:
pythonVersion: '3.11'
requirements:
- 'pandas>=2.0.0'
- 'numpy>=1.24.0'
- 'matplotlib>=3.7.0'
```

## Related Documentation

- [Deepnote Format](./deepnote-format.md) - Complete format specification
- [Supported Code Blocks](./supported-code-blocks.md) - All block types
- [Blocks Package](./blocks-package.md) - Package API reference
- [VS Code Supported Blocks](./vscode-supported-blocks.md) - VS Code extension guide
- [Converting Notebooks](./converting-notebooks.md) - Format conversion

## Resources

- [YAML Specification](https://yaml.org/spec/)
- [VS Code YAML Extension](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml)
- [yq Documentation](https://mikefarah.gitbook.io/yq/)
- [Deepnote GitHub](https://github.com/deepnote/deepnote)

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.

🛠️ Refactor suggestion | 🟠 Major

Apply Prettier formatting to resolve markdown violations.

  1. ~35+ MD031 violations—add blank lines around fenced code blocks throughout
  2. ~3 MD036 violations—convert emphasis to headings if intended as section headers

Run prettier --write docs/oss/reading-deepnote-files.md to auto-fix.

🧰 Tools
🪛 markdownlint-cli2 (0.18.1)

435-435: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


441-441: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


447-447: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


454-454: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


462-462: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


473-473: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


485-485: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


494-494: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


499-499: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


537-537: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


546-546: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


554-554: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


606-606: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


718-718: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


735-735: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)

🤖 Prompt for AI Agents
In docs/oss/reading-deepnote-files.md lines 1-805, the file has many Markdown
lint violations (MD031: missing blank lines around fenced code blocks and MD036:
emphasis used where headings are intended); fix by adding blank lines above and
below every fenced code block and converting emphasized text that functions as
section headings into proper Markdown headings (prefix with #/## as
appropriate), then run Prettier to reformat and normalize spacing — e.g.,
execute: prettier --write docs/oss/reading-deepnote-files.md to apply the fixes
and ensure the file passes the markdown linter.

Comment thread docs/oss/sql-blocks.md
Comment on lines +1 to +631
---
title: SQL Blocks in Deepnote
description: Complete guide to using SQL blocks in Deepnote for database queries, variable assignment, and local execution.
noIndex: false
noContent: false
---

# SQL Blocks in Deepnote

SQL blocks are a powerful feature in Deepnote that allow you to execute SQL queries directly against connected databases and assign the results to Python variables. This makes it easy to combine SQL data retrieval with Python data analysis in the same notebook.

## Overview

SQL blocks provide:

- **Direct database connectivity** - Query databases without writing Python connection code
- **Variable assignment** - Automatically assign query results to Python variables
- **Result caching** - Cache query results for faster re-execution
- **DataFrame output** - Results returned as pandas DataFrames or QueryPreview objects
- **Table state configuration** - Control how results are displayed
- **Jinja2 templating** - Use Python variables in SQL queries (via `deepnote_toolkit`)

## Basic Structure

```yaml
- id: block-001
type: sql
sortingKey: '1'
content: |
SELECT * FROM users
WHERE created_at > '2024-01-01'
LIMIT 100
executionCount: 1
metadata:
deepnote_variable_name: users_df
sql_integration_id: postgres-prod
deepnote_return_variable_type: dataframe
```

## Metadata Fields

### Required Fields

#### `sql_integration_id`

The ID of the database integration to use for the query. This corresponds to an integration defined in the project's integrations array.

```yaml
metadata:
sql_integration_id: snowflake-warehouse
```

**Common integration types:**
- `postgres` - PostgreSQL
- `mysql` - MySQL/MariaDB
- `snowflake` - Snowflake
- `bigquery` - Google BigQuery
- `redshift` - Amazon Redshift
- `databricks` - Databricks SQL
- `clickhouse` - ClickHouse

### Optional Fields

#### `deepnote_variable_name`

The Python variable name to assign the query results to. If not specified, results are displayed but not assigned.

```yaml
metadata:
deepnote_variable_name: customer_data
```

**Variable naming rules:**
- Must be a valid Python identifier
- Will be automatically sanitized (e.g., `user-data` becomes `user_data`)
- Defaults to `input_1`, `input_2`, etc. if invalid

#### `deepnote_return_variable_type`

The type of object to return. Options:

- `'dataframe'` (default) - Returns a pandas DataFrame
- `'query_preview'` - Returns a QueryPreview object with additional metadata

```yaml
metadata:
deepnote_return_variable_type: dataframe
```

**DataFrame vs QueryPreview:**

| Feature | DataFrame | QueryPreview |
|---------|-----------|--------------|
| Type | `pandas.DataFrame` | `deepnote_toolkit.QueryPreview` |
| Use case | Standard data analysis | Query chaining, metadata access |
| Methods | All pandas methods | Pandas methods + `.sql()`, `.preview()` |
| Performance | Standard | Optimized for large results |

#### `deepnote_table_state`

Configuration for how the result table is displayed:

```yaml
metadata:
deepnote_table_state:
sortBy: []
filters: []
pageSize: 50
pageIndex: 0
columnOrder: ['id', 'name', 'email', 'created_at']
hiddenColumnIds: ['internal_id', 'password_hash']
columnDisplayNames: []
conditionalFilters: []
cellFormattingRules: []
wrappedTextColumnIds: []
```

#### `function_export_name`

Name for exporting the query as a reusable function (advanced use case).

```yaml
metadata:
function_export_name: get_active_users
```

#### `is_compiled_sql_query_visible`

Whether to show the compiled SQL query (useful when using Jinja2 templates).

```yaml
metadata:
is_compiled_sql_query_visible: true
```

## Python Code Generation

When a SQL block is converted to Python for local execution, it generates code using the `deepnote_toolkit` library:

### With Variable Assignment

**SQL Block:**
```yaml
- type: sql
content: |
SELECT
customer_id,
SUM(amount) as total_spent,
COUNT(*) as order_count
FROM orders
WHERE order_date >= '2024-01-01'
GROUP BY customer_id
ORDER BY total_spent DESC
LIMIT 100
metadata:
deepnote_variable_name: top_customers
sql_integration_id: postgres-prod
deepnote_return_variable_type: dataframe
```

**Generated Python:**
```python
if '_dntk' in globals():
_dntk.dataframe_utils.configure_dataframe_formatter('{}')
else:
_deepnote_current_table_attrs = '{}'

top_customers = _dntk.execute_sql(
'SELECT \n customer_id,\n SUM(amount) as total_spent,\n COUNT(*) as order_count\nFROM orders\nWHERE order_date >= \'2024-01-01\'\nGROUP BY customer_id\nORDER BY total_spent DESC\nLIMIT 100',
'SQL_POSTGRES_PROD',
audit_sql_comment='',
sql_cache_mode='cache_disabled',
return_variable_type='dataframe'
)
top_customers
```

### Without Variable Assignment

**SQL Block:**
```yaml
- type: sql
content: SELECT COUNT(*) FROM users
metadata:
sql_integration_id: postgres-prod
```

**Generated Python:**
```python
if '_dntk' in globals():
_dntk.dataframe_utils.configure_dataframe_formatter('{}')
else:
_deepnote_current_table_attrs = '{}'

_dntk.execute_sql(
'SELECT COUNT(*) FROM users',
'SQL_POSTGRES_PROD',
audit_sql_comment='',
sql_cache_mode='cache_disabled',
return_variable_type='dataframe'
)
```

## Common Use Cases

### 1. Data Loading

Load data from a database into a DataFrame for analysis:

```yaml
- type: sql
content: |
SELECT *
FROM sales_data
WHERE date >= CURRENT_DATE - INTERVAL '30 days'
metadata:
deepnote_variable_name: recent_sales
sql_integration_id: snowflake-warehouse
```

Then use in a code block:

```python
# Analyze recent sales
print(f"Total sales: ${recent_sales['amount'].sum():,.2f}")
print(f"Average order: ${recent_sales['amount'].mean():.2f}")
print(f"Number of orders: {len(recent_sales)}")
```

### 2. Filtered Queries

Use SQL to filter large datasets before loading into Python:

```yaml
- type: sql
content: |
SELECT
user_id,
email,
subscription_tier,
mrr
FROM customers
WHERE
subscription_tier IN ('premium', 'enterprise')
AND mrr > 1000
AND churn_risk_score < 0.3
metadata:
deepnote_variable_name: high_value_customers
sql_integration_id: postgres-prod
```

### 3. Aggregations

Perform aggregations in SQL for better performance:

```yaml
- type: sql
content: |
SELECT
DATE_TRUNC('month', order_date) as month,
product_category,
COUNT(*) as order_count,
SUM(amount) as total_revenue,
AVG(amount) as avg_order_value
FROM orders
WHERE order_date >= '2023-01-01'
GROUP BY 1, 2
ORDER BY 1 DESC, 3 DESC
metadata:
deepnote_variable_name: monthly_revenue
sql_integration_id: bigquery-analytics
```

### 4. Joins Across Tables

Combine data from multiple tables:

```yaml
- type: sql
content: |
SELECT
u.user_id,
u.email,
u.signup_date,
COUNT(DISTINCT o.order_id) as order_count,
SUM(o.amount) as lifetime_value
FROM users u
LEFT JOIN orders o ON u.user_id = o.user_id
WHERE u.signup_date >= '2024-01-01'
GROUP BY u.user_id, u.email, u.signup_date
HAVING COUNT(DISTINCT o.order_id) > 0
metadata:
deepnote_variable_name: user_ltv
sql_integration_id: postgres-prod
```

### 5. Window Functions

Use SQL window functions for complex analytics:

```yaml
- type: sql
content: |
SELECT
customer_id,
order_date,
amount,
ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY order_date) as order_number,
SUM(amount) OVER (PARTITION BY customer_id ORDER BY order_date) as cumulative_spent,
AVG(amount) OVER (PARTITION BY customer_id) as avg_order_value
FROM orders
WHERE order_date >= '2024-01-01'
metadata:
deepnote_variable_name: customer_orders
sql_integration_id: snowflake-warehouse
```

## Working with Results

### DataFrame Operations

Once assigned to a variable, you can use all pandas operations:

```python
# After SQL block assigns to 'sales_df'

# Filter
high_value = sales_df[sales_df['amount'] > 1000]

# Group by
by_region = sales_df.groupby('region')['amount'].sum()

# Sort
top_products = sales_df.sort_values('revenue', ascending=False).head(10)

# Merge with other data
combined = sales_df.merge(customers_df, on='customer_id')
```

### QueryPreview Operations

When using `deepnote_return_variable_type: 'query_preview'`:

```python
# After SQL block assigns to 'data' as QueryPreview

# Chain additional SQL queries
filtered = data.sql("SELECT * FROM data WHERE amount > 100")

# Preview first rows
data.preview(10)

# Convert to DataFrame
df = data.to_dataframe()

# Access metadata
print(data.row_count)
print(data.column_names)
```

## Integration with Code Blocks

SQL blocks work seamlessly with code blocks:

```yaml
# SQL Block 1: Load user data
- type: sql
content: SELECT * FROM users WHERE active = true
metadata:
deepnote_variable_name: users
sql_integration_id: postgres-prod

# Code Block: Process data
- type: code
content: |
# users DataFrame is available from SQL block
print(f"Active users: {len(users)}")

# Add calculated columns
users['days_since_signup'] = (
pd.Timestamp.now() - pd.to_datetime(users['signup_date'])
).dt.days

# Filter
new_users = users[users['days_since_signup'] < 30]

# SQL Block 2: Load orders for new users
- type: sql
content: |
SELECT *
FROM orders
WHERE user_id IN ({{ new_users['user_id'].tolist() }})
metadata:
deepnote_variable_name: new_user_orders
sql_integration_id: postgres-prod
```

## Environment Variables

SQL integrations are accessed via environment variables. The pattern is:

```
SQL_{INTEGRATION_TYPE}_{INTEGRATION_ID}
```

For example:
- `sql_integration_id: 'postgres-prod'` → `SQL_POSTGRES_PROD`
- `sql_integration_id: 'snowflake-warehouse'` → `SQL_SNOWFLAKE_WAREHOUSE`

The environment variable contains a JSON string with connection details:

```json
{
"host": "db.example.com",
"port": 5432,
"database": "analytics",
"username": "readonly_user",
"password": "***"
}
```

## Local Execution Requirements

To execute SQL blocks locally, you need:

1. **deepnote_toolkit** installed:
```bash
pip install deepnote-toolkit
```

2. **Database drivers** for your database type:
```bash
# PostgreSQL
pip install psycopg2-binary

# MySQL
pip install pymysql

# Snowflake
pip install snowflake-connector-python

# BigQuery
pip install google-cloud-bigquery
```

3. **Environment variables** set with connection details:
```bash
export SQL_POSTGRES_PROD='{"host":"localhost","port":5432,...}'
```

## Best Practices

### 1. Always Assign to Variables

Assign query results to variables for reuse:

```yaml
# Good
metadata:
deepnote_variable_name: customer_data

# Avoid - results are displayed but not reusable
metadata: {}
```

### 2. Use Descriptive Variable Names

Choose clear, descriptive names:

```yaml
# Good
deepnote_variable_name: monthly_revenue_by_region

# Avoid
deepnote_variable_name: df1
```

### 3. Filter in SQL, Not Python

Reduce data transfer by filtering in SQL:

```yaml
# Good - filter 1M rows to 1K in database
content: |
SELECT * FROM large_table
WHERE date >= '2024-01-01'
AND status = 'active'

# Avoid - transfer 1M rows then filter in Python
content: SELECT * FROM large_table
```

### 4. Use Appropriate Return Types

- Use `dataframe` for standard analysis
- Use `query_preview` for query chaining or very large results

```yaml
# For standard analysis
metadata:
deepnote_return_variable_type: dataframe

# For query chaining
metadata:
deepnote_return_variable_type: query_preview
```

### 5. Limit Results During Development

Use `LIMIT` during development, remove for production:

```sql
SELECT *
FROM large_table
WHERE date >= '2024-01-01'
LIMIT 1000 -- Remove this in production
```

### 6. Add Comments

Document complex queries:

```sql
-- Calculate customer lifetime value
-- Includes all orders from the past 12 months
-- Excludes refunded orders
SELECT
customer_id,
SUM(amount) as ltv
FROM orders
WHERE
order_date >= CURRENT_DATE - INTERVAL '12 months'
AND status != 'refunded'
GROUP BY customer_id
```

### 7. Handle NULL Values

Be explicit about NULL handling:

```sql
SELECT
customer_id,
COALESCE(email, 'unknown') as email,
COALESCE(phone, 'N/A') as phone
FROM customers
```

## Troubleshooting

### Connection Errors

If you get connection errors:

1. Check integration ID matches exactly:
```yaml
sql_integration_id: postgres-prod # Must match integration definition
```

2. Verify environment variable is set:
```bash
echo $SQL_POSTGRES_PROD
```

3. Test connection manually:
```python
import os
import json
from sqlalchemy import create_engine

config = json.loads(os.environ['SQL_POSTGRES_PROD'])
engine = create_engine(f"postgresql://{config['username']}:{config['password']}@{config['host']}:{config['port']}/{config['database']}")
```

### Query Errors

If your query fails:

1. Test the query directly in your database client
2. Check for syntax differences between databases
3. Verify table and column names
4. Check permissions for the database user

### Variable Not Found

If a variable isn't available in subsequent blocks:

1. Verify `deepnote_variable_name` is set:
```yaml
metadata:
deepnote_variable_name: my_data # Required
```

2. Check variable name is valid Python identifier
3. Ensure SQL block executed successfully

## TypeScript Interface

For programmatic use:

```typescript
import type { SqlBlock } from '@deepnote/blocks'

interface SqlBlock {
id: string
type: 'sql'
content: string
executionCount?: number
metadata: {
deepnote_variable_name?: string
sql_integration_id?: string
deepnote_return_variable_type?: 'dataframe' | 'query_preview'
deepnote_table_state?: TableState
function_export_name?: string
is_compiled_sql_query_visible?: boolean
}
}
```

## Related Documentation

- [Blocks Package](./blocks-package.md) - Complete package reference
- [Supported Code Blocks](./supported-code-blocks.md) - All block types
- [Deepnote Format](./deepnote-format.md) - File format specification
- [Local Setup](./local-setup.md) - Running notebooks locally

## Resources

- [deepnote-toolkit Documentation](https://github.com/deepnote/deepnote-toolkit)
- [SQL Block Source Code](https://github.com/deepnote/deepnote/blob/main/packages/blocks/src/blocks/sql-blocks.ts)
- [Example SQL Notebooks](https://github.com/deepnote/deepnote/tree/main/examples)

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.

🛠️ Refactor suggestion | 🟠 Major

Apply Prettier formatting; convert emphasis to proper headings.

  1. ~45+ MD031 violations—add blank lines around fenced code blocks
  2. MD036 (emphasis as heading): Lines 389, 401, 415—convert **Connection Errors:** / **Query Errors:** / **Variable Not Found:** to proper headings (e.g., ### Connection Errors)
  3. ~3 MD040 violations—add language specs to fenced code blocks
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)

153-153: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


169-169: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


190-190: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


234-234: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


246-246: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


274-274: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


315-315: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


350-350: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


350-350: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


362-362: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


362-362: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


372-372: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


372-372: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


389-389: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


390-390: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


401-401: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


402-402: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


415-415: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


416-416: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


432-432: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


443-443: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


464-464: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


479-479: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


492-492: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


518-518: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


537-537: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


562-562: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


584-584: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


584-584: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


600-600: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)

🤖 Prompt for AI Agents
In docs/oss/sql-blocks.md (lines 1–631): apply Prettier/markdown formatting to
fix markdownlint issues—add blank lines above and below every fenced code block
to resolve MD031, convert the emphasized lines currently written as bold (e.g.,
"**Connection Errors:**", "**Query Errors:**", "**Variable Not Found:**" around
lines ~389, 401, 415) into proper headings like "### Connection Errors" etc. to
resolve MD036, and add explicit language identifiers to all fenced code blocks
(use yaml, python, bash, sql, json, typescript where appropriate) to resolve
MD040; after making these edits run Prettier or your markdown linter/formatter
to normalize spacing and line breaks.

Comment on lines +1 to +1103
---
title: Supported Code Blocks in Deepnote
description: Complete reference for all code block types supported in Deepnote for local execution, including executable blocks, input blocks, and display blocks.
noIndex: false
noContent: false
---

# Supported Code Blocks in Deepnote

Deepnote supports a rich set of block types that go beyond traditional Jupyter notebooks. This document provides a complete reference for all block types that can be executed locally using the `@deepnote/blocks` package.

## Block Categories

Deepnote blocks are organized into several categories:

1. **[Executable Blocks](#executable-blocks)** - Code and SQL blocks that execute and produce outputs
2. **[Input Blocks](#input-blocks)** - Interactive parameter inputs that generate Python variables
3. **[Display Blocks](#display-blocks)** - Visualization, KPI, and interactive UI elements
4. **[Text Blocks](#text-blocks)** - Rich text content with formatting
5. **[Media Blocks](#media-blocks)** - Images and separators

## Executable Blocks

### Code Block (`code`)

Standard Python code execution block.

**Type:** `'code'`

**Structure:**
```typescript
interface CodeBlock {
id: string
type: 'code'
content: string
executionCount?: number
metadata: {
deepnote_table_state?: TableState
deepnote_cell_height?: number
deepnote_to_be_reexecuted?: boolean
}
}
```

**Example:**
```yaml
- id: block-001
type: code
sortingKey: '1'
content: |
import pandas as pd
import numpy as np

df = pd.DataFrame({
'name': ['Alice', 'Bob', 'Charlie'],
'age': [25, 30, 35],
'city': ['NYC', 'SF', 'LA']
})
df
executionCount: 1
metadata: {}
```

**Generated Python:**
```python
if '_dntk' in globals():
_dntk.dataframe_utils.configure_dataframe_formatter('{}')
else:
_deepnote_current_table_attrs = '{}'

import pandas as pd
import numpy as np

df = pd.DataFrame({
'name': ['Alice', 'Bob', 'Charlie'],
'age': [25, 30, 35],
'city': ['NYC', 'SF', 'LA']
})
df
```

**Table State Configuration:**

Code blocks can include DataFrame display configuration:

```yaml
metadata:
deepnote_table_state:
sortBy: []
filters: []
pageSize: 50
pageIndex: 0
columnOrder: ['name', 'age', 'city']
hiddenColumnIds: []
columnDisplayNames: []
conditionalFilters: []
cellFormattingRules: []
wrappedTextColumnIds: []
```

### SQL Block (`sql`)

Execute SQL queries against connected databases.

**Type:** `'sql'`

**Structure:**
```typescript
interface SqlBlock {
id: string
type: 'sql'
content: string
executionCount?: number
metadata: {
deepnote_variable_name?: string
sql_integration_id?: string
deepnote_return_variable_type?: 'dataframe' | 'query_preview'
deepnote_table_state?: TableState
function_export_name?: string
is_compiled_sql_query_visible?: boolean
}
}
```

**Example:**
```yaml
- id: block-002
type: sql
sortingKey: '2'
content: |
SELECT
customer_id,
SUM(amount) as total_spent,
COUNT(*) as order_count
FROM orders
WHERE order_date >= '2024-01-01'
GROUP BY customer_id
ORDER BY total_spent DESC
LIMIT 100
metadata:
deepnote_variable_name: top_customers
sql_integration_id: snowflake-prod
deepnote_return_variable_type: dataframe
```

**Generated Python:**
```python
if '_dntk' in globals():
_dntk.dataframe_utils.configure_dataframe_formatter('{}')
else:
_deepnote_current_table_attrs = '{}'

top_customers = _dntk.execute_sql(
'SELECT \n customer_id,\n SUM(amount) as total_spent,\n COUNT(*) as order_count\nFROM orders\nWHERE order_date >= \'2024-01-01\'\nGROUP BY customer_id\nORDER BY total_spent DESC\nLIMIT 100',
'SQL_SNOWFLAKE_PROD',
audit_sql_comment='',
sql_cache_mode='cache_disabled',
return_variable_type='dataframe'
)
top_customers
```

**Key Features:**
- Assigns query results to Python variables
- Supports multiple database integrations
- Can return as DataFrame or QueryPreview
- Includes table state for result display configuration

## Input Blocks

Input blocks create interactive parameters that generate Python variable assignments. They're ideal for parameterized notebooks and dashboards.

### Text Input (`input-text`)

Single-line text input.

**Type:** `'input-text'`

**Structure:**
```typescript
interface InputTextBlock {
id: string
type: 'input-text'
content: string
metadata: {
deepnote_variable_name: string
deepnote_variable_value: string
}
}
```

**Example:**
```yaml
- id: block-003
type: input-text
sortingKey: '3'
content: ''
metadata:
deepnote_variable_name: api_key
deepnote_variable_value: sk-1234567890abcdef
```

**Generated Python:**
```python
api_key = 'sk-1234567890abcdef'
```

### Textarea Input (`input-textarea`)

Multi-line text input.

**Type:** `'input-textarea'`

**Structure:**
```typescript
interface InputTextareaBlock {
id: string
type: 'input-textarea'
content: string
metadata: {
deepnote_variable_name: string
deepnote_variable_value: string
}
}
```

**Example:**
```yaml
- id: block-004
type: input-textarea
sortingKey: '4'
content: ''
metadata:
deepnote_variable_name: sql_query
deepnote_variable_value: |
SELECT * FROM users
WHERE created_at > '2024-01-01'
LIMIT 1000
```

**Generated Python:**
```python
sql_query = 'SELECT * FROM users\nWHERE created_at > \'2024-01-01\'\nLIMIT 1000'
```

### Checkbox Input (`input-checkbox`)

Boolean checkbox input.

**Type:** `'input-checkbox'`

**Structure:**
```typescript
interface InputCheckboxBlock {
id: string
type: 'input-checkbox'
content: string
metadata: {
deepnote_variable_name: string
deepnote_variable_value: boolean
}
}
```

**Example:**
```yaml
- id: block-005
type: input-checkbox
sortingKey: '5'
content: ''
metadata:
deepnote_variable_name: include_test_data
deepnote_variable_value: false
```

**Generated Python:**
```python
include_test_data = False
```

### Select Input (`input-select`)

Dropdown selection (single or multiple).

**Type:** `'input-select'`

**Structure:**
```typescript
interface InputSelectBlock {
id: string
type: 'input-select'
content: string
metadata: {
deepnote_variable_name: string
deepnote_variable_value: string | string[]
deepnote_variable_options?: string[]
deepnote_variable_custom_options?: string[]
deepnote_variable_selected_variable?: string
deepnote_variable_select_type?: 'from_options' | 'from_variable'
deepnote_allow_multiple_values?: boolean
}
}
```

**Single Select Example:**
```yaml
- id: block-006
type: input-select
sortingKey: '6'
content: ''
metadata:
deepnote_variable_name: environment
deepnote_variable_value: production
deepnote_variable_options:
- development
- staging
- production
deepnote_allow_multiple_values: false
```

**Generated Python:**
```python
environment = 'production'
```

**Multi-Select Example:**
```yaml
- id: block-007
type: input-select
sortingKey: '7'
content: ''
metadata:
deepnote_variable_name: selected_regions
deepnote_variable_value:
- us-east-1
- eu-west-1
deepnote_variable_options:
- us-east-1
- us-west-2
- eu-west-1
- ap-southeast-1
deepnote_allow_multiple_values: true
```

**Generated Python:**
```python
selected_regions = ['us-east-1', 'eu-west-1']
```

### Slider Input (`input-slider`)

Numeric slider input.

**Type:** `'input-slider'`

**Structure:**
```typescript
interface InputSliderBlock {
id: string
type: 'input-slider'
content: string
metadata: {
deepnote_variable_name: string
deepnote_variable_value: string // Numeric string
deepnote_slider_min_value?: number
deepnote_slider_max_value?: number
deepnote_slider_step?: number
}
}
```

**Example:**
```yaml
- id: block-008
type: input-slider
sortingKey: '8'
content: ''
metadata:
deepnote_variable_name: confidence_threshold
deepnote_variable_value: '0.85'
deepnote_slider_min_value: 0
deepnote_slider_max_value: 1
deepnote_slider_step: 0.05
```

**Generated Python:**
```python
confidence_threshold = 0.85
```

### File Input (`input-file`)

File path selector.

**Type:** `'input-file'`

**Structure:**
```typescript
interface InputFileBlock {
id: string
type: 'input-file'
content: string
metadata: {
deepnote_variable_name: string
deepnote_variable_value: string // File path
}
}
```

**Example:**
```yaml
- id: block-009
type: input-file
sortingKey: '9'
content: ''
metadata:
deepnote_variable_name: data_file
deepnote_variable_value: /work/data/sales_2024.csv
```

**Generated Python:**
```python
data_file = '/work/data/sales_2024.csv'
```

**Empty Value Example:**
```yaml
metadata:
deepnote_variable_name: optional_file
deepnote_variable_value: ''
```

**Generated Python:**
```python
optional_file = None
```

### Date Input (`input-date`)

Single date picker.

**Type:** `'input-date'`

**Structure:**
```typescript
interface InputDateBlock {
id: string
type: 'input-date'
content: string
metadata: {
deepnote_variable_name: string
deepnote_variable_value: string // ISO date string
deepnote_input_date_version?: number
}
}
```

**Example (Version 2):**
```yaml
- id: block-010
type: input-date
sortingKey: '10'
content: ''
metadata:
deepnote_variable_name: report_date
deepnote_variable_value: '2024-01-27'
deepnote_input_date_version: 2
```

**Generated Python:**
```python
from dateutil.parser import parse as _deepnote_parse
report_date = _deepnote_parse('2024-01-27').date()
```

**Example (Version 1):**
```yaml
metadata:
deepnote_variable_name: timestamp
deepnote_variable_value: '2024-01-27T12:00:00.000Z'
```

**Generated Python:**
```python
from datetime import datetime as _deepnote_datetime
timestamp = _deepnote_datetime.strptime('2024-01-27T12:00:00.000Z', "%Y-%m-%dT%H:%M:%S.%fZ")
```

### Date Range Input (`input-date-range`)

Date range picker with relative and absolute ranges.

**Type:** `'input-date-range'`

**Structure:**
```typescript
interface InputDateRangeBlock {
id: string
type: 'input-date-range'
content: string
metadata: {
deepnote_variable_name: string
deepnote_variable_value: DateRangeInputValue
}
}

type DateRangeInputValue =
| string // ISO date
| [string, string] // Absolute range
| 'past7days' | 'past14days' | 'pastMonth' | 'past3months' | 'past6months' | 'pastYear'
| `customDays${number}`
```

**Relative Range Example:**
```yaml
- id: block-011
type: input-date-range
sortingKey: '11'
content: ''
metadata:
deepnote_variable_name: analysis_period
deepnote_variable_value: past7days
```

**Generated Python:**
```python
from datetime import datetime as _deepnote_datetime, timedelta as _deepnote_timedelta
analysis_period = [
_deepnote_datetime.now().date() - _deepnote_timedelta(days=7),
_deepnote_datetime.now().date()
]
```

**Absolute Range Example:**
```yaml
metadata:
deepnote_variable_name: fiscal_year
deepnote_variable_value:
- '2024-01-01'
- '2024-12-31'
```

**Generated Python:**
```python
from dateutil.parser import parse as _deepnote_parse
fiscal_year = [
_deepnote_parse('2024-01-01').date() if '2024-01-01' else None,
_deepnote_parse('2024-12-31').date() if '2024-12-31' else None
]
```

**Custom Days Example:**
```yaml
metadata:
deepnote_variable_name: last_45_days
deepnote_variable_value: customDays45
```

**Generated Python:**
```python
from datetime import datetime as _deepnote_datetime, timedelta as _deepnote_timedelta
last_45_days = [
_deepnote_datetime.now().date() - _deepnote_timedelta(days=45),
_deepnote_datetime.now().date()
]
```

**Supported Relative Ranges:**
- `'past7days'` - Last 7 days
- `'past14days'` - Last 14 days
- `'pastMonth'` - Last 30 days
- `'past3months'` - Last 90 days
- `'past6months'` - Last 180 days
- `'pastYear'` - Last 365 days
- `'customDaysN'` - Last N days (e.g., `'customDays45'`)

## Display Blocks

### Visualization Block (`visualization`)

Interactive charts using Vega-Lite specifications.

**Type:** `'visualization'`

**Structure:**
```typescript
interface VisualizationBlock {
id: string
type: 'visualization'
content: string
metadata: {
deepnote_variable_name?: string
deepnote_chart_spec?: VegaLiteSpec
}
}
```

**Example:**
```yaml
- id: block-012
type: visualization
sortingKey: '12'
content: ''
metadata:
deepnote_variable_name: sales_chart
deepnote_chart_spec:
$schema: https://vega.github.io/schema/vega-lite/v5.json
data:
name: sales_df
mark: bar
encoding:
x:
field: month
type: ordinal
title: Month
y:
field: revenue
type: quantitative
title: Revenue ($)
width: 600
height: 400
```

**Generated Python:**
```python
from deepnote_toolkit import chart
sales_chart = chart(sales_df, {
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {"name": "sales_df"},
"mark": "bar",
"encoding": {
"x": {"field": "month", "type": "ordinal", "title": "Month"},
"y": {"field": "revenue", "type": "quantitative", "title": "Revenue ($)"}
},
"width": 600,
"height": 400
})
```

### Big Number Block (`big-number`)

Display KPIs with Jinja2 templates.

**Type:** `'big-number'`

**Structure:**
```typescript
interface BigNumberBlock {
id: string
type: 'big-number'
content: string
metadata: {
deepnote_variable_name?: string
deepnote_big_number_template?: string
deepnote_big_number_value_source?: string
}
}
```

**Example:**
```yaml
- id: block-013
type: big-number
sortingKey: '13'
content: ''
metadata:
deepnote_variable_name: total_revenue
deepnote_big_number_template: '{{ value | currency }}'
deepnote_big_number_value_source: df["revenue"].sum()
```

**Generated Python:**
```python
from deepnote_toolkit import big_number
total_revenue = big_number(
df["revenue"].sum(),
template='{{ value | currency }}'
)
```

### Button Block (`button`)

Interactive button with variable control.

**Type:** `'button'`

**Structure:**
```typescript
interface ButtonBlock {
id: string
type: 'button'
content: string // Button label
metadata: {
deepnote_button_variable_name?: string
deepnote_button_variable_value?: string
}
}
```

**Example:**
```yaml
- id: block-014
type: button
sortingKey: '14'
content: Refresh Data
metadata:
deepnote_button_variable_name: refresh_trigger
deepnote_button_variable_value: timestamp
```

**Generated Python (requires execution context):**
```python
refresh_trigger = '2024-01-27T12:00:00Z'
```

## Text Blocks

Text blocks support rich formatting and are converted to markdown for local execution.

### Heading Blocks

**Types:** `'text-cell-h1'`, `'text-cell-h2'`, `'text-cell-h3'`

**Example:**
```yaml
- id: block-015
type: text-cell-h1
sortingKey: '15'
content: Data Analysis Report
metadata:
formattedRanges: []

- id: block-016
type: text-cell-h2
sortingKey: '16'
content: Executive Summary
metadata: {}

- id: block-017
type: text-cell-h3
sortingKey: '17'
content: Key Findings
metadata: {}
```

**Markdown Output:**
```markdown
# Data Analysis Report

## Executive Summary

### Key Findings
```

### Paragraph Block (`text-cell-p`)

**Type:** `'text-cell-p'`

**Example:**
```yaml
- id: block-018
type: text-cell-p
sortingKey: '18'
content: This analysis examines sales trends across Q4 2024.
metadata: {}
```

**Markdown Output:**
```markdown
This analysis examines sales trends across Q4 2024.
```

### Bullet List Block (`text-cell-bullet`)

**Type:** `'text-cell-bullet'`

**Example:**
```yaml
- id: block-019
type: text-cell-bullet
sortingKey: '19'
content: Revenue increased by 25%
metadata: {}

- id: block-020
type: text-cell-bullet
sortingKey: '20'
content: Customer acquisition cost decreased
metadata: {}
```

**Markdown Output:**
```markdown
- Revenue increased by 25%
- Customer acquisition cost decreased
```

### Todo Block (`text-cell-todo`)

**Type:** `'text-cell-todo'`

**Example:**
```yaml
- id: block-021
type: text-cell-todo
sortingKey: '21'
content: Review Q1 projections
metadata:
checked: false

- id: block-022
type: text-cell-todo
sortingKey: '22'
content: Update dashboard
metadata:
checked: true
```

**Markdown Output:**
```markdown
- [ ] Review Q1 projections
- [x] Update dashboard
```

### Callout Block (`text-cell-callout`)

**Type:** `'text-cell-callout'`

**Example:**
```yaml
- id: block-023
type: text-cell-callout
sortingKey: '23'
content: Important note about data quality
metadata:
color: blue
```

**Markdown Output:**
```markdown
> Important note about data quality
```

**Supported Colors:** `'blue'`, `'green'`, `'yellow'`, `'red'`, `'purple'`

### Text Formatting

Text blocks support rich formatting through `formattedRanges`:

```yaml
metadata:
formattedRanges:
- type: marks
fromCodePoint: 0
toCodePoint: 4
marks:
bold: true
- type: marks
fromCodePoint: 5
toCodePoint: 11
marks:
italic: true
color: '#FF0000'
- type: link
fromCodePoint: 12
toCodePoint: 16
url: https://example.com
ranges:
- type: marks
fromCodePoint: 0
toCodePoint: 4
marks:
underline: true
```

**Supported Marks:**
- `bold` - Bold text
- `italic` - Italic text
- `underline` - Underlined text
- `strike` - Strikethrough text
- `code` - Inline code
- `color` - Text color (CSS color value)

## Media Blocks

### Image Block (`image`)

**Type:** `'image'`

**Structure:**
```typescript
interface ImageBlock {
id: string
type: 'image'
content: ''
metadata: {
deepnote_img_src?: string
deepnote_img_width?: string
deepnote_img_alignment?: 'left' | 'center' | 'right'
}
}
```

**Example:**
```yaml
- id: block-024
type: image
sortingKey: '24'
content: ''
metadata:
deepnote_img_src: https://example.com/chart.png
deepnote_img_width: '600'
deepnote_img_alignment: center
```

**Markdown Output:**
```markdown
<img src="https://example.com/chart.png" width="600" align="center" />
```

### Separator Block (`separator`)

**Type:** `'separator'`

**Example:**
```yaml
- id: block-025
type: separator
sortingKey: '25'
content: ''
metadata: {}
```

**Markdown Output:**
```markdown
<hr>
```

## Block Execution Order

Blocks are ordered using the `sortingKey` field, which uses base-36 encoding:

```yaml
blocks:
- id: block-001
sortingKey: '1' # First block
- id: block-002
sortingKey: '2' # Second block
- id: block-003
sortingKey: '1a' # Inserted between 1 and 2
- id: block-004
sortingKey: '3' # Third block
```

## Execution Modes

Deepnote notebooks support two execution modes:

### Block Mode (`executionMode: 'block'`)

Blocks execute independently. Each block can be run individually without affecting others.

```yaml
notebooks:
- id: notebook-001
name: Analysis
executionMode: block
blocks: [...]
```

### Downstream Mode (`executionMode: 'downstream'`)

When a block is executed, all dependent blocks automatically re-execute.

```yaml
notebooks:
- id: notebook-002
name: Pipeline
executionMode: downstream
blocks: [...]
```

## Module Notebooks

Notebooks can be marked as modules for reuse across projects:

```yaml
notebooks:
- id: notebook-003
name: Data Utils
isModule: true
executionMode: block
blocks: [...]
```

Module notebooks can be imported in other notebooks:

```python
from data_utils import clean_dataframe, validate_schema
```

## Working Directory

Each notebook can specify a working directory:

```yaml
notebooks:
- id: notebook-004
name: Analysis
workingDirectory: /work/analysis
blocks: [...]
```

Default working directory is `/work`.

## Best Practices

### Variable Naming

Always use valid Python identifiers for variable names:

```yaml
# Good
metadata:
deepnote_variable_name: user_count

# Bad (will be sanitized)
metadata:
deepnote_variable_name: user-count # Becomes user_count
```

### Input Block Organization

Group related input blocks at the top of notebooks:

```yaml
blocks:
# Input parameters
- type: input-date-range
# ...
- type: input-select
# ...
- type: input-checkbox
# ...

# Data loading
- type: code
# ...

# Analysis
- type: sql
# ...
```

### SQL Block Variables

Always assign SQL results to variables for reuse:

```yaml
- type: sql
content: SELECT * FROM users
metadata:
deepnote_variable_name: users_df # Required for reuse
```

### Error Handling

Wrap block execution in try-catch when processing programmatically:

```typescript
import { createPythonCode, UnsupportedBlockTypeError } from '@deepnote/blocks'

try {
const pythonCode = createPythonCode(block)
} catch (error) {
if (error instanceof UnsupportedBlockTypeError) {
console.warn(`Skipping unsupported block type: ${block.type}`)
}
}
```

## Unsupported Block Types

The following block types are not yet supported for local Python code generation:

- Custom app blocks
- Third-party integrations
- Proprietary visualization types

These blocks will throw an `UnsupportedBlockTypeError` when passed to `createPythonCode()`.

## Related Documentation

- [Blocks Package](./blocks-package.md) - Package API reference
- [Deepnote Format](./deepnote-format.md) - File format specification
- [Converting Notebooks](./converting-notebooks.md) - Jupyter ↔ Deepnote conversion
- [Local Setup](./local-setup.md) - Running Deepnote notebooks locally

## Resources

- [GitHub Repository](https://github.com/deepnote/deepnote)
- [Block Types Source](https://github.com/deepnote/deepnote/tree/main/packages/blocks/src/blocks)
- [Example Notebooks](https://github.com/deepnote/deepnote/tree/main/examples)

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.

🛠️ Refactor suggestion | 🟠 Major

Apply Prettier formatting; ignore gitleaks false positive.

  1. ~100+ MD031 violations—extensive blank line issues around fenced code blocks
  2. ~7 MD036 violations—convert emphasis to headings (e.g., line 895: **Button Blocks** → ### Button Blocks)
  3. ~20+ MD040 violations—add language specs to code fences

Gitleaks finding (line 205): False positive. The string sk-1234567890abcdef is a documented example, not a real API key. No action needed.

Use prettier --write docs/oss/supported-code-blocks.md to auto-fix most issues.

🧰 Tools
🪛 Gitleaks (8.28.0)

[high] 205-205: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🪛 markdownlint-cli2 (0.18.1)

31-31: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


46-46: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


65-65: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


108-108: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


126-126: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


147-147: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


180-180: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


193-193: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


204-204: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


215-215: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


228-228: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


242-242: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


253-253: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


266-266: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


277-277: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


288-288: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


306-306: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


322-322: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


327-327: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


346-346: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


357-357: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


373-373: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


387-387: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


398-398: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


411-411: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


422-422: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


427-427: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


434-434: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


445-445: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


459-459: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


471-471: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


477-477: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


484-484: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


496-496: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


515-515: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


526-526: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


535-535: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


544-544: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


553-553: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


560-560: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


586-586: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


599-599: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


625-625: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


647-647: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


661-661: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


673-673: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


688-688: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


701-701: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


712-712: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


725-725: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


747-747: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


760-760: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


769-769: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


778-778: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


793-793: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


803-803: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


820-820: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


830-830: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


840-840: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


891-891: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


905-905: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


917-917: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


926-926: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


935-935: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)

Comment on lines +1 to +849
---
title: Deepnote VS Code Extension
description: Complete guide to the official Deepnote VS Code extension for working with Deepnote notebooks locally in Visual Studio Code.
noIndex: false
noContent: false
---

# Deepnote VS Code Extension

The official Deepnote VS Code extension brings the power of Deepnote notebooks to your local development environment. Work with `.deepnote` files directly in VS Code with full support for execution, debugging, and collaboration.

## Overview

The Deepnote extension for VS Code provides:

- **Native `.deepnote` file support** - Open and edit Deepnote notebooks
- **Block execution** - Run code, SQL, and other executable blocks
- **Rich outputs** - Display DataFrames, plots, and visualizations
- **IntelliSense** - Code completion and suggestions
- **Debugging** - Set breakpoints and debug code blocks
- **Git integration** - Version control for notebooks
- **Local execution** - Use your own Python environment

<!-- IMAGE: Screenshot of Deepnote extension in VS Code marketplace -->
<!-- FILE: vscode-extension-marketplace.png -->
<!-- CAPTION: Deepnote extension in VS Code marketplace -->

## Installation

### From VS Code Marketplace

1. **Open VS Code**
- Launch Visual Studio Code

2. **Open Extensions View**
- Click Extensions icon in sidebar (Ctrl/Cmd + Shift + X)
- Or go to View → Extensions

<!-- IMAGE: Screenshot of VS Code Extensions sidebar -->
<!-- FILE: vscode-extensions-sidebar.png -->
<!-- CAPTION: VS Code Extensions view -->

3. **Search for Deepnote**
- Type "Deepnote" in the search box
- Find "Deepnote" by Deepnote

<!-- IMAGE: Screenshot of Deepnote extension search results -->
<!-- FILE: deepnote-extension-search.png -->
<!-- CAPTION: Searching for Deepnote extension -->

4. **Install**
- Click "Install" button
- Wait for installation to complete
- Reload VS Code if prompted

<!-- IMAGE: Screenshot showing installed Deepnote extension -->
<!-- FILE: deepnote-extension-installed.png -->
<!-- CAPTION: Successfully installed Deepnote extension -->

### From Command Line

```bash
# Install using VS Code CLI
code --install-extension deepnote.deepnote
```

### Verify Installation

1. Open Command Palette (Ctrl/Cmd + Shift + P)
2. Type "Deepnote"
3. You should see Deepnote-related commands

<!-- IMAGE: Screenshot of Command Palette showing Deepnote commands -->
<!-- FILE: deepnote-commands-palette.png -->
<!-- CAPTION: Deepnote commands in Command Palette -->

## Features

### 1. Native .deepnote File Support

**File Association:**
- `.deepnote` files automatically open in notebook interface
- YAML syntax highlighting for raw view
- Structured notebook view for editing

**View Modes:**
- **Notebook View** - Interactive editing and execution
- **Source View** - Raw YAML editing
- **Split View** - Both views side-by-side

<!-- IMAGE: Screenshot showing notebook view vs source view -->
<!-- FILE: notebook-vs-source-view.png -->
<!-- CAPTION: Notebook view and source view comparison -->

### 2. Block Execution

**Supported Block Types:**
- ✅ Code blocks (Python)
- ✅ SQL blocks (with database connections)
- ✅ Input blocks (all types)
- ✅ Markdown blocks (rendered)

**Execution Controls:**
- Run single block: Click play button or Shift + Enter
- Run all blocks: Ctrl/Cmd + Shift + Enter
- Run above: Execute all blocks above current
- Run below: Execute all blocks below current
- Clear outputs: Remove all execution results

<!-- IMAGE: Screenshot showing block execution controls -->
<!-- FILE: block-execution-controls.png -->
<!-- CAPTION: Block execution controls and shortcuts -->

### 3. Rich Output Display

**Supported Output Types:**
- Text output (stdout/stderr)
- DataFrames (interactive tables)
- Plots (matplotlib, seaborn, plotly)
- Images (PNG, JPEG, SVG)
- HTML content
- JSON/dict pretty-printing
- Error tracebacks

<!-- IMAGE: Screenshot showing various output types -->
<!-- FILE: rich-output-display.png -->
<!-- CAPTION: Different output types in VS Code -->

### 4. IntelliSense and Code Completion

**Features:**
- Auto-completion for Python code
- Function signatures and documentation
- Import suggestions
- Variable inspection
- Type hints

**Trigger IntelliSense:**
- Type and pause (auto-trigger)
- Ctrl/Cmd + Space (manual trigger)

<!-- IMAGE: Screenshot of IntelliSense in action -->
<!-- FILE: intellisense-completion.png -->
<!-- CAPTION: IntelliSense code completion -->

### 5. Debugging Support

**Debug Features:**
- Set breakpoints in code blocks
- Step through execution
- Inspect variables
- Evaluate expressions
- View call stack

**Start Debugging:**
1. Set breakpoint (click left margin)
2. Click "Debug Cell" button
3. Use debug controls to step through

<!-- IMAGE: Screenshot of debugging interface with breakpoints -->
<!-- FILE: debugging-interface.png -->
<!-- CAPTION: Debugging a code block in VS Code -->

### 6. Variable Explorer

**View Variables:**
- See all variables in current scope
- Inspect values and types
- View DataFrame shapes
- Expand nested structures

**Access Variable Explorer:**
- Click "Variables" in notebook toolbar
- Or use Command Palette: "Deepnote: Show Variables"

<!-- IMAGE: Screenshot of Variable Explorer panel -->
<!-- FILE: variable-explorer.png -->
<!-- CAPTION: Variable Explorer showing notebook variables -->

### 7. SQL Block Support

**Features:**
- Syntax highlighting for SQL
- Execute queries against databases
- Display results as DataFrames
- Variable assignment
- Connection management

**Requirements:**
- Database drivers installed
- Connection details in environment variables

<!-- IMAGE: Screenshot of SQL block execution -->
<!-- FILE: sql-block-execution.png -->
<!-- CAPTION: Executing SQL block in VS Code -->

### 8. Input Blocks

**Interactive Inputs:**
- Text inputs
- Checkboxes
- Dropdowns
- Sliders
- Date pickers
- File selectors

**Usage:**
- Change input values in UI
- Re-run dependent blocks
- Values saved to notebook

<!-- IMAGE: Screenshot showing various input block types -->
<!-- FILE: input-blocks-vscode.png -->
<!-- CAPTION: Interactive input blocks in VS Code -->

## Configuration

### Extension Settings

Access settings via:
- File → Preferences → Settings (Ctrl/Cmd + ,)
- Search for "Deepnote"

**Available Settings:**

```json
{
// Python interpreter path
"deepnote.pythonPath": "/usr/local/bin/python3",

// Auto-save notebooks
"deepnote.autoSave": true,

// Auto-save delay (ms)
"deepnote.autoSaveDelay": 1000,

// Show line numbers
"deepnote.showLineNumbers": true,

// Enable IntelliSense
"deepnote.intelliSense": true,

// Max output lines
"deepnote.maxOutputLines": 1000,

// Enable SQL syntax highlighting
"deepnote.sqlSyntaxHighlighting": true,

// Default execution mode
"deepnote.executionMode": "block",

// Show execution time
"deepnote.showExecutionTime": true,

// Enable debugging
"deepnote.enableDebugging": true
}
```

<!-- IMAGE: Screenshot of Deepnote extension settings -->
<!-- FILE: extension-settings.png -->
<!-- CAPTION: Deepnote extension settings in VS Code -->

### Python Environment

**Select Python Interpreter:**

1. Open Command Palette (Ctrl/Cmd + Shift + P)
2. Type "Python: Select Interpreter"
3. Choose your Python environment

**Recommended Setup:**
```bash
# Create virtual environment
python -m venv .venv

# Activate it
source .venv/bin/activate # macOS/Linux
.venv\Scripts\activate # Windows

# Install dependencies
pip install deepnote-toolkit pandas numpy
```

<!-- IMAGE: Screenshot of Python interpreter selection -->
<!-- FILE: python-interpreter-selection.png -->
<!-- CAPTION: Selecting Python interpreter -->

### Database Connections

**Set Environment Variables:**

Create `.env` file in project root:
```bash
# PostgreSQL
SQL_POSTGRES_PROD={"host":"localhost","port":5432,"database":"mydb","username":"user","password":"pass"}

# Snowflake
SQL_SNOWFLAKE_WAREHOUSE={"account":"xy12345","user":"analyst","password":"pass","warehouse":"COMPUTE_WH"}

# MySQL
SQL_MYSQL_DEV={"host":"localhost","port":3306,"database":"testdb","username":"root","password":"pass"}
```

**Load in Notebook:**
```python
# First block - load environment variables
from dotenv import load_dotenv
load_dotenv()
```

## Keyboard Shortcuts

### Execution Shortcuts

| Action | Windows/Linux | macOS |
|--------|--------------|-------|
| Run cell | Shift + Enter | Shift + Return |
| Run cell and insert below | Alt + Enter | Option + Return |
| Run all cells | Ctrl + Shift + Enter | Cmd + Shift + Return |
| Run above | Ctrl + Shift + Up | Cmd + Shift + Up |
| Run below | Ctrl + Shift + Down | Cmd + Shift + Down |

### Navigation Shortcuts

| Action | Windows/Linux | macOS |
|--------|--------------|-------|
| Next cell | Down | Down |
| Previous cell | Up | Up |
| Insert cell above | Ctrl + Shift + A | Cmd + Shift + A |
| Insert cell below | Ctrl + Shift + B | Cmd + Shift + B |
| Delete cell | Ctrl + Shift + D | Cmd + Shift + D |

### Editing Shortcuts

| Action | Windows/Linux | macOS |
|--------|--------------|-------|
| Toggle line comment | Ctrl + / | Cmd + / |
| Toggle block comment | Ctrl + Shift + / | Cmd + Shift + / |
| Format cell | Shift + Alt + F | Shift + Option + F |
| Trigger IntelliSense | Ctrl + Space | Cmd + Space |

### View Shortcuts

| Action | Windows/Linux | macOS |
|--------|--------------|-------|
| Toggle source view | Ctrl + K V | Cmd + K V |
| Show variables | Ctrl + Shift + V | Cmd + Shift + V |
| Command Palette | Ctrl + Shift + P | Cmd + Shift + P |

<!-- IMAGE: Screenshot showing keyboard shortcuts overlay -->
<!-- FILE: keyboard-shortcuts.png -->
<!-- CAPTION: Keyboard shortcuts reference -->

## Working with Blocks

### Creating Blocks

**Add Code Block:**
1. Click "+" button between blocks
2. Select "Code" from dropdown
3. Start typing Python code

**Add SQL Block:**
1. Click "+" button
2. Select "SQL"
3. Write SQL query
4. Configure integration

**Add Markdown Block:**
1. Click "+" button
2. Select "Markdown"
3. Write markdown content

<!-- IMAGE: Screenshot of block type selector -->
<!-- FILE: block-type-selector.png -->
<!-- CAPTION: Selecting block type when creating new block -->

### Editing Blocks

**Code Editing:**
- Full Python syntax highlighting
- Auto-indentation
- Bracket matching
- Multi-cursor editing

**Block Metadata:**
- Right-click block → "Edit Metadata"
- Configure block-specific settings
- Set execution order

### Moving Blocks

**Reorder Blocks:**
- Drag and drop blocks
- Or use move up/down buttons
- Sorting keys update automatically

### Deleting Blocks

**Remove Block:**
- Click delete icon
- Or use Ctrl/Cmd + Shift + D
- Confirm deletion

## Output Management

### Viewing Outputs

**Output Panel:**
- Appears below each executed block
- Scrollable for long outputs
- Collapsible to save space

**Output Types:**
- Text: Plain text output
- Tables: Interactive DataFrames
- Plots: Rendered visualizations
- Errors: Formatted tracebacks

<!-- IMAGE: Screenshot showing different output panels -->
<!-- FILE: output-panels.png -->
<!-- CAPTION: Various output types displayed -->

### Clearing Outputs

**Clear Single Output:**
- Click "Clear Output" button on block
- Or right-click → "Clear Output"

**Clear All Outputs:**
- Command Palette → "Deepnote: Clear All Outputs"
- Or click "Clear All" in toolbar

### Exporting Outputs

**Export Options:**
- Copy output as text
- Save DataFrame as CSV
- Export plot as image
- Download HTML output

## Debugging

### Setting Breakpoints

1. **Add Breakpoint:**
- Click left margin next to line number
- Red dot appears

2. **Conditional Breakpoint:**
- Right-click margin → "Add Conditional Breakpoint"
- Enter condition (e.g., `x > 10`)

<!-- IMAGE: Screenshot showing breakpoint in code -->
<!-- FILE: breakpoint-example.png -->
<!-- CAPTION: Setting a breakpoint in a code block -->

### Debug Controls

**Start Debugging:**
- Click "Debug Cell" button
- Or F5 to start debugging

**Debug Actions:**
- Continue (F5)
- Step Over (F10)
- Step Into (F11)
- Step Out (Shift + F11)
- Stop (Shift + F5)

**Debug Panel:**
- Variables view
- Watch expressions
- Call stack
- Breakpoints list

<!-- IMAGE: Screenshot of debug panel with variables -->
<!-- FILE: debug-panel.png -->
<!-- CAPTION: Debug panel showing variables and call stack -->

### Inspecting Variables

**During Debugging:**
- Hover over variables to see values
- Add to watch list
- Evaluate expressions in debug console

## Git Integration

### Version Control

**Initialize Git:**
```bash
git init
git add *.deepnote
git commit -m "Initial commit"
```

**Track Changes:**
- VS Code shows modified files
- View diffs in source control panel
- Commit changes with messages

<!-- IMAGE: Screenshot of Git integration in VS Code -->
<!-- FILE: git-integration.png -->
<!-- CAPTION: Git source control panel -->

### Viewing Diffs

**Compare Changes:**
- Click file in source control panel
- View side-by-side diff
- YAML format shows clean diffs

**Merge Conflicts:**
- VS Code highlights conflicts
- Resolve using merge editor
- Validate YAML syntax after merge

### Branches and Collaboration

**Create Branch:**
```bash
git checkout -b feature/new-analysis
```

**Push to Remote:**
```bash
git push origin feature/new-analysis
```

## Performance Tips

### Optimize Execution

**1. Use Virtual Environments:**
```bash
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
```

**2. Limit Output Size:**
```python
# Limit DataFrame display
pd.set_option('display.max_rows', 100)

# Limit plot size
plt.figure(figsize=(8, 6))
```

**3. Cache Results:**
```python
# Cache expensive computations
import functools

@functools.lru_cache(maxsize=128)
def expensive_function(x):
# ... computation
return result
```

### Memory Management

**Monitor Memory:**
```python
import psutil
import os

process = psutil.Process(os.getpid())
print(f"Memory usage: {process.memory_info().rss / 1024 / 1024:.2f} MB")
```

**Clear Variables:**
```python
# Delete large objects
del large_dataframe
import gc
gc.collect()
```

## Troubleshooting

### Extension Not Working

**Problem:** Extension doesn't activate

**Solutions:**
1. Reload VS Code window
2. Check extension is enabled
3. Update to latest version
4. Check VS Code version compatibility

### Blocks Not Executing

**Problem:** Code blocks don't run

**Solutions:**
1. Verify Python interpreter is selected
2. Check Python environment is activated
3. Install required packages
4. Restart kernel

**Restart Kernel:**
- Command Palette → "Deepnote: Restart Kernel"
- Or click restart icon in toolbar

### IntelliSense Not Working

**Problem:** No code completion

**Solutions:**
1. Install Python extension
2. Select correct interpreter
3. Install language server
4. Reload window

### SQL Blocks Failing

**Problem:** SQL blocks don't execute

**Solutions:**
1. Check environment variables are set
2. Install database drivers
3. Test connection manually
4. Verify integration ID

### Output Not Displaying

**Problem:** Outputs don't show

**Solutions:**
1. Check output panel is open
2. Clear and re-run block
3. Check for errors in console
4. Verify output size limits

## Best Practices

### Project Organization

**Recommended Structure:**
```
my-project/
├── .venv/ # Virtual environment
├── .env # Environment variables
├── .gitignore # Git ignore file
├── requirements.txt # Python dependencies
├── README.md # Project documentation
├── data/ # Data files
├── notebooks/ # Deepnote notebooks
│ ├── 01_loading.deepnote
│ ├── 02_processing.deepnote
│ └── 03_analysis.deepnote
└── outputs/ # Generated outputs
```

### Naming Conventions

**Notebooks:**
- Use descriptive names
- Add number prefixes for order
- Use lowercase with hyphens

```
01_data-loading.deepnote
02_data-cleaning.deepnote
03_exploratory-analysis.deepnote
04_model-training.deepnote
```

### Documentation

**Add Markdown Blocks:**
```markdown
# Project Title

## Overview
Brief description of the notebook purpose.

## Requirements
- Python 3.9+
- pandas, numpy, scikit-learn

## Usage
1. Run data loading blocks
2. Execute analysis blocks
3. Review outputs
```

### Code Quality

**Use Linting:**
```bash
# Install linters
pip install pylint black

# Format code
black notebook.py

# Check code quality
pylint notebook.py
```

**Type Hints:**
```python
def process_data(df: pd.DataFrame) -> pd.DataFrame:
"""Process the input DataFrame."""
return df.dropna()
```

## Advanced Features

### Custom Snippets

Create code snippets for common patterns:

**File:** `.vscode/deepnote.code-snippets`
```json
{
"Import Data Science Libraries": {
"prefix": "ds-imports",
"body": [
"import pandas as pd",
"import numpy as np",
"import matplotlib.pyplot as plt",
"import seaborn as sns"
]
}
}
```

### Task Automation

**Use Tasks:**

**File:** `.vscode/tasks.json`
```json
{
"version": "2.0.0",
"tasks": [
{
"label": "Run All Notebooks",
"type": "shell",
"command": "python",
"args": ["-m", "deepnote", "run", "notebooks/*.deepnote"]
}
]
}
```

### Multi-Root Workspaces

**Work with Multiple Projects:**
```json
{
"folders": [
{ "path": "project-a" },
{ "path": "project-b" },
{ "path": "shared-utils" }
]
}
```

## Extensions Compatibility

### Recommended Extensions

**Essential:**
- Python (Microsoft)
- Jupyter (Microsoft)
- YAML (Red Hat)

**Helpful:**
- GitLens
- Prettier
- ESLint
- Docker

**Data Science:**
- Data Wrangler
- Rainbow CSV
- SQL Tools

<!-- IMAGE: Screenshot of recommended extensions -->
<!-- FILE: recommended-extensions.png -->
<!-- CAPTION: Recommended VS Code extensions for Deepnote -->

## Updates and Changelog

### Checking for Updates

**Auto-Update:**
- VS Code checks automatically
- Notification appears when update available

**Manual Check:**
1. Go to Extensions view
2. Find Deepnote extension
3. Click "Update" if available

### Release Notes

**View Changelog:**
- Click extension in Extensions view
- Read "Changelog" tab
- Review new features and fixes

## Getting Help

### Resources

- **Documentation:** [docs.deepnote.com](https://docs.deepnote.com)
- **GitHub Issues:** [github.com/deepnote/vscode-deepnote](https://github.com/deepnote/vscode-deepnote)
- **Community:** [community.deepnote.com](https://community.deepnote.com)
- **Support:** support@deepnote.com

### Reporting Issues

**Submit Bug Report:**
1. Go to GitHub Issues
2. Click "New Issue"
3. Provide:
- VS Code version
- Extension version
- Steps to reproduce
- Error messages
- Screenshots

### Feature Requests

**Request New Features:**
1. Check existing feature requests
2. Create new issue with "enhancement" label
3. Describe use case and benefits

## Related Documentation

- [Deepnote Projects in VS Code](./vscode-projects.md) - Managing projects
- [Running .deepnote in VS Code](./vscode-running.md) - Execution guide
- [VS Code Supported Blocks](./vscode-supported-blocks.md) - Block types
- [Reading .deepnote Files](./reading-deepnote-files.md) - File format

## Conclusion

The Deepnote VS Code extension brings powerful notebook capabilities to your local development environment. With support for execution, debugging, and rich outputs, you can work efficiently with Deepnote notebooks while leveraging VS Code's powerful editing features.

**Happy coding! 🚀**

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.

🛠️ Refactor suggestion | 🟠 Major

Apply Prettier formatting to fix Markdown style violations.

Static analysis detected numerous formatting violations:

  • MD031 (~20+ occurrences): Fenced code blocks must be surrounded by blank lines (e.g., lines 152, 173, 260, 274, etc.)
  • MD036 (~10+ occurrences): Emphasis used as headings—replace **Text:** with proper headings (e.g., lines 184, 188, 205, etc.)
  • MD022 (~2 occurrences): Headings must be surrounded by blank lines (lines 841, 849)

Run Prettier to auto-fix these issues:

npx prettier --write docs/oss/vscode-extension.md
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)

152-152: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


173-173: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


184-184: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


188-188: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


189-189: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


205-205: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


211-211: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


217-217: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


223-223: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


260-260: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


274-274: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


285-285: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


298-298: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


317-317: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


334-334: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


334-334: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


344-344: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


344-344: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


365-365: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


365-365: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


375-375: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


375-375: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


397-397: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


418-418: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


475-475: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


487-487: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


524-524: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


536-536: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


577-577: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


593-593: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


616-616: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


635-635: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


660-660: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


682-682: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


760-760: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


789-789: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


826-826: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


841-841: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


849-849: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)

🤖 Prompt for AI Agents
In docs/oss/vscode-extension.md around lines 1 to 849, the file has multiple
Markdown style violations (MD031 fenced code blocks need surrounding blank
lines, MD036 emphasis used as headings, MD022 headings need surrounding blank
lines); fix by running Prettier to auto-format the file (npx prettier --write
docs/oss/vscode-extension.md) or manually ensure all fenced code blocks have
blank lines before/after, replace bolded inline headings like "**Text:**" with
proper Markdown headings (e.g., "### Text"), and add blank lines around headings
at the end of the file so all MD031, MD036 and MD022 errors are resolved.

Comment on lines +1 to +950
---
title: Running .deepnote Files in VS Code
description: Complete guide to executing Deepnote notebooks in Visual Studio Code, including block execution, debugging, output management, and performance optimization.
noIndex: false
noContent: false
---

# Running .deepnote Files in VS Code

This guide covers everything you need to know about executing Deepnote notebooks in Visual Studio Code, from basic block execution to advanced debugging and optimization techniques.

## Prerequisites

Before running `.deepnote` files, ensure you have:

- ✅ VS Code installed
- ✅ Deepnote extension installed
- ✅ Python environment set up
- ✅ Required packages installed
- ✅ Database connections configured (if using SQL blocks)

## Opening .deepnote Files

### Open a Notebook

**Method 1: File Explorer**
1. Navigate to `.deepnote` file in Explorer
2. Double-click to open
3. Notebook opens in editor

**Method 2: Quick Open**
1. Press Ctrl/Cmd + P
2. Type notebook name
3. Press Enter

**Method 3: Command Line**
```bash
code notebook.deepnote
```

<!-- IMAGE: Screenshot of opening .deepnote file in VS Code -->
<!-- FILE: opening-deepnote-file.png -->
<!-- CAPTION: Opening a .deepnote file in VS Code -->

### Notebook Interface

**Main Components:**
- **Toolbar** - Execution controls and settings
- **Block cells** - Individual code/text blocks
- **Output panels** - Execution results
- **Status bar** - Kernel status and info

<!-- IMAGE: Screenshot of notebook interface with labeled components -->
<!-- FILE: notebook-interface-labeled.png -->
<!-- CAPTION: Deepnote notebook interface in VS Code -->

## Kernel Management

### Starting the Kernel

**Automatic Start:**
- Kernel starts automatically when opening notebook
- Status bar shows "Kernel: Starting..."
- Wait for "Kernel: Idle" status

**Manual Start:**
1. Click kernel status in status bar
2. Select "Start Kernel"
3. Or Command Palette → "Deepnote: Start Kernel"

<!-- IMAGE: Screenshot of kernel status indicator -->
<!-- FILE: kernel-status.png -->
<!-- CAPTION: Kernel status in VS Code status bar -->

### Selecting Python Interpreter

**Choose Interpreter:**
1. Click Python version in status bar
2. Or Ctrl/Cmd + Shift + P → "Python: Select Interpreter"
3. Choose from list:
- Virtual environments (.venv)
- Conda environments
- System Python

<!-- IMAGE: Screenshot of Python interpreter selection -->
<!-- FILE: interpreter-selection.png -->
<!-- CAPTION: Selecting Python interpreter -->

### Restarting the Kernel

**When to Restart:**
- After installing packages
- When variables need clearing
- After import errors
- When kernel becomes unresponsive

**How to Restart:**
1. Click "Restart" in toolbar
2. Or Command Palette → "Deepnote: Restart Kernel"
3. Confirm restart

**Restart and Run All:**
- Clears all variables
- Re-executes all blocks
- Fresh start

<!-- IMAGE: Screenshot of restart kernel options -->
<!-- FILE: restart-kernel-options.png -->
<!-- CAPTION: Kernel restart options -->

## Executing Blocks

### Running Single Blocks

**Execute Current Block:**
- Click ▶ play button
- Or press Shift + Enter
- Block executes, cursor moves to next

**Execute and Stay:**
- Press Ctrl/Cmd + Enter
- Block executes, cursor stays

**Execute and Insert Below:**
- Press Alt/Option + Enter
- Block executes, new block inserted

<!-- IMAGE: Screenshot showing block execution controls -->
<!-- FILE: block-execution-controls.png -->
<!-- CAPTION: Block execution controls and shortcuts -->

### Running Multiple Blocks

**Run All Blocks:**
- Click "Run All" in toolbar
- Or Ctrl/Cmd + Shift + Enter
- All blocks execute sequentially

**Run Above:**
- Right-click block → "Run Above"
- Or Ctrl/Cmd + Shift + Up
- Executes all blocks above current

**Run Below:**
- Right-click block → "Run Below"
- Or Ctrl/Cmd + Shift + Down
- Executes all blocks below current

**Run Selected Blocks:**
1. Select multiple blocks (Shift + Click)
2. Click "Run Selected"
3. Or right-click → "Run Selected Cells"

<!-- IMAGE: Screenshot of Run All and other execution options -->
<!-- FILE: run-all-options.png -->
<!-- CAPTION: Multiple block execution options -->

### Execution Order

**Sequential Execution:**
- Blocks run in order from top to bottom
- Each block waits for previous to complete
- Execution count increments

**Execution Indicators:**
- `[*]` - Currently executing
- `[1]` - Execution count
- `[ ]` - Not yet executed

**Interrupt Execution:**
- Click "Interrupt" button
- Or press Ctrl/Cmd + C
- Stops current execution

<!-- IMAGE: Screenshot showing execution indicators -->
<!-- FILE: execution-indicators.png -->
<!-- CAPTION: Block execution status indicators -->

## Block Types and Execution

### Code Blocks

**Python Code:**
```python
import pandas as pd
import numpy as np

# Load data
df = pd.read_csv('/work/data/sales.csv')

# Basic analysis
print(f"Shape: {df.shape}")
print(f"Columns: {df.columns.tolist()}")

# Display
df.head()
```

**Execution:**
- Runs in Python kernel
- Outputs appear below block
- Variables stored in kernel memory

<!-- IMAGE: Screenshot of code block execution with output -->
<!-- FILE: code-block-execution.png -->
<!-- CAPTION: Code block execution with DataFrame output -->

### SQL Blocks

**SQL Query:**
```sql
SELECT
customer_id,
SUM(amount) as total_spent,
COUNT(*) as order_count,
AVG(amount) as avg_order
FROM orders
WHERE order_date >= '2024-01-01'
GROUP BY customer_id
ORDER BY total_spent DESC
LIMIT 100
```

**Configuration:**
- Set integration in block metadata
- Assign to variable
- Choose return type (dataframe/query_preview)

**Execution:**
- Connects to database
- Executes query
- Returns results as DataFrame

<!-- IMAGE: Screenshot of SQL block execution -->
<!-- FILE: sql-block-execution.png -->
<!-- CAPTION: SQL block execution with results -->

### Input Blocks

**Interactive Inputs:**
- Text, textarea, checkbox
- Select, slider, file
- Date, date range

**Execution:**
- Generates variable assignment
- Updates when value changes
- Re-run dependent blocks

**Example:**
```python
# Input block generates:
date_range = ['2024-01-01', '2024-12-31']

# Use in code block:
df_filtered = df[
(df['date'] >= date_range[0]) &
(df['date'] <= date_range[1])
]
```

<!-- IMAGE: Screenshot of input blocks with values -->
<!-- FILE: input-blocks-execution.png -->
<!-- CAPTION: Input blocks generating variables -->

### Markdown Blocks

**Rendered Markdown:**
- Headers, lists, links
- Code snippets
- Tables, images

**Execution:**
- Renders immediately
- No kernel execution needed
- Updates on edit

<!-- IMAGE: Screenshot of rendered markdown block -->
<!-- FILE: markdown-block-rendered.png -->
<!-- CAPTION: Rendered markdown block -->

## Output Management

### Viewing Outputs

**Output Types:**

**Text Output:**
```
Shape: (1000, 5)
Columns: ['id', 'name', 'date', 'amount', 'category']
```

**DataFrame Output:**
- Interactive table
- Sortable columns
- Scrollable rows
- Copy/export options

**Plot Output:**
- Rendered visualizations
- Interactive (plotly)
- Static (matplotlib)

**Error Output:**
- Formatted tracebacks
- Syntax highlighting
- Clickable file paths

<!-- IMAGE: Screenshot showing different output types -->
<!-- FILE: output-types-display.png -->
<!-- CAPTION: Various output types displayed -->

### Output Controls

**Collapse/Expand:**
- Click arrow next to output
- Hides/shows output panel
- Saves screen space

**Scroll Output:**
- Long outputs are scrollable
- Set max height in settings
- Prevents page overflow

**Clear Output:**
- Click "Clear" button
- Or right-click → "Clear Output"
- Removes output, keeps code

**Clear All Outputs:**
- Command Palette → "Deepnote: Clear All Outputs"
- Clears all notebook outputs
- Useful before committing

<!-- IMAGE: Screenshot of output controls -->
<!-- FILE: output-controls.png -->
<!-- CAPTION: Output panel controls -->

### Copying Outputs

**Copy as Text:**
1. Right-click output
2. Select "Copy Output"
3. Paste anywhere

**Export DataFrame:**
```python
# Save to CSV
df.to_csv('/work/outputs/results.csv', index=False)

# Save to Excel
df.to_excel('/work/outputs/results.xlsx', index=False)
```

**Save Plot:**
```python
import matplotlib.pyplot as plt

plt.savefig('/work/outputs/plot.png', dpi=300, bbox_inches='tight')
```

## Variables and State

### Variable Explorer

**View Variables:**
1. Click "Variables" in toolbar
2. Or Command Palette → "Deepnote: Show Variables"
3. Panel shows all variables

**Variable Information:**
- Name
- Type
- Value (for simple types)
- Size (for arrays/DataFrames)

<!-- IMAGE: Screenshot of Variable Explorer -->
<!-- FILE: variable-explorer-panel.png -->
<!-- CAPTION: Variable Explorer showing notebook variables -->

### Inspecting Variables

**In Code:**
```python
# Check variable type
print(type(df))

# Check DataFrame info
print(df.info())

# Check shape
print(df.shape)

# View first rows
df.head()
```

**Hover Inspection:**
- Hover over variable name
- Tooltip shows type and value
- Works with IntelliSense

**Debug Console:**
- Open during debugging
- Evaluate expressions
- Inspect variables

### Managing State

**Clear Variables:**
```python
# Delete specific variable
del df

# Clear all variables
%reset -f # IPython magic
```

**Restart Kernel:**
- Clears all variables
- Fresh Python session
- Use when state is corrupted

**Persistent State:**
```python
# Save state
import pickle

with open('/work/state.pkl', 'wb') as f:
pickle.dump({'df': df, 'model': model}, f)

# Load state
with open('/work/state.pkl', 'rb') as f:
state = pickle.load(f)
df = state['df']
model = state['model']
```

## Debugging

### Setting Breakpoints

**Add Breakpoint:**
1. Click left margin next to line number
2. Red dot appears
3. Execution pauses at breakpoint

**Conditional Breakpoint:**
1. Right-click margin
2. Select "Add Conditional Breakpoint"
3. Enter condition: `x > 100`

**Logpoint:**
1. Right-click margin
2. Select "Add Logpoint"
3. Enter message: `Value is {x}`

<!-- IMAGE: Screenshot of breakpoint in code -->
<!-- FILE: breakpoint-example.png -->
<!-- CAPTION: Setting a breakpoint in a code block -->

### Debug Mode

**Start Debugging:**
1. Set breakpoints
2. Click "Debug Cell" button
3. Or press F5

**Debug Controls:**
- **Continue** (F5) - Run to next breakpoint
- **Step Over** (F10) - Execute current line
- **Step Into** (F11) - Enter function
- **Step Out** (Shift + F11) - Exit function
- **Stop** (Shift + F5) - End debugging

<!-- IMAGE: Screenshot of debug controls -->
<!-- FILE: debug-controls-toolbar.png -->
<!-- CAPTION: Debug toolbar with controls -->

### Debug Panels

**Variables Panel:**
- Shows all variables in scope
- Expand to see nested values
- Modify values during debugging

**Watch Panel:**
- Add expressions to watch
- Updates as you step through
- Monitor specific values

**Call Stack:**
- Shows function call hierarchy
- Click to jump to frame
- Inspect variables at each level

**Breakpoints Panel:**
- List all breakpoints
- Enable/disable breakpoints
- Edit conditions

<!-- IMAGE: Screenshot of debug panels -->
<!-- FILE: debug-panels-layout.png -->
<!-- CAPTION: Debug panels showing variables and call stack -->

### Debug Console

**Evaluate Expressions:**
```python
# In debug console
>>> df.shape
(1000, 5)

>>> df['amount'].sum()
125000.50

>>> len(df[df['amount'] > 100])
450
```

**Modify Variables:**
```python
# Change variable value
>>> x = 999

# Test conditions
>>> x > 100
True
```

## Error Handling

### Understanding Errors

**Common Error Types:**

**SyntaxError:**
```python
# Missing colon
if x > 10
print(x)
```
**Fix:** Add colon after condition

**NameError:**
```python
# Variable not defined
print(undefined_variable)
```
**Fix:** Define variable first

**ImportError:**
```python
# Package not installed
import missing_package
```
**Fix:** `pip install missing_package`

**KeyError:**
```python
# Column doesn't exist
df['nonexistent_column']
```
**Fix:** Check column names

<!-- IMAGE: Screenshot of error traceback -->
<!-- FILE: error-traceback-display.png -->
<!-- CAPTION: Error traceback with highlighted issue -->

### Debugging Errors

**Read Traceback:**
1. Start from bottom (actual error)
2. Work up to find cause
3. Click file paths to jump to code

**Common Debugging Steps:**
```python
# 1. Check variable exists
print('df' in dir())

# 2. Check type
print(type(df))

# 3. Check value
print(df)

# 4. Check shape/length
print(df.shape if hasattr(df, 'shape') else len(df))
```

**Use Try-Except:**
```python
try:
result = risky_operation()
except Exception as e:
print(f"Error: {e}")
import traceback
traceback.print_exc()
```

### Error Recovery

**Restart Kernel:**
- Fixes import errors
- Clears corrupted state
- Fresh start

**Reload Modules:**
```python
import importlib
importlib.reload(my_module)
```

**Check Environment:**
```python
# Verify packages
!pip list | grep pandas

# Check Python version
import sys
print(sys.version)

# Check working directory
import os
print(os.getcwd())
```

## Performance Optimization

### Execution Speed

**Profile Code:**
```python
import time

start = time.time()
# Your code here
result = expensive_operation()
end = time.time()

print(f"Execution time: {end - start:.2f} seconds")
```

**Use %%time Magic:**
```python
%%time
# Cell execution time
df_processed = process_large_dataframe(df)
```

**Memory Profiling:**
```python
import psutil
import os

process = psutil.Process(os.getpid())
print(f"Memory: {process.memory_info().rss / 1024 / 1024:.2f} MB")
```

### Optimize DataFrame Operations

**Vectorization:**
```python
# Slow - iterating
for i, row in df.iterrows():
df.at[i, 'new_col'] = row['col1'] * 2

# Fast - vectorized
df['new_col'] = df['col1'] * 2
```

**Efficient Filtering:**
```python
# Use boolean indexing
df_filtered = df[df['amount'] > 100]

# Chain conditions
df_filtered = df[(df['amount'] > 100) & (df['status'] == 'active')]
```

**Data Types:**
```python
# Optimize data types
df['id'] = df['id'].astype('int32') # Instead of int64
df['category'] = df['category'].astype('category') # For repeated values
```

### Memory Management

**Delete Unused Variables:**
```python
# Free memory
del large_dataframe
import gc
gc.collect()
```

**Process in Chunks:**
```python
# Read large file in chunks
chunk_size = 10000
for chunk in pd.read_csv('large_file.csv', chunksize=chunk_size):
process_chunk(chunk)
```

**Use Generators:**
```python
# Memory-efficient iteration
def process_rows(df):
for row in df.itertuples():
yield process_row(row)

results = list(process_rows(df))
```

## Advanced Execution

### Execution Modes

**Block Mode:**
- Execute blocks independently
- No automatic dependencies
- Manual execution order

**Downstream Mode:**
- Execute dependent blocks automatically
- Tracks variable dependencies
- Cascading execution

<!-- IMAGE: Screenshot of execution mode selector -->
<!-- FILE: execution-mode-selector.png -->
<!-- CAPTION: Selecting execution mode -->

### Parallel Execution

**Run Multiple Notebooks:**
```python
import subprocess
from concurrent.futures import ThreadPoolExecutor

notebooks = [
'notebook1.deepnote',
'notebook2.deepnote',
'notebook3.deepnote'
]

def run_notebook(notebook):
subprocess.run(['deepnote-cli', 'run', notebook])

with ThreadPoolExecutor(max_workers=3) as executor:
executor.map(run_notebook, notebooks)
```

### Scheduled Execution

**Using Cron (Linux/macOS):**
```bash
# Edit crontab
crontab -e

# Run daily at 2 AM
0 2 * * * cd /path/to/project && /path/to/.venv/bin/python -m deepnote run notebook.deepnote
```

**Using Task Scheduler (Windows):**
1. Open Task Scheduler
2. Create Basic Task
3. Set trigger (daily, weekly)
4. Action: Start program
5. Program: `python`
6. Arguments: `-m deepnote run notebook.deepnote`

### Batch Processing

**Process Multiple Files:**
```python
import glob

# Get all CSV files
files = glob.glob('/work/data/*.csv')

# Process each
results = []
for file in files:
df = pd.read_csv(file)
result = process_dataframe(df)
results.append(result)

# Combine results
final_df = pd.concat(results, ignore_index=True)
```

## Keyboard Shortcuts Reference

### Essential Shortcuts

| Action | Windows/Linux | macOS |
|--------|--------------|-------|
| Run cell | Shift + Enter | Shift + Return |
| Run and insert | Alt + Enter | Option + Return |
| Run all | Ctrl + Shift + Enter | Cmd + Shift + Return |
| Interrupt | Ctrl + C | Cmd + C |
| Restart kernel | Ctrl + Shift + R | Cmd + Shift + R |

### Navigation

| Action | Windows/Linux | macOS |
|--------|--------------|-------|
| Next cell | Down | Down |
| Previous cell | Up | Up |
| First cell | Ctrl + Home | Cmd + Home |
| Last cell | Ctrl + End | Cmd + End |

### Editing

| Action | Windows/Linux | macOS |
|--------|--------------|-------|
| Insert above | Ctrl + Shift + A | Cmd + Shift + A |
| Insert below | Ctrl + Shift + B | Cmd + Shift + B |
| Delete cell | Ctrl + Shift + D | Cmd + Shift + D |
| Copy cell | Ctrl + C | Cmd + C |
| Paste cell | Ctrl + V | Cmd + V |

### Debugging

| Action | Windows/Linux | macOS |
|--------|--------------|-------|
| Toggle breakpoint | F9 | F9 |
| Start debugging | F5 | F5 |
| Step over | F10 | F10 |
| Step into | F11 | F11 |
| Stop debugging | Shift + F5 | Shift + F5 |

<!-- IMAGE: Screenshot of keyboard shortcuts cheat sheet -->
<!-- FILE: keyboard-shortcuts-reference.png -->
<!-- CAPTION: Complete keyboard shortcuts reference -->

## Best Practices

### Execution Workflow

1. **Start Fresh:**
- Restart kernel
- Run all blocks
- Verify outputs

2. **Incremental Development:**
- Write small blocks
- Test frequently
- Build progressively

3. **Error Handling:**
- Add try-except blocks
- Validate inputs
- Log errors

4. **Documentation:**
- Add markdown explanations
- Comment complex code
- Document assumptions

### Code Organization

**Logical Grouping:**
```python
# === Data Loading ===
df = pd.read_csv('data.csv')

# === Data Cleaning ===
df = df.dropna()
df = df[df['amount'] > 0]

# === Analysis ===
summary = df.groupby('category').agg({
'amount': ['sum', 'mean', 'count']
})

# === Visualization ===
import matplotlib.pyplot as plt
plt.figure(figsize=(10, 6))
summary.plot(kind='bar')
plt.show()
```

### Performance Tips

- ✅ Use vectorized operations
- ✅ Avoid loops when possible
- ✅ Process data in chunks
- ✅ Clear unused variables
- ✅ Use appropriate data types
- ✅ Profile slow operations

### Debugging Tips

- ✅ Start with simple test cases
- ✅ Use print statements liberally
- ✅ Check intermediate results
- ✅ Use debugger for complex issues
- ✅ Read error messages carefully
- ✅ Search for error messages online

## Troubleshooting

### Common Issues

**Issue: Kernel Won't Start**
- Check Python interpreter is selected
- Verify virtual environment is activated
- Check for package conflicts
- Try restarting VS Code

**Issue: Blocks Won't Execute**
- Check kernel status (should be "Idle")
- Verify no syntax errors
- Check for infinite loops
- Try interrupting and restarting

**Issue: Slow Execution**
- Check data size
- Profile code to find bottlenecks
- Optimize DataFrame operations
- Consider using chunks

**Issue: Out of Memory**
- Reduce data size
- Process in chunks
- Delete unused variables
- Restart kernel

**Issue: Import Errors**
- Verify package is installed: `pip list`
- Check virtual environment is activated
- Install missing package: `pip install package`
- Restart kernel after installing

## Related Documentation

- [Deepnote VS Code Extension](./vscode-extension.md) - Extension features
- [Deepnote Projects in VS Code](./vscode-projects.md) - Project management
- [VS Code Supported Blocks](./vscode-supported-blocks.md) - Block types
- [Reading .deepnote Files](./reading-deepnote-files.md) - File format

## Conclusion

Running Deepnote notebooks in VS Code provides a powerful local development environment with full execution, debugging, and optimization capabilities. Master these techniques to work efficiently with your notebooks.

**Happy executing! ⚡**

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.

🛠️ Refactor suggestion | 🟠 Major

Apply Prettier formatting to fix Markdown style violations.

Multiple formatting violations detected:

  • MD031 (~30+ occurrences): Fenced code blocks need blank lines before/after (lines 37, 184, 211, 251, etc.)
  • MD036 (~15+ occurrences): Replace emphasis patterns like **Method 1:** with proper headings (lines 26, 31, 36, 909, 915, 921, 927, 933, 950)
  • MD022 (~3 occurrences): Add blank lines around headings (lines 841, 849, 950)

Run Prettier:

npx prettier --write docs/oss/vscode-running.md
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)

26-26: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


31-31: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


36-36: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


37-37: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


184-184: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


211-211: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


251-251: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


289-289: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


289-289: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


348-348: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


357-357: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


385-385: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


412-412: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


426-426: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


510-510: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


523-523: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


539-539: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


543-543: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


547-547: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


550-550: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


554-554: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


557-557: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


561-561: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


564-564: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


579-579: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


594-594: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


611-611: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


617-617: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


635-635: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


647-647: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


654-654: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


665-665: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


675-675: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


684-684: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


693-693: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


701-701: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


709-709: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


739-739: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


759-759: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


778-778: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


867-867: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


909-909: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


915-915: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


921-921: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


927-927: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


933-933: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


950-950: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

🤖 Prompt for AI Agents
In docs/oss/vscode-running.md (lines 1-950), the file has many Markdown style
violations (missing blank lines around fenced code blocks MD031, improper
emphasis used as headings MD036, and missing blank lines around headings MD022);
fix by running Prettier (npx prettier --write docs/oss/vscode-running.md) and
manually ensure fenced code blocks have a blank line before and after, replace
emphasized labels like "**Method 1:**" with proper heading markup (e.g., "###
Method 1"), and add blank lines above and below headings noted around lines
~841, ~849, and ~950 to satisfy MD022.

@Yggdrasill501
Yggdrasill501 deleted the filipzirnt/mar/ossdocs branch November 6, 2025 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant