Skip to content

Improve error message when Dask is not installed #349

@corrado9999

Description

@corrado9999

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    daskDask related issue.proposalIdea for a new feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions