-
Notifications
You must be signed in to change notification settings - Fork 247
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
Cleaning up Python module import infrastructure #3608
Conversation
import inspect | ||
caller = inspect.stack()[1] # Information about the file that imported this, to check for unexpected imports | ||
application_importer.ImportApplication(application,application_name,application_folder,caller) | ||
KM._ImportApplicationAsModule(application, application_name, application_folder, __path__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note that we ported the MappingApp right away to see how it is being used
@KratosMultiphysics/technical-committee it would be nice to have this asap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KratosMultiphysics/technical-committee approves the cleanup but let put on hold the optional part to maintain the backward compatibility
@KratosMultiphysics/technical-committee just to clarify: The big apps already now support both ways (the later one for backwards compatibility) Only new apps will use right away the new/correct/pythonic import system. There we don't need backwards-compatibility bcs there is no "old" way From a user-point of view we already now use the "new" way for old and new apps |
Now that #3586 is merged, the Python import infrastructure can be greatly simplified. This PR cleans up some of the darker things going on when an application is loaded. We have also taken the occasion to finally remove the old
application_importer
, which has been deprecated for 7 years now...This PR is 100% backwards compatible but it also introduces a "more Pythonic" module import function
_ImportApplicationAsModule
. This one is optional but, if application developers choose to use it in their application's__init__
instead the current one, it does not add the application#spython_scripts
folder to the python path. This means that python scripts would have to be imported relative to the applicationThis allows Kratos applications to work like native python submodules but, since it would break current scripts, it is not enabled by default.