-
Notifications
You must be signed in to change notification settings - Fork 529
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
Automate TPL callback registrations #3167
Conversation
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.
Smallest of NFC changes, but it's good besides that.
pyomo/common/dependencies.py
Outdated
|
||
_DeferredImportCallbackFinder = DeferredImportCallbackFinder() | ||
# Insert the DeferredImportCallbackFinder at the beginning of the | ||
# sys.meta_path to that it is found before the standard finders (so that |
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.
# sys.meta_path to that it is found before the standard finders (so that | |
# sys.meta_path so that it is found before the standard finders (so that |
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.
I found one typo but otherwise this looks great
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3167 +/- ##
==========================================
+ Coverage 88.38% 88.44% +0.06%
==========================================
Files 846 846
Lines 94857 95473 +616
==========================================
+ Hits 83835 84443 +608
- Misses 11022 11030 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Fixes IDAES/idaes-pse#1348
Summary/Motivation:
This PR updates how we handle registration of
numpy
types as native numeric types. This updates theattempt_import
machinery to hook into Python's regularimportlib
process. Now deferred import modules with callbacks (includingnumpy
) are registered with a custom module finder that ensures that if they are imported (even by code outside of Pyomo), the post-import callback is triggered.Changes proposed in this PR:
DeferredImportCallbackFinder
/DeferredImportCallbackLoader
to hook intoimportlib
and endure deferred import modules with callbacks always have their callbacks calledattempt_import(defer_check=
toattempt_import(defer_import=
attempt_import
will immediately process modules that have already been importedLegal Acknowledgement
By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution: