Use lazy imports for generated client #67
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The auto-generated client is pretty large and importing the DefaultApi pulls in the data for all endpoints, so the load time is pretty high:
Previously, we had an unconditional import of the default_api module in the main nethsm module so that loading the nethsm module caused a significant delay in pynitrokey even if it is not used at all:
This patch changes the main nethsm module to only import the generated types if they are actually needed, reducing the load time significantly:
Further improvements could probably be achieved by using the endpoint classes directly instead of DefaultApi, but this is a less pressing issue as it only occurs if the client is actually used and performing the request introduces an additional delay.