Skip to content

 zarr.consolidate_metadata

zarr.consolidate_metadata

consolidate_metadata(
    store: StoreLike,
    path: str | None = None,
    zarr_format: ZarrFormat | None = None,
) -> Group

Consolidate the metadata of all nodes in a hierarchy.

Upon completion, the metadata of the root node in the Zarr hierarchy will be updated to include all the metadata of child nodes. For Stores that do not use consolidated metadata, this operation raises a TypeError.

Parameters:

  • store (StoreLike) –

    The store-like object whose metadata you wish to consolidate. See the storage documentation in the user guide for a description of all valid StoreLike values.

  • path (str, default: None ) –

    A path to a group in the store to consolidate at. Only children below that group will be consolidated.

    By default, the root node is used so all the metadata in the store is consolidated.

  • zarr_format ((2, 3, None), default: 2 ) –

    The zarr format of the hierarchy. By default the zarr format is inferred.

Returns:

  • group ( Group ) –

    The group, with the consolidated_metadata field set to include the metadata of each child node. If the Store doesn't support consolidated metadata, this function raises a TypeError. See Store.supports_consolidated_metadata.

Source code in zarr/api/synchronous.py
def consolidate_metadata(
    store: StoreLike,
    path: str | None = None,
    zarr_format: ZarrFormat | None = None,
) -> Group:
    """
    Consolidate the metadata of all nodes in a hierarchy.

    Upon completion, the metadata of the root node in the Zarr hierarchy will be
    updated to include all the metadata of child nodes. For Stores that do
    not use consolidated metadata, this operation raises a `TypeError`.

    Parameters
    ----------
    store : StoreLike
        The store-like object whose metadata you wish to consolidate. See the
        [storage documentation in the user guide][user-guide-store-like]
        for a description of all valid StoreLike values.
    path : str, optional
        A path to a group in the store to consolidate at. Only children
        below that group will be consolidated.

        By default, the root node is used so all the metadata in the
        store is consolidated.
    zarr_format : {2, 3, None}, optional
        The zarr format of the hierarchy. By default the zarr format
        is inferred.

    Returns
    -------
    group: Group
        The group, with the ``consolidated_metadata`` field set to include
        the metadata of each child node. If the Store doesn't support
        consolidated metadata, this function raises a `TypeError`.
        See ``Store.supports_consolidated_metadata``.

    """
    return Group(sync(async_api.consolidate_metadata(store, path=path, zarr_format=zarr_format)))