Skip to content

Suggest installing dask when not discovered by ChunkManager #7963

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ Documentation
- Added examples to docstrings of :py:meth:`Dataset.isel`, :py:meth:`Dataset.reduce`, :py:meth:`Dataset.argmin`,
:py:meth:`Dataset.argmax` (:issue:`6793`, :pull:`7881`)
By `Harshitha <https://github.com/harshitha1201>`_ .

- Error message when dask not installed clarified - now suggests user installs dask.
(:issue:`7962`, :pull:`7963`) By `Tom Nicholas <https://github.com/TomNicholas>`_.

Internal Changes
~~~~~~~~~~~~~~~~
Expand Down
3 changes: 2 additions & 1 deletion xarray/core/parallelcompat.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ def get_chunked_array_type(*args) -> ChunkManagerEntrypoint:
if chunkmanager.is_chunked_array(chunked_arr)
]
if not selected:
possible_missing_package_name = type(chunked_arr).__module__.split(".")[0]
raise TypeError(
Copy link
Member

@andersy005 andersy005 Oct 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

considering that the error is actually caused by a missing package, could we consider

  • using a more general exception, such as ModuleNotFoundError, instead of the current TypeError?
  • or implementing a custom exception specifically for this purpose?

f"Could not find a Chunk Manager which recognises type {type(chunked_arr)}"
f"Could not find a Chunk Manager which recognises type {type(chunked_arr)}. Try installing the {possible_missing_package_name} package."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f"Could not find a Chunk Manager which recognises type {type(chunked_arr)}. Try installing the {possible_missing_package_name} package."
f"Could not find a Chunk Manager which recognises type {type(chunked_arr)}. Try searching for and installing a {possible_missing_package_name}_xarray package."

? Since you could have cubed installed but not cubed-xarray

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point, but then would that be more confusing if the problem is that the user doesn't have Dask installed? Because then it would point them towards a non-existent dask_xarray package...

)
elif len(selected) >= 2:
raise TypeError(f"Multiple ChunkManagers recognise type {type(chunked_arr)}")
Expand Down