dsavransky / EXOSIMS

Simulator for exoplanet direct imaging space missions
BSD 3-Clause "New" or "Revised" License
26 stars 40 forks source link

Make getmodule failures more transparent when error lies in actually importing a found module #321

Open dsavransky opened 1 year ago

dsavransky commented 1 year ago

Describe the bug Some details courtesy of @turmon:

Bug trigger: utils.getmodule() is importing a named Exosims module (“BrownCompleteness”) The module in turn has imports, e.g. import urllib3 One of these imports fails The resulting error message (“could not load urllib3”) is suppressed by a try/catch block Suppression of the actual error message is quite frustrating and masks the root cause of the problem See around line 97 of get_module.py … note that we don’t want to merely “raise” there (unconditionally), because it’s OK to fail some imports…perhaps we want to peek at the reason the import failed, and raise if the reason is not a possibly-expected one (module X not found, where we know what X is – urllib3 is NOT an expected import fail).