-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Using a generated python client can be very costly with regard to import performance. For the (quite large) API-spec linked below, importing the generated client module takes ~8s and ~500MB of memory on my M1 macbook.
This issue could not be observed for versions before v7.0.0 (I tested v6.0.0 in particular) and likely is related to the switch to the pydantic generator in v7.0.0 which does not perform lazy importing (previously introduced in ee0686e) such that the (potentially quite large) module will be loaded in its entirety.
openapi-generator version
v7.8.0. Suspected to be a regression introduced in v7.0.0. Not an issue in v6.0.0.
OpenAPI declaration file content or url
kubernetes-release-1.31.swagger.json
Generation Details
openapi-generator-cli generate -i kubernetes-release-1.31.swagger.json -g python --skip-validate-specSteps to reproduce
import openapi_clientRelated issues/PRs
#18144 also concerns import performance but points at __init__.py.
Suggest a fix
Reinstate some sort of lazy importing.