VirtualiZarr icon indicating copy to clipboard operation
VirtualiZarr copied to clipboard

Unable to provide `decode_timedelta` to open_virtual_dataset

Open jbusecke opened this issue 5 months ago • 4 comments

I just refactored some code to use v2 of virtualizarr and with that probably updated my xarray dependencies too.

I am now getting:

[/home/jovyan/mursst-icechunk-updater/.venv/lib/python3.12/site-packages/virtualizarr/xarray.py:341](https://hub.openveda.cloud/user/jbusecke/lab/tree/mursst-icechunk-updater/notebooks/mursst-icechunk-updater/.venv/lib/python3.12/site-packages/virtualizarr/xarray.py#line=340): FutureWarning: In a future version, xarray will not decode timedelta values based on the presence of a timedelta-like units attribute by default. Instead it will rely on the presence of a timedelta64 dtype attribute, which is now xarray's default way of encoding timedelta64 values. To continue decoding timedeltas based on the presence of a timedelta-like units attribute, users will need to explicitly opt-in by passing True or CFTimedeltaCoder(decode_via_units=True) to decode_timedelta. To silence this warning, set decode_timedelta to True, False, or a 'CFTimedeltaCoder' instance.

I tried to provide the argument as suggested by the warning

open_virtual_mfdataset(..., decode_timedelta=True)

but that kwarg is not accepted in the open_virtual_dataset function. Should that be added as an explicit kwarg here? Or should we pass arbitrary kwargs to the xr.open_zarr() call?

Id be happy to work on a PR for this, but wanted to first get a rough idea if I am on the right path.

Happy to provide a MRE if needed, this was just a fairly elaborate workflow, and I wanted to make some more progress.

jbusecke avatar Jul 29 '25 20:07 jbusecke

Should that be added as an explicit kwarg here? Or should we pass arbitrary kwargs to the xr.open_zarr() call?

I guess we might need to do that yes. We basically just inherit the complexity of xarray here.

TomNicholas avatar Jul 29 '25 22:07 TomNicholas

Happy to work on this. Would you prefer to keep things explicit by just adding keywords or catching arbitrary kwargs and passing them on (letting xr.open_zarr deal with whether they work or not)?

jbusecke avatar Jul 31 '25 14:07 jbusecke

Happy to work on this. Would you prefer to keep things explicit by just adding keywords or catching arbitrary kwargs and passing them on (letting xr.open_zarr deal with whether they work or not)?

I'm pretty strongly in favor of adding keywords because pass-through kwargs make for more confusing errors and make autocompletion/linters less effective.

maxrjones avatar Aug 07 '25 22:08 maxrjones

Took a swing at it in https://github.com/zarr-developers/VirtualiZarr/pull/800, still a WIP, but there are some open questions that I would love to get some input on.

jbusecke avatar Sep 22 '25 20:09 jbusecke