Skip to content

Conversation

@jsignell
Copy link
Member

Just tries to add a suggestion about which library to install. @keewis had done something similar for guess_chunkmanager already.

For instance, if you have cubed but not cubed-xarray:

import cubed
import cubed.random

import xarray as xr

t_length = 50
spec = cubed.Spec(allowed_mem="2GB")

u = cubed.random.random((t_length, 1, 987, 1920), chunks=(10, 1, -1, -1), spec=spec)
v = cubed.random.random((t_length, 1, 987, 1920), chunks=(10, 1, -1, -1), spec=spec)

ds = xr.Dataset(
    dict(
        anom_u=(["time", "face", "j", "i"], u),
        anom_v=(["time", "face", "j", "i"], v),
    )
)
result = ds**2
result.compute()

@github-actions github-actions bot added the topic-NamedArray Lightweight version of Variable label Dec 23, 2025
@jsignell jsignell added the topic-chunked-arrays Managing different chunked backends, e.g. dask label Dec 23, 2025
@jsignell jsignell requested a review from keewis January 21, 2026 17:34
Copy link
Collaborator

@keewis keewis left a comment

Choose a reason for hiding this comment

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

looks good to me. I have one stylistic comment, and as mentioned during our chat today we need tests that triggers both suggestions.

For the unknown type we probably need a dummy (something that pretends to implement the relevant protocols, no need to be thorough), and for the known array type it should be fine to only run the test if dask is not installed.

Comment on lines +177 to +181
suggestion = "This is usually the result of a missing dependency."
if (
maybe_lib := type(chunked_arr).__module__.split(".")[0]
) in KNOWN_CHUNKMANAGERS:
suggestion = f"Please try installing {KNOWN_CHUNKMANAGERS[maybe_lib]!r}."
Copy link
Collaborator

Choose a reason for hiding this comment

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

would it make sense to put this in else?

Suggested change
suggestion = "This is usually the result of a missing dependency."
if (
maybe_lib := type(chunked_arr).__module__.split(".")[0]
) in KNOWN_CHUNKMANAGERS:
suggestion = f"Please try installing {KNOWN_CHUNKMANAGERS[maybe_lib]!r}."
if (
maybe_lib := type(chunked_arr).__module__.split(".")[0]
) in KNOWN_CHUNKMANAGERS:
suggestion = f"Please try installing {KNOWN_CHUNKMANAGERS[maybe_lib]!r}."
else:
suggestion = "This is usually the result of a missing dependency."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic-chunked-arrays Managing different chunked backends, e.g. dask topic-NamedArray Lightweight version of Variable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants