MCPcopy Index your code
hub / github.com/pydata/xarray / _get_open_params

Function _get_open_params

xarray/backends/zarr.py:1875–1993  ·  view source on GitHub ↗
(
    store,
    mode,
    synchronizer,
    group,
    consolidated,
    consolidate_on_close,
    chunk_store,
    storage_options,
    zarr_version,
    use_zarr_fill_value_as_mask,
    zarr_format,
)

Source from the content-addressed store, hash-verified

1873
1874
1875def _get_open_params(
1876 store,
1877 mode,
1878 synchronizer,
1879 group,
1880 consolidated,
1881 consolidate_on_close,
1882 chunk_store,
1883 storage_options,
1884 zarr_version,
1885 use_zarr_fill_value_as_mask,
1886 zarr_format,
1887):
1888 if TYPE_CHECKING:
1889 import zarr
1890 else:
1891 zarr = attempt_import("zarr")
1892
1893 # zarr doesn't support pathlib.Path objects yet. zarr-python#601
1894 if isinstance(store, os.PathLike):
1895 store = os.fspath(store)
1896
1897 open_kwargs = dict(
1898 # mode='a-' is a handcrafted xarray specialty
1899 mode="a" if mode == "a-" else mode,
1900 synchronizer=synchronizer,
1901 path=group,
1902 )
1903 open_kwargs["storage_options"] = storage_options
1904
1905 zarr_format = _handle_zarr_version_or_format(
1906 zarr_version=zarr_version, zarr_format=zarr_format
1907 )
1908
1909 if _zarr_v3():
1910 open_kwargs["zarr_format"] = zarr_format
1911 else:
1912 open_kwargs["zarr_version"] = zarr_format
1913
1914 if chunk_store is not None:
1915 open_kwargs["chunk_store"] = chunk_store
1916 if consolidated is None:
1917 consolidated = False
1918
1919 if _zarr_v3():
1920 # TODO: replace AssertionError after https://github.com/zarr-developers/zarr-python/issues/2821 is resolved
1921 missing_exc = AssertionError
1922 else:
1923 missing_exc = zarr.errors.GroupNotFoundError
1924
1925 if _zarr_v3():
1926 # zarr 3.0.8 and earlier did not support this property - it was effectively assumed true
1927 if not getattr(store, "supports_consolidated_metadata", True):
1928 consolidated = consolidate_on_close = False
1929
1930 if consolidated in [None, True]:
1931 # open the root of the store, in case there is metadata consolidated there
1932 group = open_kwargs.pop("path")

Callers 2

open_storeMethod · 0.85
open_groupMethod · 0.85

Calls 5

attempt_importFunction · 0.90
emit_user_level_warningFunction · 0.90
_zarr_v3Function · 0.85
open_groupMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…