Skip to content
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

Improve error message when Dask is not installed #349

Open
corrado9999 opened this issue May 25, 2021 · 1 comment
Open

Improve error message when Dask is not installed #349

corrado9999 opened this issue May 25, 2021 · 1 comment
Labels
dask Dask related issue. proposal Idea for a new feature.

Comments

@corrado9999
Copy link

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.

@corrado9999 corrado9999 added the proposal Idea for a new feature. label May 25, 2021
@snowman2
Copy link
Member

This is currently how xarray handles the optional dask dependency as well:

It would be good to keep this consistent. What do you propose?

@snowman2 snowman2 added the dask Dask related issue. label Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dask Dask related issue. proposal Idea for a new feature.
Projects
None yet
Development

No branches or pull requests

2 participants