Skip to content

Add mutator documentation in initialize phase - #2560

Merged
denik merged 6 commits into
mainfrom
mutator-documentation
Apr 4, 2025
Merged

Add mutator documentation in initialize phase#2560
denik merged 6 commits into
mainfrom
mutator-documentation

Conversation

@denik

@denikdenik commented Mar 25, 2025

Copy link
Copy Markdown
Contributor

Changes

  • Add comments to every mutator call in initialize.go. Some of them written manually, most are AI generated.

The script & prompt are not included available on separate branch:
https://github.com/databricks/cli/blob/denik/mutator-documentation-with-script/tools/update_phases_comments.py
https://github.com/databricks/cli/blob/denik/mutator-documentation-with-script/bundle/phases/mutator_documentation.md

Why

This helps to see what changes are mutators making to bundle (if any), without reading every source file.

Comment threadbundle/phases/initialize.go Outdated

// Reads (dynamic): resources.jobs.*.{notebook_task.notebook_path,spark_jar_task.main_class_name,spark_python_task.python_file}, resources.pipelines.*.{libraries.notebook.path,libraries.file.path}, resources.dashboards.*.definition, resources.apps.*.{package,resources.*.path}
// Updates (dynamic): resources.jobs.*.{notebook_task.notebook_path,spark_jar_task.main_class_name,spark_python_task.python_file}, resources.pipelines.*.{libraries.notebook.path,libraries.file.path}, resources.dashboards.*.definition, resources.apps.*.{package,resources.*.path} (converts local paths to workspace paths)
// Translates local file paths to workspace paths for notebooks, files, and directories

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.

The list of paths is incorrect; lists items that are not updated and omits others.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

This one is quite complex, no wonder LLM could not write correct comment. I also don't see what exactly it updates from a glance.

Can you suggest authoritative description? Can also be a follow up PR.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

For now, I removed wrong comment completely.

Comment threadtools/update_phases_comments.py Outdated
Comment threadbundle/phases/initialize.go
Comment threadbundle/phases/initialize.go Outdated
Comment threadbundle/phases/initialize.go Outdated
@denik
denikforce-pushed the mutator-documentation branch from 175631e to a6eea15CompareMarch 28, 2025 12:44
@denik
deniktemporarily deployed to test-trigger-is March 28, 2025 12:44 — with GitHub Actions Inactive
@denikdenik changed the title AI generated mutator documentation in initialize phaseAdd mutator documentation in initialize phaseMar 28, 2025
@denik
deniktemporarily deployed to test-trigger-is March 28, 2025 16:23 — with GitHub Actions Inactive
@denik
denikforce-pushed the mutator-documentation branch from a6e9049 to 1fcad7aCompareMarch 28, 2025 16:23
@denik
deniktemporarily deployed to test-trigger-is March 28, 2025 16:23 — with GitHub Actions Inactive
Comment threadbundle/phases/initialize.go Outdated
// Figure out if the sync root path is identical or an ancestor of the bundle root path.
// If it is an ancestor, this updates all paths to be relative to the sync root path.
// Reads (typed): b.Config.Sync.Paths (calculates longest common parent together with bundle root).
// Updates (typed) b.{SyncRoot,SyncRootPath} (set to calculate sync root, which is either bundle root or some parent of bundle root)

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.

Suggested change
// Updates (typed) b.{SyncRoot,SyncRootPath} (set to calculate sync root, which is either bundle root or some parent of bundle root)
// Updates (typed) b.{SyncRoot,SyncRootPath} (set to inferred sync root, which is either bundle root or some parent of bundle root)

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.

Not sure why the comment was disregarded as it seems like inferred makes more sense here

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

"inferred" to be implies some guessing or really deep reasoning. We just calculate the closest common parent, nothing fancy.

Comment threadbundle/phases/initialize.go
Comment threadbundle/phases/initialize.go Outdated
// searches for strings with variable references in them.
// Reads (dynamic): * (strings) (searches for strings with workspace path variables prefixed with "/Workspace")
// Updates (dynamic): * (strings) (removes "/Workspace" prefix from workspace path variables)
// Finds and removes "/Workspace" prefix from all strings in bundle configuration

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.

Suggested change
// Finds and removes "/Workspace" prefix from all strings in bundle configuration
// Finds and removes "/Workspace" prefix from all references to `workspace.root_path`, `workspace.file_path` etc in bundle configuration

@shreyas-goenka
shreyas-goenka self-requested a review March 31, 2025 16:26
@denik
deniktemporarily deployed to test-trigger-is March 31, 2025 17:34 — with GitHub Actions Inactive
@denik
denikforce-pushed the mutator-documentation branch from d1a0669 to 1ed2ec0CompareApril 1, 2025 13:22
@denik
deniktemporarily deployed to test-trigger-is April 1, 2025 13:26 — with GitHub Actions Inactive
Comment threadbundle/phases/initialize.go
Comment threadbundle/phases/initialize.go Outdated
// Figure out if the sync root path is identical or an ancestor of the bundle root path.
// If it is an ancestor, this updates all paths to be relative to the sync root path.
// Reads (typed): b.Config.Sync.Paths (calculates longest common parent together with bundle root).
// Updates (typed) b.{SyncRoot,SyncRootPath} (set to calculate sync root, which is either bundle root or some parent of bundle root)

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.

Not sure why the comment was disregarded as it seems like inferred makes more sense here

Comment threadbundle/phases/initialize.go Outdated
Comment threadbundle/phases/initialize.go
Comment threadbundle/phases/initialize.go Outdated
// searches for strings with variable references in them.
mutator.RewriteWorkspacePrefix(),

// Reads (dynamic): variables.* (checks for existing values, defaults, and lookup references)

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.

Not sure what this part means, should it be clarified?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

How would you write it?

Comment threadbundle/phases/initialize.go Outdated

// Reads (dynamic): variables.* (checks for existing values, defaults, and lookup references)
// Updates (dynamic): variables.*.value (sets values from environment variables, variable files, or defaults)
// Resolves and sets values for bundle variables from environment variables, variable files, or defaults

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.

Maybe worth clarifying the order how we set the variables?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

How would you write it?

Comment threadbundle/phases/initialize.go Outdated

// Reads (typed): b.Config.RunAs, b.Config.Workspace.CurrentUser (validates run_as configuration)
// Reads (dynamic): run_as (checks if run_as is specified)
// Updates (typed): b.Config.Resources.Jobs[].RunAs (sets job run_as fields to bundle run_as)

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.

It only does it when Experimental.UseLegacyRunAs is set which is imprortant part here. It also does it for pipelines and mostly just validates that we don;t use run_as with unsupported resources

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Updated.

Comment threadbundle/phases/initialize.go Outdated

// Reads (typed): b.Config.Experimental.PythonWheelWrapper, b.Config.Presets.SourceLinkedDeployment (checks Python wheel wrapper and deployment mode settings)
// Reads (dynamic): resources.jobs.*.tasks (checks for tasks with local libraries and incompatible DBR versions)
// Provides warnings when Python wheel tasks require DBR 13.3+ or when wheel wrapper is incompatible with source-linked deployment

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.

This seems incorrect, the warning is for cases when python wheel tasks are used on DBRs < 13.3

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Updated.

@denik
denikforce-pushed the mutator-documentation branch from eac2aa0 to b35785dCompareApril 3, 2025 07:34
@denik
deniktemporarily deployed to test-trigger-is April 3, 2025 07:34 — with GitHub Actions Inactive
@denik
deniktemporarily deployed to test-trigger-is April 3, 2025 07:35 — with GitHub Actions Inactive
@denik
denikforce-pushed the mutator-documentation branch from 7aafea4 to b5ae417CompareApril 3, 2025 07:42
@denik
deniktemporarily deployed to test-trigger-is April 3, 2025 07:42 — with GitHub Actions Inactive
@denik
denik requested a review from andrewnesterApril 3, 2025 07:44
Comment threadbundle/phases/initialize.go Outdated
Comment threadbundle/phases/initialize.go Outdated
Comment threadbundle/phases/initialize.go Outdated
denikand others added 3 commits April 4, 2025 14:49
Co-authored-by: Andrew Nester <andrew.nester.dev@gmail.com>
Co-authored-by: Andrew Nester <andrew.nester.dev@gmail.com>
@denik
deniktemporarily deployed to test-trigger-is April 4, 2025 12:52 — with GitHub Actions Inactive
Co-authored-by: Andrew Nester <andrew.nester.dev@gmail.com>
@denik
deniktemporarily deployed to test-trigger-is April 4, 2025 12:53 — with GitHub Actions Inactive
@denik
denik enabled auto-merge April 4, 2025 12:54
@denik
denik disabled auto-merge April 4, 2025 13:34
@denik
denik merged commit 0821f08 into mainApr 4, 2025
@denik
denik deleted the mutator-documentation branch April 4, 2025 13:34
denik added a commit that referenced this pull request May 20, 2026
## Changes
- Add comments to every mutator call in initialize.go. Some of them
written manually, most are AI generated.
The script & prompt are not included available on separate branch:
https://github.com/databricks/cli/blob/denik/mutator-documentation-with-script/tools/update_phases_comments.pyhttps://github.com/databricks/cli/blob/denik/mutator-documentation-with-script/bundle/phases/mutator_documentation.md
## Why
This helps to see what changes are mutators making to bundle (if any),
without reading every source file.
---------
Co-authored-by: Andrew Nester <andrew.nester.dev@gmail.com>
Sign up for freeto 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.

4 participants

@denik@pietern@andrewnester@shreyas-goenka