Improve error handling on importing modules for GAMMA #325
Description
I'm still working through getting pyroSAR working with our GAMMA installation. One thing I've noticed is that despite having DISP in the GAMMA directory, pyroSAR hasn't created a module for it in my ~/.pyrosar/gammaparse
folder (I have yet to investigate this further). As such, I'm getting non-intuitive errors when trying to use the GAMMA functions.
Specifically, I believe this is because the error handling on the import statement in the GAMMA utils python file is failing silently:
try:
from .api import diff, disp, isp, lat
except ImportError:
pass
I confirmed this by running from pyroSAR.gamma.api import diff, disp, isp, lat
, which produces
ImportError: cannot import name 'disp' from 'pyroSAR.gamma.api'
confirming that the disp module is the issue. However, this means that isp
never gets imported, and future calls to isp
fail, even if disp is not required (which is the case for convert2gamma
). I confirmed this by running from pyroSAR.gamma.api import diff, isp, lat
which works correctly, allowing me to run dir(isp)
and see the module contents.
I believe this is related to #85 -- my enhancement suggestion would be to catch each module import error and let the user know which module failed to import. That way, they can at least be pointed to the problematic module, rather than one that is working (but appears later in the import list).
-
which operating system are you using?
Rocky Linux release 8.10 (Green Obsidian) -
which environment is pyroSAR running in?
Micromamba environment -
which version of pyroSAR are you using?
conda forge (pyrosar=0.23.0 in environment.yml file) -
which function of pyroSAR did you call with which parameters?
convert2gamma