Skip to content

Conversation

ThorstenGroh
Copy link

Hey, thanks for the nice work here.

I would like to send xarray objects via RPC, but sipyco was missing a decoder/encoder for xarray objects (xarray.pydata.org/). Xarray DataArray and Dataset objects have a to_dict method, that can be easily used to transform the object to something serializable (one however needs to bypass the conversion of numpy objects to lists).

Let me know if this is within the interest of this package and how to proceed.

I added the necessary encode and decode methods and a unittest. Is there anything else to do?

Best regards
Thorsten

@ThorstenGroh ThorstenGroh changed the title Added xarray object encoding and decoding. pyon: Add xarray object encoding and decoding. Mar 2, 2022
@sbourdeauducq
Copy link
Member

We don't want to add a mandatory dependency on xarray.

There would be several ways to address this:

  • handle ImportError and disable the corresponding functionality accordingly.
  • add a with_xarray parameter and import xarray dynamically.
  • a plug-in system, though PYON: add plugin support #22 is overly complicated. Simply extending the handlers using some dictionary or class passed to encode/decode would be better. Then the plugin could be integrated into sipyco.

@jordens
Copy link
Member

jordens commented Jul 7, 2025

#64 adds a plugin interface. feel free to revise this PR for optional xarray support.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants