Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[BUG][PYTHON] Import performance regression #19635

Open
3 of 6 tasks
bachorp opened this issue Sep 21, 2024 · 0 comments
Open
3 of 6 tasks

[BUG][PYTHON] Import performance regression #19635

bachorp opened this issue Sep 21, 2024 · 0 comments

Comments

@bachorp
Copy link
Contributor

bachorp commented Sep 21, 2024

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-spec

Steps to reproduce

import openapi_client

Related issues/PRs

#18144 also concerns import performance but points at __init__.py.

Suggest a fix

Reinstate some sort of lazy importing.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant