Skip to content

Minor refactoring of PyDABs autogen code - #6575

Merged
Sankalp-Mittal merged 8 commits into
mainfrom
sankalp-mittal/pydabs-autogen-refactor
Sep 9, 2026
Merged

Minor refactoring of PyDABs autogen code#6575
Sankalp-Mittal merged 8 commits into
mainfrom
sankalp-mittal/pydabs-autogen-refactor

Conversation

@Sankalp-Mittal

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

Copy link
Copy Markdown
Collaborator

Summary

Minor follow-up refactoring on the PyDABs autogen code, addressing non-blocking review comments left on earlier PRs (#6421, #6528).

Details

  • Guard generate_type against unsupported map refs: only dict[str, str] is modelled today; any other map ref (map/int, map/<object>) previously fell through and silently generated the bare value type instead of a dict. It now fails loudly, matching the existing guard in generated_test_cases._synth_ref.
  • Remove the dead create_func_type_name / create_func_default fields (and the now-orphaned optional_type helper): scaffolding for a static create() factory that was never implemented — set but never read since codegen was first added.
  • De-duplicate generate_field: collapse the four near-duplicate GeneratedField(...) branches into one base value plus per-branch dataclasses.replace(...) deltas.
  • Rename TestCaseResourceTestCase: pytest no longer tries to collect it as a test class (its name no longer starts with Test), so the __test__ = False marker is unnecessary. The rename propagates through test_case.py.tmpl into test_resources.py and the generated per-resource files.
  • Avoid a KeyError on an unknown launch stage: use _STAGE_RANK.get(prop.stage, 0) instead of a bare dict lookup, so an absent/unknown stage is treated as GA rather than killing codegen (matches the Go launchStageRank semantics).
  • De-duplicate module resolution: route _synth_ref's module lookup through _module_of to drop the duplicated get_package(...) + assert logic.

All changes are behavior-preserving: regenerating the PyDABs output produces a byte-identical tree (aside from the ResourceTestCase rename propagating into the generated files). Codegen unit tests (38) and test_resources.py (232) pass.

Supersedes #6573 (auto-closed when the stack it was based on merged to main).

This pull request and its description were written by Isaac.

Sankalp-Mittal and others added 2 commits September 8, 2026 16:24
- Use _STAGE_RANK.get(prop.stage, 0) so an unknown/absent launch stage is
  treated as GA instead of raising KeyError and killing codegen.
- Route _synth_ref's module resolution through _module_of to avoid
  duplicating the get_package + assert logic.
- Add __test__ = False to TestCase so pytest stops trying to collect it.

Co-authored-by: Isaac <no-reply@databricks.com>
The four GeneratedField branches differed in only a couple of kwargs; build
one base field and override the per-branch deltas via replace(), keeping
pyright's type checking intact.

Co-authored-by: Isaac <no-reply@databricks.com>
generate_type only models dict[str, str]; any other map ref (map/int,
map/<object>) previously fell through and silently generated the bare value
type instead of a dict. Fail loudly instead, matching the guard in
generated_test_cases._synth_ref.

Co-authored-by: Isaac <no-reply@databricks.com>
@eng-dev-ecosystem-bot

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

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: 4bbdf6c

Run: 34348281124

Env 💚​RECOVERED ✅​pass 🙈​skip Time
💚​ aws linux 1 275 15 6:53
💚​ aws windows 1 277 13 4:56
💚​ azure linux 1 274 15 10:01
💚​ azure windows 1 276 13 6:58
💚​ gcp linux 1 275 15 6:34
💚​ gcp windows 1 277 13 5:17
Test Name aws linux aws windows azure linux azure windows gcp linux gcp windows
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
Top 6 slowest tests (at least 2 minutes):
duration env testname
4:53 aws windows TestAccept
3:50 gcp windows TestAccept
3:47 azure windows TestAccept
2:09 gcp linux TestAccept
2:09 azure linux TestAccept
2:06 aws linux TestAccept

@Sankalp-Mittal Sankalp-Mittal changed the title WIP minor refactoring of autogen code Minor refactoring of PyDABs autogen code Sep 9, 2026
@Sankalp-Mittal
Sankalp-Mittal marked this pull request as ready for review September 9, 2026 08:10
Comment thread python/databricks_tests/core/_resource_test_case.py Outdated
Comment thread python/codegen/codegen/generated_dataclass.py Outdated
Sankalp-Mittal and others added 3 commits September 9, 2026 11:42
Renaming avoids pytest trying to collect it as a test class (its name no
longer starts with "Test"), so the __test__ = False marker is no longer
needed. Addresses review nit.

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.

thanks!

@Sankalp-Mittal
Sankalp-Mittal added this pull request to the merge queue Sep 9, 2026
Merged via the queue into main with commit 483ee7d Sep 9, 2026
34 checks passed
@Sankalp-Mittal
Sankalp-Mittal deleted the sankalp-mittal/pydabs-autogen-refactor branch September 9, 2026 12:41
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