Skip to content

Regenerate Python clients with shared legacy model helpers - #2762

Open
Abhinav0905 wants to merge 1 commit into
kubernetes-client:masterfrom
Abhinav0905:agent/share-legacy-model-helpers
Open

Abhinav0905 wants to merge 1 commit into
kubernetes-client:masterfrom
Abhinav0905:agent/share-legacy-model-helpers

Conversation

@Abhinav0905

Copy link
Copy Markdown

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

This is the downstream follow-up proposed and accepted in #2677, and promised after the upstream fix. OpenAPITools/openapi-generator#24730 merged on October 19.

  • Pin both update scripts to OpenAPI Generator commit 3cf4b374881ed853d522d67b326428e09defcf29, while keeping the existing environment override.
  • Regenerate the synchronous and asyncio clients from the checked-in scripts/swagger.json. The Kubernetes schema and package version stay the same.
  • Replace 1,692 copies of the conversion helper with two private modules, one per client. All 845 model classes in each client retain the same parsed code apart from the helper definitions/imports.
  • Reapply the existing Kubernetes transport/retry patches and refresh the asyncio retry patch context for the generator's new CIMultiDict import.
  • Add eight serialization compatibility cases across both clients and a repeatable release-wheel size measurement script.

Which issue(s) this PR fixes:

Related to #2677. This addresses repeated legacy helpers; it does not remove the separate sync/async clients or all package duplication.

Special notes for your reviewer:

Measured against 774884db83b36fb5d3e54629f01b14cad2d67852, using CPython 3.12.14, setuptools 84.2.1 and wheel 0.48.0:

Measurement Before (bytes) After (bytes) Reduction
Packaged Python source 73,617,872 70,146,771 3,471,101 (4.72%)
Compressed release wheel 7,511,822 6,674,379 837,443 (11.15%)
Installed files without bytecode 73,845,521 70,374,279 3,471,242 (4.70%)
Bytecode alone 42,734,869 39,925,585 2,809,284 (6.57%)
Installed files plus bytecode 116,580,390 110,299,864 6,280,526 (5.39%)

These count file contents, not filesystem allocation or dependencies. Bytecode uses optimization level 0 and relative compile paths. Both wheels use setup-release.py, including both clients. This measures code reduction separately from the pip --no-compile workaround.

To repeat with the same interpreter and separate clean checkouts:

python devel/measure-package-size.py /path/to/baseline
python devel/measure-package-size.py /path/to/this-branch

Regeneration used the CLI built from the pinned upstream commit and the settings from kubernetes-client/gen@d01fc8a15955e08c5102b7f9916a99b094ebd0e1: compatibleWithPythonLegacy, lazy imports, independent implicit clients, existing name/parameter mappings and disabled generated API/model tests. Both outputs passed through that revision's postprocess_python.py, then the patches in the update scripts were reapplied. The input spec was not fetched or changed.

The pin advances the generator from 7.25.0 to a specific 7.27.0-SNAPSHOT commit. Its generated case-insensitive header handling and query serialization changes are included, so the diff is broader than the helper imports alone.

Validation:

  • Full local suite: 452 passed, 28 skipped, 174 subtests passed. The same baseline suite passed 444 tests with the same 28 skips.
  • python -m pytest -q --ignore=kubernetes/e2e_test --ignore=kubernetes/aio/e2e_test
  • Eight new cases cover public/wire names, nested containers, JSON/API serialization, inherited models and custom to_dict() overrides.
  • New helper modules, tests and measurement script pass flake8 with the repository's 127-character line limit.
  • Both update scripts pass bash -n; git diff --check passes.
  • Live-cluster e2e tests were not run locally.

Does this PR introduce a user-facing change?

Reduce duplicated legacy model conversion helpers in the synchronous and asyncio Python clients, reducing package source, wheel and bytecode sizes.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

[Other doc]: https://github.com/OpenAPITools/openapi-generator/pull/24730

Pin OpenAPI Generator to the merged helper deduplication change and regenerate
both clients from the existing Kubernetes schema. Preserve Kubernetes patches,
add serialization compatibility tests, and make package size comparisons
reproducible.

Related to kubernetes-client#2677.
@kubernetes-prow kubernetes-prow Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels Oct 27, 2026
@linux-foundation-easycla

linux-foundation-easycla Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: Abhinav0905 / name: Kumar Abhinav (58b1868)

@kubernetes-prow

Copy link
Copy Markdown
Contributor

Welcome @Abhinav0905!

It looks like this is your first PR to kubernetes-client/python 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-client/python has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@kubernetes-prow kubernetes-prow Bot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Oct 27, 2026
@kubernetes-prow
kubernetes-prow Bot requested review from roycaihw and yliaog October 27, 2026 20:06
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Abhinav0905
Once this PR has been reviewed and has the lgtm label, please assign roycaihw for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow kubernetes-prow Bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant