Migrate synchronous Python client generation to OpenAPI Generator v7 - #305
Conversation
|
Welcome @tamird! |
f9cf540 to
ad0715f
Compare
ad0715f to
c3b3c7d
Compare
OpenAPI Generator v7 removed python-legacy. Select the modern Python generator with legacy compatibility, independent implicit clients, lazy package imports, and explicit name mappings so the synchronous client keeps its public API without eagerly loading every model and API. Preprocess the Kubernetes Swagger document to preserve exec arguments, port-forward ports, custom-object patch media types, bearer-token aliases, Namespace-delete responses, and the missing GroupVersionKind definition. Namespace deletion can return a Namespace or Status, so leave its successful response as a parsed object instead of validating it against the wrong model. Replace the broad shell rewrites with focused Python post-processing that preserves prose, qualifies package references, accepts Kubernetes IntOrString and CRD JSON-schema unions without invalid coercion, accepts JSON Patch operation lists and generated model instances in PATCH methods, defers eager Pydantic call validators, preserves importlib metadata on lazy packages, and normalizes generated whitespace.
c3b3c7d to
31aa737
Compare
|
@yliaog I guess you need to merge this, yeah? |
|
/assign @yliaog |
yliaog
left a comment
There was a problem hiding this comment.
could you please keep the sync and async commits in separate PR? we can merge the PR for sync client first.
fc5b727 to
d38e3aa
Compare
|
@yliaog Split as requested. This PR is the original synchronous-only 31aa737; the independently master-targeted asyncio generator and its required postprocessing are in #306. GitHub is waiting for a repository maintainer to approve the current generator runs: https://github.com/kubernetes-client/gen/actions/runs/29980454288 and https://github.com/kubernetes-client/gen/actions/runs/29980478522. The exact synchronous commit already has a passing run at https://github.com/kubernetes-client/gen/actions/runs/29936513495. The generated client also needs maintainer approval for validation and real-cluster end-to-end tests: https://github.com/kubernetes-client/python/actions/runs/29979421215 and https://github.com/kubernetes-client/python/actions/runs/29979421210. — tamirdex |
7f74c6d to
31aa737
Compare
|
i took a look at the PR, it looks good. Let's discuss kubernetes-client/python#2631 (comment) |
|
@yliaog The consensus you were waiting for is now explicit in kubernetes-client/python#2631 (comment). The corresponding dependency-free generator fix is OpenAPITools/openapi-generator#24402, and all 25 Python sample checks are passing. Once that fix lands, this synchronous migration can consume it independently of the asynchronous migration in #306. — tamirdex |
|
let's wait for OpenAPITools/openapi-generator#24402 to merge. I think this PR needs modification after it merges. |
|
@yliaog OpenAPITools/openapi-generator#24402 has merged. This PR now pins its exact 830e9d156 source and contains the shared Python schema, discovery, authentication, PATCH, and postprocessing fixes. #306 independently changes only the Kubernetes aio entrypoint and its dedicated XML; both the external python-asyncio.sh and its v6 XML are byte-for-byte unchanged. The regenerated synchronous client is kubernetes-client/python#2652 and the asyncio client is kubernetes-client/python#2647. Each records 7.25.0-SNAPSHOT rather than claiming a release. GitHub requires maintainer approval for the exact generator runs https://github.com/kubernetes-client/gen/actions/runs/30281344413 and https://github.com/kubernetes-client/gen/actions/runs/30281335564, and the client validation and end-to-end runs https://github.com/kubernetes-client/python/actions/runs/30282192543, https://github.com/kubernetes-client/python/actions/runs/30282192475, https://github.com/kubernetes-client/python/actions/runs/30281290930, and https://github.com/kubernetes-client/python/actions/runs/30281291447. Could you approve the runs and review this synchronous generator first? [tamirdex] |
| source "${SCRIPT_ROOT}/openapi-generator/client-generator.sh" | ||
| source "${SETTING_FILE}" | ||
| OPENAPI_GENERATOR_COMMIT="${OPENAPI_GENERATOR_COMMIT:-v7.24.0}" | ||
| OPENAPI_GENERATOR_COMMIT="${OPENAPI_GENERATOR_COMMIT:-830e9d156960bb7f51a5337f31636a7e73226474}" |
There was a problem hiding this comment.
ok for now, later let's change it to v7.25.0
There was a problem hiding this comment.
Agreed. v7.24.0 is still the latest published release, so this currently pins the exact merged upstream commit containing the dependency-free lazy import fix. Once v7.25.0 is actually published, we can replace that immutable commit pin with the release tag and regenerate both clients.
[tamirdex]
| <packageName>${generator.package.name}</packageName> | ||
| <packageVersion>${generator.client.version}</packageVersion> | ||
| <sortParamsByRequiredFlag>true</sortParamsByRequiredFlag> | ||
| <lazyImports>true</lazyImports> |
There was a problem hiding this comment.
Yes. OpenAPI Generator v7 defaults lazyImports to false: https://github.com/OpenAPITools/openapi-generator/blob/830e9d156960bb7f51a5337f31636a7e73226474/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java#L215. OpenAPITools/openapi-generator#24402 replaced the old third-party lazy-imports implementation with the standard library; it did not change that default.
Without this option, importing the client eagerly imports all 768 generated model exports and 65 API exports. Keeping it enabled selects the new dependency-free lazy path, avoiding that startup regression while removing lazy-imports from the distribution.
[tamirdex]
|
could you move this commit to the PR that migrates asyncio? then this PR would focus just on sync client gen. |
d74116f to
6282bad
Compare
|
thanks for the PR /lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: tamird, yliaog The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
fa1b9c8
into
kubernetes-client:master
OpenAPI Generator v7 removed python-legacy, the backend used by the synchronous Kubernetes Python client. OpenAPITools/openapi-generator#24402 introduces standard-library lazy imports, removing the third-party lazy-imports dependency without eagerly importing the generated API and models.
Generate the synchronous client from merged source commit 830e9d156960bb7f51a5337f31636a7e73226474. Centralize the Python schema, discovery, authentication, PATCH, and postprocessing corrections needed by kubernetes-client/python#2652 and the independently proposed asyncio migration in #306.
The pinned generator identifies itself as 7.25.0-SNAPSHOT; 7.25.0 has not been released.