Improve error message when Dask is not installed
If I understood it correctly, Dask is not currently a dependency because it is needed only if chunking is explicitly required. Unfortunately, it looks like no check is performed when chunks is passed, leading to an error message like this:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
[...]
~\miniconda3\envs\env\lib\site-packages\rioxarray\_io.py in open_rasterio(filename, parse_coordinates, chunks, cache, lock, masked, mask_and_scale, variable, group, default_name, **open_kwargs)
863
864 if chunks is not None:
--> 865 result = _prepare_dask(result, riods, filename, chunks)
866
867 # Make the file closeable
~\miniconda3\envs\env\lib\site-packages\rioxarray\_io.py in _prepare_dask(result, riods, filename, chunks)
573 """
574 # pylint: disable=import-outside-toplevel
--> 575 from dask.base import tokenize
576
577 # augment the token with the file modification time
ModuleNotFoundError: No module named 'dask'
Probably an explicit check (try-except?) on dask could be added to improve the error message?
We encountered this "problem" in bopen/xarray-sentinel/issues/50, and we could wrap rioxarray error message there, but we feel this could be a better place to put such check. If wanted/appreciated, I am willing to submit a PR.
This is currently how xarray handles the optional dask dependency as well:
It would be good to keep this consistent. What do you propose?