Skip to content

[3.0] Preserve PEP 723 metadata when wrapping Python source notebooks - #2367

Open
hengzhan wants to merge 1 commit into
databricks:release/3.xfrom
hengzhan:fix/workflow-notebook-metadata-v3
Open

hengzhan wants to merge 1 commit into
databricks:release/3.xfrom
hengzhan:fix/workflow-notebook-metadata-v3

Conversation

@hengzhan

Copy link
Copy Markdown

Changes

Fixes PEP 723 metadata handling in the release/3.x notebook wrapper. The equivalent fix for 2.x (main) is proposed separately in #2356.

When "Run File as Workflow" wraps a Python source notebook containing PEP 723 environment metadata, it moves that metadata into the first original code cell. A following %run command is then no longer recognized correctly.

For example:

# Databricks notebook source
# /// script
# [tool.databricks.environment]
# environment_version = "5"
# ///
# MAGIC %run ./setup

This change keeps the metadata immediately below the notebook header, before the bootstrap code and any rearranged %pip or Python restart cells.

Tests

  • All 14 wrapper tests pass. The four new regression cases cover LF and CRLF line endings with cell rearrangement enabled and disabled, using a notebook containing %run, %pip, and a Python restart command. All four failed against the original implementation.
  • yarn check, yarn test, and yarn typecheck pass.
  • Extension test suite: 3,114 passed, one existing skip. All 179 repository script tests pass.
  • Manually verified the v3 build against a real Databricks workspace: the metadata + %run reproduction succeeds with cell rearrangement enabled and disabled.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant