Skip to content

 zarr.open_group

zarr.open_group

open_group(
    store: StoreLike | None = None,
    *,
    mode: AccessModeLiteral = "a",
    cache_attrs: bool | None = None,
    synchronizer: Any = None,
    path: str | None = None,
    chunk_store: StoreLike | None = None,
    storage_options: dict[str, Any] | None = None,
    zarr_format: ZarrFormat | None = None,
    meta_array: Any | None = None,
    attributes: dict[str, JSON] | None = None,
    use_consolidated: bool | str | None = None,
) -> Group

Open a group using file-mode-like semantics.

Parameters:

  • store (StoreLike or None, default: None ) –

    StoreLike object to open. See the storage documentation in the user guide for a description of all valid StoreLike values.

  • mode (('r', 'r+', 'a', 'w', 'w-'), default: 'r' ) –

    Persistence mode: 'r' means read only (must exist); 'r+' means read/write (must exist); 'a' means read/write (create if doesn't exist); 'w' means create (overwrite if exists); 'w-' means create (fail if exists).

  • cache_attrs (bool, default: None ) –

    If True (default), user attributes will be cached for attribute read operations. If False, user attributes are reloaded from the store prior to all attribute read operations.

  • synchronizer (object, default: None ) –

    Array synchronizer.

  • path (str, default: None ) –

    Group path within store.

  • chunk_store (StoreLike or None, default: None ) –

    Separate storage for chunks. See the storage documentation in the user guide for a description of all valid StoreLike values.

  • storage_options (dict, default: None ) –

    If using an fsspec URL to create the store, these will be passed to the backend implementation. Ignored otherwise.

  • meta_array (array - like, default: None ) –

    An array instance to use for determining arrays to create and return to users. Use numpy.empty(()) by default.

  • attributes (dict, default: None ) –

    A dictionary of JSON-serializable values with user-defined attributes.

  • use_consolidated (bool or str, default: None ) –

    Whether to use consolidated metadata.

    By default, consolidated metadata is used if it's present in the store (in the zarr.json for Zarr format 3 and in the .zmetadata file for Zarr format 2).

    To explicitly require consolidated metadata, set use_consolidated=True, which will raise an exception if consolidated metadata is not found.

    To explicitly not use consolidated metadata, set use_consolidated=False, which will fall back to using the regular, non consolidated metadata.

    Zarr format 2 allowed configuring the key storing the consolidated metadata (.zmetadata by default). Specify the custom key as use_consolidated to load consolidated metadata from a non-default key.

Returns:

  • g ( Group ) –

    The new group.

Source code in zarr/api/synchronous.py
def open_group(
    store: StoreLike | None = None,
    *,
    mode: AccessModeLiteral = "a",
    cache_attrs: bool | None = None,  # default changed, not used in async api
    synchronizer: Any = None,  # not used in async api
    path: str | None = None,
    chunk_store: StoreLike | None = None,  # not used in async api
    storage_options: dict[str, Any] | None = None,  # not used in async api
    zarr_format: ZarrFormat | None = None,
    meta_array: Any | None = None,  # not used in async api
    attributes: dict[str, JSON] | None = None,
    use_consolidated: bool | str | None = None,
) -> Group:
    """Open a group using file-mode-like semantics.

    Parameters
    ----------
    store : StoreLike or None, default=None
        StoreLike object to open. See the
        [storage documentation in the user guide][user-guide-store-like]
        for a description of all valid StoreLike values.
    mode : {'r', 'r+', 'a', 'w', 'w-'}, optional
        Persistence mode: 'r' means read only (must exist); 'r+' means
        read/write (must exist); 'a' means read/write (create if doesn't
        exist); 'w' means create (overwrite if exists); 'w-' means create
        (fail if exists).
    cache_attrs : bool, optional
        If True (default), user attributes will be cached for attribute read
        operations. If False, user attributes are reloaded from the store prior
        to all attribute read operations.
    synchronizer : object, optional
        Array synchronizer.
    path : str, optional
        Group path within store.
    chunk_store : StoreLike or None, default=None
        Separate storage for chunks. See the
        [storage documentation in the user guide][user-guide-store-like]
        for a description of all valid StoreLike values.
    storage_options : dict
        If using an fsspec URL to create the store, these will be passed to
        the backend implementation. Ignored otherwise.
    meta_array : array-like, optional
        An array instance to use for determining arrays to create and return
        to users. Use `numpy.empty(())` by default.
    attributes : dict
        A dictionary of JSON-serializable values with user-defined attributes.
    use_consolidated : bool or str, default None
        Whether to use consolidated metadata.

        By default, consolidated metadata is used if it's present in the
        store (in the ``zarr.json`` for Zarr format 3 and in the ``.zmetadata`` file
        for Zarr format 2).

        To explicitly require consolidated metadata, set ``use_consolidated=True``,
        which will raise an exception if consolidated metadata is not found.

        To explicitly *not* use consolidated metadata, set ``use_consolidated=False``,
        which will fall back to using the regular, non consolidated metadata.

        Zarr format 2 allowed configuring the key storing the consolidated metadata
        (``.zmetadata`` by default). Specify the custom key as ``use_consolidated``
        to load consolidated metadata from a non-default key.

    Returns
    -------
    g : Group
        The new group.
    """
    return Group(
        sync(
            async_api.open_group(
                store=store,
                mode=mode,
                cache_attrs=cache_attrs,
                synchronizer=synchronizer,
                path=path,
                chunk_store=chunk_store,
                storage_options=storage_options,
                zarr_format=zarr_format,
                meta_array=meta_array,
                attributes=attributes,
                use_consolidated=use_consolidated,
            )
        )
    )