Skip to content

Commit eb37aed

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 eb37aed

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

xarray/backends/zarr.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,12 @@ 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: v
628+
for k, v in self.get_variables().items()
629+
if k in existing_variable_names
630+
},
631+
self.get_attrs(),
627632
)
628633
# Modified variables must use the same encoding as the store.
629634
vars_with_encoding = {}

0 commit comments

Comments
 (0)