Skip to content

Generate PyDABs reference doc pages from generated modules - #6727

Open
Sankalp-Mittal wants to merge 3 commits into
mainfrom
sankalp-mittal/automate-pydabs-docs
Open

Sankalp-Mittal wants to merge 3 commits into
mainfrom
sankalp-mittal/automate-pydabs-docs

Conversation

@Sankalp-Mittal

@Sankalp-Mittal Sankalp-Mittal commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Stack

Why

The PyDABs Python reference docs (https://databricks.github.io/cli/python/) went stale. Codegen now emits 31 resource modules under python/databricks/bundles/*/, but the Sphinx .rst pages were hand-written and listed only 5 (core, jobs, pipelines, schemas, volumes).

What

Generate the per-resource .rst pages and the index.rst toctree inside pydabs-codegen:

  • New python/codegen/codegen/generated_docs.pywrite_docs() scans the generated databricks/bundles/*/ package dirs (decoupled from RESOURCE_NAMESPACE, robust to future renames), writes one page per resource, and regenerates the index.rst toctree. Called from main.py after the existing generation.
  • Stale generated pages are removed on each run so a dropped resource loses its page.
  • core.rst stays hand-written. The 4 previously hand-written resource pages (jobs, pipelines, schemas, volumes) regenerate byte-identical — no diff. index.rst's prose header is preserved verbatim; only its toctree grows.
  • Acronym titles (SQL Warehouses, MCP Services) handled via a small override map.
  • The doc structure lives in doc_page.rst.tmpl and doc_index.rst.tmpl (loaded via string.Template, like the existing *.py.tmpl codegen templates) so it can be reviewed separately from the generation code.
  • python/Taskfile.yml: added the generated doc outputs to the task's generates: list.

Also fold in a related fix surfaced in review: some upstream API descriptions aren't valid reStructuredText and break the Sphinx build (e.g. sql.SpotInstancePolicy, whose comment is a hard-wrapped ASCII grid table docutils rejects as malformed).

  • New burn-down override list jsonschema_patch.override_descriptions rewrites such descriptions into valid RST until the proto comment is fixed upstream (see sqlgateway/scheduler/api/proto/endpoint_common.proto). The override raises if it becomes a no-op, flagging entries to remove once upstream lands.
  • The strict -W docs gate that surfaces any new such breakage (at PR/SDK-bump time) lands in Auto-publish PyDABs reference docs to gh-pages on release #6729.

CI's generate-check + git diff --exit-code now enforces the documented resource list can never drift from the generated modules.

Testing

  • ./task pydabs-codegen — regenerates code + 31 .rst pages + index.rst; the 4 existing pages show no diff; idempotent on re-run.
  • ./task pydabs-docs — Sphinx build succeeds and now emits all 32 databricks.bundles.*.html pages; the sql_warehouses page renders a proper table instead of the malformed one.

This pull request and its description were written by Isaac.

Sankalp-Mittal and others added 2 commits September 17, 2026 09:50
The Sphinx .rst pages under python/docs/ were hand-written and listed only 5
resources, while codegen now emits 31 resource modules — so the published
Python reference docs (databricks.github.io/cli/python) went stale.

Generate the per-resource .rst pages and index.rst toctree in pydabs-codegen,
driven by scanning the generated databricks/bundles/*/ package dirs (decoupled
from RESOURCE_NAMESPACE). The existing hand-written pages regenerate
byte-identical; core.rst stays hand-written. CI's generate-check + git diff now
enforces the doc list never drifts from the generated resources.

Co-authored-by: Isaac <no-reply@databricks.com>
Extract the RST page and index layout from generated_docs.py into
doc_page.rst.tmpl and doc_index.rst.tmpl, loaded via string.Template like the
existing *.py.tmpl codegen templates. This lets the doc structure be reviewed
and tracked separately from the generation code. Output is byte-identical.

Co-authored-by: Isaac <no-reply@databricks.com>

@janniklasrose janniklasrose left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

tested task pydabs-docs:

/Users/jan.rose/pub/cli.worktrees/pr-6727/python/databricks/bundles/sql_warehouses/_models/spot_instance_policy.py:docstring of databricks.bundles.sql_warehouses._models.spot_instance_policy.SpotInstancePolicy:5: ERROR: Malformed table.

+-------+--------------------------------------+--------------------------------+
| Cloud |            COST_OPTIMIZED            |     RELIABILITY_OPTIMIZED |
+-------+--------------------------------------+--------------------------------+ [docutils]
/Users/jan.rose/pub/cli.worktrees/pr-6727/python/databricks/bundles/sql_warehouses/_models/spot_instance_policy.py:docstring of databricks.bundles.sql_warehouses._models.spot_instance_policy.SpotInstancePolicy:8: WARNING: Blank line required after table. [docutils]
/Users/jan.rose/pub/cli.worktrees/pr-6727/python/databricks/bundles/sql_warehouses/_models/spot_instance_policy.py:docstring of databricks.bundles.sql_warehouses._models.spot_instance_policy.SpotInstancePolicy:9: WARNING: Line block ends without a blank line. [docutils]
/Users/jan.rose/pub/cli.worktrees/pr-6727/python/databricks/bundles/sql_warehouses/_models/spot_instance_policy.py:docstring of databricks.bundles.sql_warehouses._models.spot_instance_policy.SpotInstancePolicy:9: ERROR: Malformed table.

+-------+--------------------------------------+--------------------------------+
| AWS   | On Demand Driver with Spot Executors | On Demand Driver and [docutils]
/Users/jan.rose/pub/cli.worktrees/pr-6727/python/databricks/bundles/sql_warehouses/_models/spot_instance_policy.py:docstring of databricks.bundles.sql_warehouses._models.spot_instance_policy.SpotInstancePolicy:11: WARNING: Blank line required after table. [docutils]


/Users/jan.rose/pub/cli.worktrees/pr-6727/python/databricks/bundles/core/_resources.py:docstring of databricks.bundles.core._resources.Resources:23: WARNING: py:meth reference target not found: add_job [ref.meth]

Comment thread python/codegen/codegen/generated_docs.py
@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: eb02251

Run: 35238446628

Env ✅​pass 🙈​skip Time
✅​ aws linux 276 15 4:27
✅​ aws windows 278 13 5:23
✅​ azure linux 275 15 4:06
✅​ azure windows 277 13 3:43
✅​ gcp linux 276 15 4:27
✅​ gcp windows 278 13 3:47
Top 3 slowest tests (at least 2 minutes):
duration env testname
5:20 aws windows TestAccept
3:44 gcp windows TestAccept
3:41 azure windows TestAccept

Comment thread python/Taskfile.yml
@Sankalp-Mittal

Sankalp-Mittal commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

tested task pydabs-docs:

/Users/jan.rose/pub/cli.worktrees/pr-6727/python/databricks/bundles/sql_warehouses/_models/spot_instance_policy.py:docstring of databricks.bundles.sql_warehouses._models.spot_instance_policy.SpotInstancePolicy:5: ERROR: Malformed table.

+-------+--------------------------------------+--------------------------------+
| Cloud |            COST_OPTIMIZED            |     RELIABILITY_OPTIMIZED |
+-------+--------------------------------------+--------------------------------+ [docutils]
/Users/jan.rose/pub/cli.worktrees/pr-6727/python/databricks/bundles/sql_warehouses/_models/spot_instance_policy.py:docstring of databricks.bundles.sql_warehouses._models.spot_instance_policy.SpotInstancePolicy:8: WARNING: Blank line required after table. [docutils]
/Users/jan.rose/pub/cli.worktrees/pr-6727/python/databricks/bundles/sql_warehouses/_models/spot_instance_policy.py:docstring of databricks.bundles.sql_warehouses._models.spot_instance_policy.SpotInstancePolicy:9: WARNING: Line block ends without a blank line. [docutils]
/Users/jan.rose/pub/cli.worktrees/pr-6727/python/databricks/bundles/sql_warehouses/_models/spot_instance_policy.py:docstring of databricks.bundles.sql_warehouses._models.spot_instance_policy.SpotInstancePolicy:9: ERROR: Malformed table.

+-------+--------------------------------------+--------------------------------+
| AWS   | On Demand Driver with Spot Executors | On Demand Driver and [docutils]
/Users/jan.rose/pub/cli.worktrees/pr-6727/python/databricks/bundles/sql_warehouses/_models/spot_instance_policy.py:docstring of databricks.bundles.sql_warehouses._models.spot_instance_policy.SpotInstancePolicy:11: WARNING: Blank line required after table. [docutils]


/Users/jan.rose/pub/cli.worktrees/pr-6727/python/databricks/bundles/core/_resources.py:docstring of databricks.bundles.core._resources.Resources:23: WARNING: py:meth reference target not found: add_job [ref.meth]

This is a issue with the comment in the protos, we would have to change the upstream descriptions, or special case this, I would prefer doing the former

@janniklasrose

Copy link
Copy Markdown
Member

This is a issue with the comment in the protos, we would have to change the upstream descriptions, or special case this, I would prefer doing the former

please fix this upstream. but with the auto-gen + pipeline you're building in this stack, we need a way to surface these. erroring is probably not ok, ideally this should fail at SDK bump stage with an override that we can burn down again upstream

@Sankalp-Mittal

Copy link
Copy Markdown
Contributor Author

please fix this upstream. but with the auto-gen + pipeline you're building in this stack, we need a way to surface these. erroring is probably not ok, ideally this should fail at SDK bump stage with an override that we can burn down again upstream

Just a clarification this is not an error but a warning so the docs would be generated but they would just be broken

The sql.SpotInstancePolicy description is a hard-wrapped ASCII grid table that
docutils rejects as malformed, so the sql_warehouses page rendered broken and
the Sphinx build logged errors.

Add a burn-down override list in jsonschema_patch that rewrites such upstream
descriptions into valid reStructuredText until the proto comment is fixed
upstream (see sqlgateway/scheduler/api/proto/endpoint_common.proto). The
override raises if it becomes a no-op, flagging entries to remove once upstream
lands. Pairs with the strict (-W) docs build added later in the stack.

Co-authored-by: Isaac <no-reply@databricks.com>
@Sankalp-Mittal

Copy link
Copy Markdown
Contributor Author

please fix this upstream. but with the auto-gen + pipeline you're building in this stack, we need a way to surface these. erroring is probably not ok, ideally this should fail at SDK bump stage with an override that we can burn down again upstream

Added an override here, and the hard error is added to the other PR on this stack

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.

3 participants