Skip to content

Consolidated Metadata Not Passed Down #3954

Closed

Description

@ilan-gold

Zarr version

3.2.1

Numcodecs version

0.16.5

Python Version

3.12

Operating System

Mac

Installation

pip

Description

Consolidated Metadata does not get passed down fully despite being advertised as With nested groups, the consolidated metadata is available on the children, recursively: https://zarr.readthedocs.io/en/latest/user-guide/consolidated_metadata/#usage

Steps to reproduce

# /// script
# requires-python = ">=3.12"
# dependencies = [
#   "zarr[remote]@git+https://github.com/zarr-developers/zarr-python.git@main",
# ]
# ///
#
# This script automatically imports the development branch of zarr to check for issues

import zarr
z = zarr.open_consolidated(zarr.storage.FsspecStore.from_url("https://vitessce-demo-data.storage.googleapis.com/anndata-demos/BALF_VIB-UGent_processed_cleaned.zarr/", read_only=True), mode="r")
assert z["raw"].metadata.consolidated_metadata is not None # passes
assert z["raw"]["varm"].metadata.consolidated_metadata is not None # fails

Additional output

No response

Activity

  1. added
    bugPotential issues with the zarr-python library
    on May 7, 2026
  2. d-v-b commented on May 10, 2026

    @d-v-b
    Contributor

    With nested groups, the consolidated metadata is available on the children, recursively

    I think this is meant to describe zarr-python's behavior when writing consolidated metadata. What you are observing is data where consolidated metadata was not written to the subgroups.

  3. ilan-gold commented on May 11, 2026

    @ilan-gold
    ContributorAuthor

    Could you elaborate a bit? In the following example, I don't see any consolidated metadata written to disk at the subgroups but it is present on the in-memory data when read back in, which is what I would expect given the description of the behavior:

    # /// script
    # requires-python = ">=3.12"
    # dependencies = [
    #   "zarr@git+https://github.com/zarr-developers/zarr-python.git@main",
    # ]
    # ///
    #
    # This script automatically imports the development branch of zarr to check for issues
    
    from __future__ import annotations
    
    import json
    
    import numpy as np
    import zarr
    
    z = zarr.open("foo.zarr", mode="w")
    z.create_group("bar")
    z["bar"].create_group("fuzz")
    z["bar"]["fuzz"].create_group("bazz")
    z["bar"]["fuzz"]["bazz"] = np.arange(5)
    zarr.consolidate_metadata(z.store)
    
    z = zarr.open("foo.zarr", mode="r")
    assert z["bar"]["fuzz"].metadata.consolidated_metadata is not None  # works
    with open("foo.zarr/bar/zarr.json") as f:
        print(json.loads(f.read())) # does not contain metadata i.e., at the next group down

    I think it's possible this is a v2 problem since the original store is v2 only!

  4. d-v-b commented on May 11, 2026

    @d-v-b
    Contributor

    the v2 thing seems explanatory, but I'm not sure that it makes sense. Evidently I don't know the consolidated metadata semantics very well! maybe @TomAugspurger can explain better how things should work.

  5. TomAugspurger commented on May 11, 2026

    @TomAugspurger
    Contributor

    IIUC, this is behaving as intended, at least as I understood it. Consolidating metadata takes all the metadata at and under a point in the tree and consolidates it to a single metadata document, which is written to disk. But you need to access it from that consolidation point to use it.

    I don't think we would want to write out multiple consolidated metadata documents, one at each node in the tree... Though I see how the asymmetry between zarr.open_consolidate(store)["path/to/group"] and zarr.open(store, path="path/to/group") is jarring.

  6. TomAugspurger commented on May 11, 2026

    @TomAugspurger
    Contributor

    With respect to

    With nested groups, the consolidated metadata is available on the children, recursively

    I'm not sure if I wrote that or not, but in my reading that's making a statement about the in-memory metadata (.metadata.consolidated_metadata) rather than the representation on disk.

  7. ilan-gold commented on May 11, 2026

    @ilan-gold
    ContributorAuthor

    I'm not sure if I wrote that or not, but in my reading that's making a statement about the in-memory metadata (.metadata.consolidated_metadata) rather than the representation on disk.

    This was my impression as well (same with the on-disk, doesn't make sense to write it all out)

  8. TomAugspurger commented on May 11, 2026

    @TomAugspurger
    Contributor

    Sorry, I'm just now looking at the original post more closely, and this definitely looks like a bug

    (Pdb) pp z["raw"]["varm"].metadata.consolidated_metadata

    I'll take a closer look today.

  9. ilan-gold commented on May 11, 2026

    @ilan-gold
    ContributorAuthor

    Thanks!

  10. TomAugspurger commented on May 12, 2026

    @TomAugspurger
    Contributor

    See #3967

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPotential issues with the zarr-python library

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions