write
write(
self ,
spool ,
resource: UPath ,
encoding: dict | None[<class ’dict, None] = None,
append: bool | str[bool, str] = False,
**kwargs ,
)
Write a spool to a zarr store, replacing any store there by default.
One patch is written at the store root. Several are written one group each, named by get_patch_names with “/” replaced by “_” and repeats suffixed __1, __2, … as DASDAE does; one patch is held in memory at a time.
The store is built beside resource and moved into place once complete, so a failed write leaves the previous store intact. On object storage the move is a copy, so it is not atomic.
Parameters
| Parameter | Description |
|---|---|
| encoding |
Passed to xarray’s Dataset.to_zarr, e.g.{"data": {"chunks": (100, 1000), "shards": (100, 10000)}};shards needs zarr format 3. Not used to extend a patch, whosearrays keep their own. |
| append |
False (the default) replaces the store. True adds to it, in its own zarr format and without rewriting it: each patch becomes a new group, named as above and not yet taken. A dimension name, such as "time", also extends: a patch which continues astored patch along it (the same kind, data units, dimensions, dtype and other coordinates, its labels starting one step after the stored ones end) extends that patch, its chunks written before its shape so readers never see a part written; a patch continuing none (after a gap, or of another kind) is added as a new group. One which could continue several, or which DASCore cannot extend whole, raises. With no store at the path, a store is written, as for False. |
Adding ends by consolidating the store’s metadata, which DASCore readers list groups from and a spool’s index watches, so Spool.update sees the new content and a reader sees none of it before then.