Guidance for creating Xarray consumer libraries (supporting flexible array backends, and in general) #10925
Replies: 1 comment 2 replies
-
|
We had a similar challenge in sgkit - how to make sgkit's xarray usage support different parallel backends (Dask and Cubed). The approach we took is summarised here: sgkit-dev/sgkit#908 (comment), but basically
Using Dask via array-api-compat should be array API compliant though - did this not work for you? Also Cubed is array API compliant too, except for some gaps documented at https://github.com/cubed-dev/cubed/blob/main/api_status.md. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Heyall . I have been wanting to make Parcels as an Xarray consuming library be flexible to the array backend (i.e., if we're doing operations it would be great to be able to avoid - for example - calling
np.sumon dask/cupy arrays triggering eager computation or communication between the GPU and CPU.This is a bit of thinking ahead for us as we want to avoid unnecessary Dask computations, support GPU in future (via Cupy), and just generally allow our support for array backends to evolve alongside Xarray.
What would be the best way to do this in Xarray world? I attended the talk from @lucascolley at EuroScipy 2025 talking about the Array API ecosystem - of particular interest being the
array-api-compatlibrary. From my understanding though, this isn't the full picture - partly at least because Dask is not array API compliant dask/dask#10994 (nor is cubed for that matter).I see that there is a
xarray.compat.array_api_compat(a custom file providing an array API compat layer - not to be confused with thearray-api-compatpackage) providing namespacing for Array API compliant packages, but there is stillxarray/core/duck_array_ops.pyto deal with different array types (e.g., for Dask). Hence the following - which I would have expected to returndawhere Dask - doesn't workSo my question is the following:
What is the current approach for making and testing an Xarray consuming library to be flexible to array backend ? Is there a guide on this? Are there such consuming libraries code I can poke around in more to see how they handle things? (tried xdggs, but couldn't find this code) Regarding testing, it would be great to make sure that arrays don't change type unexpectedly
More generally, is there documentation with what considerations to have when creating xarray consuming libraries? (I guess somewhat related is the docs on accessors, are there other things as well?)
Beta Was this translation helpful? Give feedback.
All reactions