-
Notifications
You must be signed in to change notification settings - Fork 108
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
Homogenize imports of optional libraries #430
Comments
Nice, I think this is definitely something we should tackle. With respect to the "double import", nothing to worry about since Python does not actually import it twice. It just skips it. To actually reimport a module one has to One thing, this pattern of try, import devito, otherwise devito = None triggers errors with mypy. One technique is described here, basically using global bools to keep track. So all in all I do agree with the design, but I would suggest skipping the |
Great, I wasn't aware about the double import thingy :) Alright, good point about the None. I actually believe that in most places we never effectively do checks of the form |
See PyLops#430 for details.
This is currently not implemented in kirchhoff and lsm |
* WIP: reduce memory footprint of Kirchhoff operator * WIP: added matvec with dynamic * feature: added _ampsrcrec methods * minor: homogenize variable names in kirchhoff methods * minor: handled remaining in #430 * doc: fix outputs of _traveltime_table
Motivation
In PyLops, we have an increasing number of optional dependencies. For these dependencies 2 import patters have started to emerge:
backend.py
module with availability check performed indeps.py
Proposed solution
*_enabled
variables for all other optional dependences indeps.py
*_import
for each optional dependences indeps.py
that parses error messages during imports of those optional dependencies. This function looks like this (eg for devito):and use it in combination with
*_enabled
when import this library, eg:instead of the old way
So far the only downside I see for the new version is that a library gets imported twice instead ones. Is that a big deal?
Opinions?
The text was updated successfully, but these errors were encountered: