mcgibbon / sympl

A toolkit for building planetary/Earth system models in Python
http://sympl.readthedocs.io
Other
50 stars 14 forks source link

NetcdfMonitor errors with unhelpful message #40

Closed JoyMonteiro closed 6 years ago

JoyMonteiro commented 6 years ago

If netcdf4 is not installed, the definition of the NetCDFMonitor class is different, and __init__ takes different keyword arguments. Therefore, if you try to instantiate this monitor with keyword arguments that should work if netcdf4 is installed, __init__ errors saying these arguments are invalid.

This error does not point to the issue the netcdf4 is not present. The simplest option would be to not define a different class when netcdf4 is not present, but rather provide an informative error asking users to install it.

mcgibbon commented 6 years ago

Fixed in the latest push to develop. There is no longer a dummy component, instead the real component will raise a DependencyError.

Printing the error on __init__ instead of on module load has the advantage that this error is only shown to people who are trying to use NetCDFMonitor, and is only shown to them at the point when they are trying to use it, and is shown in a very loud and obnoxious way that they won't miss or misunderstand (an exception). Printing an error message can easily be ignored, then the user is left to wonder why they can't from sympl import NetCDFMonitor.

JoyMonteiro commented 6 years ago

sounds great!