-
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
Changing how optional dependencies are import state are checked #551
Conversation
Hi @alex-rakowski, I have one main comment:
I personally, believe that we should just make 2 new functions called
This way we will not change the entire logic of what has worked for long time, and still get around the And a couple of minor comments:
|
This reverts commit 06534b1.
Thanks! The docstring is better now :) I'll wait to hear from @cako regarding my concerns and then we can agree all together what is the best way forward. |
Thanks for the issue and the patch @alex-rakowski. The way I see it, since I see a few options in handling this:
I'm personally not a huge fan of catering to faulty installs. Someone with a faulty install but with a GPU may be confused why PyLops doesnt complain about import Regarding the FFT issue, that's a great catch. Upon further investigation, whereas For bookkeeping though, I would agree with @mrava87 that this would be better suited in another PR. |
Thanks @cako for your thought! Just to be clear, what I am saying is that right now we have a slight different approach for cupy/cusignal than for all the other optional dependencies:
and we use
and
If I remember correctly, the need to introduce the env variable So to your points: 1 . we already use |
Now, this is the main reason for having a 2 steps strategy:
So when you do |
Just to check, it seems that the proposed solution is to keep the |
Correct, this is my suggestion. @cako ? |
That sounds like the ideal solution to me as well! |
@alex-rakowski, just checking that it is clear from your end that we are waiting for you to adapt your code based on the agreed solution... no rush from our end though, happy to handle this at any time :) |
I believe this is ready and matches the behavior described above. I've checked locally and on Google Colab which now imports, and the I tested the behavior with the following: !pip install git+https://github.com/alex-rakowski/pylops.git@optional-depends-checker > /dev/null
import pylops
print()
states_to_check = [
"cupy_enabled",
"cusignal_enabled",
"devito_enabled",
"numba_enabled",
"pyfftw_enabled",
"pywt_enabled",
"skfmm_enabled",
"spgl1_enabled",
"sympy_enabled",
"torch_enabled",
]
for state in states_to_check:
s = getattr(pylops.utils, state)
print(f"{state}: {s}") On the CPU runtime, which is the environment with Cupy installed but no GPU, it prints an error on |
Thanks! I'll get back to this later this week and let you know if I have any question :) |
LGTM. @mrava87 I'll leave it to you to merge if you approve as well! |
I’m looking into it, as I found a few typos and a couple of things I want to test before merging… hopefully it will be ready by the end of the week :) |
This PR changes how optional dependencies import states are checked, to address #548. Importing on Colab now works without requiring adding
os.envion["CUPY_PYLOPS] = "0"
. Instead of usingimportlib.util.find_spec
to get state, this usesimportlib.import_module
in atry/except
block.I changed
np.float128
andnp.complex256
tonp.longdouble
andnp.clongdouble
intest_fft.py
to run tests on my local mac. Tests are passing on linux machine, and on mac (with the exception of the 7 mentioned in #550). I can revert these changes if desired.