Skip to content

Commit 9bc43dd

Browse files
committed
Optimize writes to existing Zarr stores.
We need to read existing variables to make sure we append or write to a region with the right encoding. Currently we request all arrays in a Zarr group. Instead only request those arrays for which we require encoding information.
1 parent 7c3d2dd commit 9bc43dd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

xarray/backends/zarr.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,11 @@ def store(
623623
# avoid needing to load index variables into memory.
624624
# TODO: consider making loading indexes lazy again?
625625
existing_vars, _, _ = conventions.decode_cf_variables(
626-
self.get_variables(), self.get_attrs()
626+
{
627+
k: self.open_store_variable(k, self.zarr_group[k])
628+
for k in existing_variable_names
629+
},
630+
self.get_attrs(),
627631
)
628632
# Modified variables must use the same encoding as the store.
629633
vars_with_encoding = {}

0 commit comments

Comments
 (0)