MCPcopy Create free account
hub / github.com/dask/dask / from_zarr

Function from_zarr

dask/array/core.py:3732–3789  ·  view source on GitHub ↗

Load array from the zarr storage format See https://zarr.readthedocs.io for details about the format. Parameters ---------- url: Zarr Array or str or MutableMapping Location of the data. A URL can include a protocol specifier like s3:// for remote data. Can also be

(
    url,
    component=None,
    storage_options=None,
    chunks=None,
    name=None,
    inline_array=False,
    **kwargs,
)

Source from the content-addressed store, hash-verified

3730
3731
3732def from_zarr(
3733 url,
3734 component=None,
3735 storage_options=None,
3736 chunks=None,
3737 name=None,
3738 inline_array=False,
3739 **kwargs,
3740):
3741 """Load array from the zarr storage format
3742
3743 See https://zarr.readthedocs.io for details about the format.
3744
3745 Parameters
3746 ----------
3747 url: Zarr Array or str or MutableMapping
3748 Location of the data. A URL can include a protocol specifier like s3://
3749 for remote data. Can also be any MutableMapping instance, which should
3750 be serializable if used in multiple processes.
3751 component: str or None
3752 If the location is a zarr group rather than an array, this is the
3753 subcomponent that should be loaded, something like ``'foo/bar'``.
3754 storage_options: dict
3755 Any additional parameters for the storage backend (ignored for local
3756 paths)
3757 chunks: tuple of ints or tuples of ints
3758 Passed to :func:`dask.array.from_array`, allows setting the chunks on
3759 initialisation, if the chunking scheme in the on-disc dataset is not
3760 optimal for the calculations to follow.
3761 name : str, optional
3762 An optional keyname for the array. Defaults to hashing the input
3763 kwargs:
3764 Passed to :class:`zarr.core.Array`.
3765 inline_array : bool, default False
3766 Whether to inline the zarr Array in the values of the task graph.
3767 See :meth:`dask.array.from_array` for an explanation.
3768
3769 See Also
3770 --------
3771 from_array
3772 """
3773 import zarr
3774
3775 storage_options = storage_options or {}
3776 if isinstance(url, zarr.Array):
3777 z = url
3778 elif isinstance(url, (str, os.PathLike)):
3779 if isinstance(url, os.PathLike):
3780 url = os.fspath(url)
3781
3782 zarr_store = _setup_zarr_store(url, storage_options, **kwargs)
3783 z = zarr.open_array(store=zarr_store, path=component, **kwargs)
3784 else:
3785 z = zarr.open_array(store=url, path=component, **kwargs)
3786 chunks = chunks if chunks is not None else z.chunks
3787 if name is None:
3788 name = "from-zarr-" + tokenize(z, component, storage_options, chunks, **kwargs)
3789 return from_array(z, chunks, name=name, inline_array=inline_array)

Callers

nothing calls this directly

Calls 3

_setup_zarr_storeFunction · 0.85
from_arrayFunction · 0.70
tokenizeFunction · 0.50

Tested by

no test coverage detected