-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[python-experimental] Quicken package loading #6437
Conversation
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
@sebastien-rosset how does this look to you?
|
Let me try and let you know, thank you for the PR! |
If I import import mypackage If I import import mypackage.all_models Does this answer your question?
Do you mean a codegen CLI option or a configuration parameter in the generated First, the client may be part of a larger application, the part invoking the generated Python SDK may possibly be just a small piece of the entire application. This would mean potentially the generated OpenAPITools python code would change the value in the middle of the application, but isn't this better to set this global parameter at the beginning of the application? BTW, I'm not sure what setrecursionlimit() do exactly, especially in a multi-threaded application, the multi-threading behavior does not seem to be documented. What does this call do for existing threads vs new threads? Everything seems to point that code should be rewritten such that high level of recursion are not needed. Second, the application may already have some code (or may need) to set the recursion limit. So now potentially we would have two separate lines of code setting the recursion limit, not a good idea. If the configuration option is part of the Configuration class, isn't there going to be a chicken-and-egg problem, since the import will fail even before you can access the Configuration class? You could ask users to specifically import the Configuration class then set the recursion limit, but I feel this is very unpythonic and cumbersome. We might as well just document that users should set the recursion limit before the import; or better, somehow prevent the recursion to occur. |
Can you email or slack me an oas document (json or yaml) that demonstrates these recursion depths? It is very strange to me that the package import is triggering such high recursive counts. Suspected reason that we still have high recursive counts:
So the root import is still loading models that the apis use. |
The load time change in loading petstore_api in the v3 samples directory is now:
Next up: checking it with the larger sample spec. |
@sebastien-rosset when I load in the library created with your sample spec, and my improvement to remove the apis from the root of the package I find:
|
Yes, I meant a parameter inside our python Configuration class. Good point, setting that parameter would impact all imports in the program so we probably shouldn't do that. |
TODO:
|
How about editing the `README_common.mustache file? I think users go to the README file first. If the script fails on first import, most likely they would go to README for help, I doubt many users will bother looking elsewhere. If the OpenAPI model is large, the import may fail with an error indicating the maximum recursion limit has been exceeded. import sys
sys.setrecursionlimit(1500)
import {{{packageName}}} |
Note to self:
|
906ef07
to
ec1dc07
Compare
…he package namespace
3f25a51
to
37b5ff9
Compare
Note to self: why are the model imports missing from the operations? |
TODO: update v3 sample model tests to include the sys import |
The drone CI error is unrelated to this change, merging it in |
* master: Update Generate.java (#6515) Undo PR #6451 (#6514) Minor enhancement to Python client generator's code format (#6510) [python-experimental] Quicken package loading (#6437) [Python][Client] Fix delimiter collision issue #5981 (#6451) [Java][Jersey2] add petstore integration tests (#6508) UE4 client generator fixes (#6438) Fix docs typos (#6478) [php-laravel] Show required PHP version in docs (#6502) [php-lumen] Show required PHP version in docs (#6501) [Java][Jersey2] Fix typo and script, Log enhancements, HTTP signature, deserialization (#6476) Remove deprecations 5.0 (#6060)
This PR was written to resolve #6402
In this PR we have:
@sebastien-rosset
The load time change in loading petstore_api in the v3 samples directory is:
Load time should scale directly with memory usage.
When loading the root package we should no longer see the RecursionError
./bin/
(or Windows batch scripts under.\bin\windows
) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run./bin/{LANG}-petstore.sh
,./bin/openapi3/{LANG}-petstore.sh
if updating the code or mustache templates for a language ({LANG}
) (e.g. php, ruby, python, etc).master
,4.3.x
,5.0.x
. Default:master
.Python technical committee:
@taxpon (2017/07) @frol (2017/07) @mbohlool (2017/07) @cbornet (2017/09) @kenjones-cisco (2017/11) @tomplus (2018/10) @Jyhess (2019/01) @arun-nalla (2019/11) @spacether (2019/11)