MCPcopy
hub / github.com/dask/dask / _setup_zarr_store

Function _setup_zarr_store

dask/array/core.py:3895–3939  ·  view source on GitHub ↗

Set up a Zarr store for reading or writing, handling both Zarr v2 and v3. This function prepares a Zarr-compatible storage object (`store`) from a URL or existing store. It supports optional storage options for fsspec-based stores and automatically selects the appropriate store typ

(
    url: str, storage_options: dict[str, object] | None = None, **kwargs: object
)

Source from the content-addressed store, hash-verified

3893
3894
3895def _setup_zarr_store(
3896 url: str, storage_options: dict[str, object] | None = None, **kwargs: object
3897):
3898 """
3899 Set up a Zarr store for reading or writing, handling both Zarr v2 and v3.
3900
3901 This function prepares a Zarr-compatible storage object (`store`) from a URL or existing
3902 store. It supports optional storage options for fsspec-based stores and automatically
3903 selects the appropriate store type depending on the Zarr version.
3904
3905 Parameters
3906 ----------
3907 url: Zarr Array or str or MutableMapping
3908 Location of the data. A URL can include a protocol specifier like s3://
3909 for remote data. Can also be any MutableMapping instance, which should
3910 be serializable if used in multiple processes.
3911 storage_options: dict | None, default = None
3912 Any additional parameters for the storage backend (ignored for local
3913 paths)
3914 **kwargs:
3915 Passed to determine whether the store should be readonly by evaluating the following:
3916 'kwargs.pop("read_only", kwargs.pop("mode", "a") == "r")'
3917
3918 Returns
3919 -------
3920 store : zarr.store.Store or original url
3921 A Zarr-compatible store object. Can be:
3922 - `zarr.storage.FsspecStore` for Zarr v3 with storage options
3923 - `zarr.storage.FSStore` for Zarr v2 with storage options
3924 - The original URL/path if no storage options are provided
3925 """
3926 # Cannot directly import FSStore from storage.
3927 from zarr import storage
3928
3929 if storage_options is not None:
3930 if _zarr_v3():
3931 read_only = kwargs.pop("read_only", kwargs.pop("mode", "a") == "r")
3932 store = storage.FsspecStore.from_url(
3933 url, read_only=read_only, storage_options=storage_options
3934 )
3935 else:
3936 store = storage.FSStore(url, **storage_options)
3937 else:
3938 store = url
3939 return store
3940
3941
3942def to_zarr(

Callers 2

from_zarrFunction · 0.85
to_zarrFunction · 0.85

Calls 2

_zarr_v3Function · 0.85
popMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…