Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions asdf_zarr/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def _iter_chunk_keys(zarray, only_initialized=False):
"""Using zarray metadata iterate over chunk keys"""
if only_initialized:
for k in async_iter_to_list(zarray.store.list()):
if k in (".zarray", ".zattrs"):
if k in (".zarray", ".zattrs", "zarr.json"):
continue
yield k
return
Expand All @@ -37,7 +37,8 @@ def _iter_chunk_keys(zarray, only_initialized=False):

# make blocks and map them to the internal kv store
# compute number of chunks (across all axes)
chunk_counts = [math.ceil(s / c) for (s, c) in zip(zarray_meta["shape"], zarray_meta["chunks"])]
chunk_counts = [math.ceil(s / c) for (s, c) in zip(zarray_meta["shape"],
zarray_meta["chunk_grid"]["configuration"]["chunk_shape"])]

# iterate over all chunk keys
chunk_iter = itertools.product(*[range(c) for c in chunk_counts])
Expand All @@ -59,10 +60,10 @@ def chunk_map_callback(zarray=zarray, chunk_key_block_index_map=chunk_key_block_
chunk_map = numpy.zeros(zarray.cdata_shape, dtype="int32")
chunk_map[:] = MISSING_CHUNK # set all as uninitialized
zarray_meta = zarray.metadata.to_dict()
dimension_separator = zarray_meta.get("dimension_separator", ".")
dimension_separator = zarray_meta.get("dimension_separator", "/")
for k in _iter_chunk_keys(zarray, only_initialized=True):
index = chunk_key_block_index_map[k]
coords = tuple([int(sk) for sk in k.split(dimension_separator)])
coords = tuple([int(sk) for sk in k.split(dimension_separator)[1:]]) # Don't need the leading 'c/'
Copy link
Copy Markdown
Member

@zacharyburnett zacharyburnett Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it ever possible for this to skip data? can the dimension ever start with a coordinate instead of c/?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly I have no idea. I was hoping someone more familiar with the project could tell me. If it turns out it is then obviously I'll make this catch more cases.

chunk_map[coords] = index
return chunk_map

Expand Down Expand Up @@ -164,7 +165,8 @@ def __init__(self, ctx, chunk_block_map_index, zarray_meta, tmp_path=None, read_
# so for a zarray with 4 x 5 chunks (dimension 1
# split into 4 chunks) the chunk_block_map will be
# 4 x 5
cdata_shape = tuple(math.ceil(s / c) for s, c in zip(zarray_meta["shape"], zarray_meta["chunks"]))
cdata_shape = tuple(math.ceil(s / c) for s, c in zip(zarray_meta["shape"],
zarray_meta["chunk_grid"]["configuration"]["chunk_shape"]))
self._chunk_block_map_asdf_key = ctx.generate_block_key()
self._chunk_block_map = numpy.frombuffer(
ctx.get_block_data_callback(chunk_block_map_index, self._chunk_block_map_asdf_key)(), dtype="int32"
Expand Down
Loading