virtualizarr.accessor.VirtualiZarrDataTreeAccessor.to_icechunk#

VirtualiZarrDataTreeAccessor.to_icechunk(store: IcechunkStore, *, write_inherited_coords: bool = False, last_updated_at: datetime | None = None) None#

Write an xarray DataTree to an Icechunk store.

Any variables backed by ManifestArray objects will be be written as virtual references. Any other variables will be loaded into memory before their binary chunk data is written into the store.

If last_updated_at is provided, it will be used as a checksum for any virtual chunks written to the store with this operation. At read time, if any of the virtual chunks have been updated since this provided datetime, an error will be raised. This protects against reading outdated virtual chunks that have been updated since the last read. When not provided, no check is performed. This value is stored in Icechunk with seconds precision, so be sure to take that into account when providing this value.

Parameters:
  • store – Store to write dataset into.

  • write_inherited_coords – If True, replicate inherited coordinates on all descendant nodes. Otherwise, only write coordinates at the level at which they are originally defined. This saves disk space, but requires opening the full tree to load inherited coordinates.

  • last_updated_at – Datetime to use as a checksum for any virtual chunks written to the store with this operation. When not provided, no check is performed.

Raises:

ValueError – If the store is read-only.

Examples

To ensure an error is raised if the files containing referenced virtual chunks are modified at any time from now on, pass the current time to last_updated_at.

>>> from datetime import datetime
>>> vdt.virtualize.to_icechunk(
...     icechunkstore,
...     last_updated_at=datetime.now(),
... )