I've tried to use the latest version of OpenAPI generator to generate the library. That version uses Pydantic2 to generate models. Unfortunately kubernetes library contains ~600 models/api and loading time (at startup) is huge and not acceptable, especially for scripts, long running applications import modules once so it's not so painful. I tried to replace imports with lazy imports as a workaround but it's still 10 time worse in compare with current version using old generator.
My tests:
- kubectl, local cluster (as a reference), get pods (9) from all namespaces - 0.12 sec
- this library, current version, example1.py to list pods - 0.50 sec
- OpenAPIGenerator v 7.0.1, example1.py - 17.26 sec
- OpenAPIGenerator like above with some lazy imports (for models, apis) - 5.22 sec
The problem is known and may be resolved in the future: pydantic/pydantic#6748
For now I' m going to switch to the version just before Pydantic. It helps to resolve some pending issues, and this issue is for tracking ideas or attempts for future upgrades.
I've tried to use the latest version of OpenAPI generator to generate the library. That version uses Pydantic2 to generate models. Unfortunately kubernetes library contains ~600 models/api and loading time (at startup) is huge and not acceptable, especially for scripts, long running applications import modules once so it's not so painful. I tried to replace imports with lazy imports as a workaround but it's still 10 time worse in compare with current version using old generator.
My tests:
The problem is known and may be resolved in the future: pydantic/pydantic#6748
For now I' m going to switch to the version just before Pydantic. It helps to resolve some pending issues, and this issue is for tracking ideas or attempts for future upgrades.