Skip to content

Commit

Permalink
Optimize writes to existing Zarr stores.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dcherian committed Mar 25, 2024
1 parent 7c3d2dd commit eb37aed
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion xarray/backends/zarr.py
Expand Up @@ -623,7 +623,12 @@ def store(
# avoid needing to load index variables into memory.
# TODO: consider making loading indexes lazy again?
existing_vars, _, _ = conventions.decode_cf_variables(
self.get_variables(), self.get_attrs()
{
k: v
for k, v in self.get_variables().items()
if k in existing_variable_names
},
self.get_attrs(),
)
# Modified variables must use the same encoding as the store.
vars_with_encoding = {}
Expand Down

0 comments on commit eb37aed

Please sign in to comment.