8000 Update zarr store creation functions (#9790) · dask/dask@0cd60ee · GitHub
[go: up one dir, main page]

Skip to content

Commit 0cd60ee

Browse files
authored
Update zarr store creation functions (#9790)
As discussed in zarr-developers/zarr-python#1309 (review), Zarr can now handle a the creation of more types of store object from URLs thanks to the FSStore class. This means that usually Dask can just pass through the store URL with no modifications (e.g. calling get_mapper). The only exception is when the user specifies storage_options explicitly
1 parent 40bc376 commit 0cd60ee

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

dask/array/core.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
from typing import Any, TypeVar, Union, cast
2828

2929
import numpy as np
30-
from fsspec import get_mapper
3130
from tlz import accumulate, concat, first, frequencies, groupby, partition
3231
from tlz.curried import pluck
3332

@@ -3562,11 +3561,13 @@ def from_zarr(
35623561
elif isinstance(url, (str, os.PathLike)):
35633562
if isinstance(url, os.PathLike):
35643563
url = os.fspath(url)
3565-
mapper = get_mapper(url, **storage_options)
3566-
z = zarr.Array(mapper, read_only=True, path=component, **kwargs)
3564+
if storage_options:
3565+
store = zarr.storage.FSStore(url, **storage_options)
3566+
else:
3567+
store = url
3568+
z = zarr.Array(store, read_only=True, path=component, **kwargs)
35673569
else:
3568-
mapper = url
3569-
z = zarr.Array(mapper, read_only=True, path=component, **kwargs)
3570+
z = zarr.Array(url, read_only=True, path=component, **kwargs)
35703571
chunks = chunks if chunks is not None else z.chunks
35713572
if name is None:
35723573
name = "from-zarr-" + tokenize(z, component, storage_options, chunks, **kwargs)
@@ -3674,19 +3675,18 @@ def to_zarr(
36743675

36753676
storage_options = storage_options or {}
36763677

3677-
if isinstance(url, str):
3678-
mapper = get_mapper(url, **storage_options)
3678+
if storage_options:
3679+
store = zarr.storage.FSStore(url, **storage_options)
36793680
else:
3680-
# assume the object passed is already a mapper
3681-
mapper = url
3681+
store = url
36823682

36833683
chunks = [c[0] for c in arr.chunks]
36843684

36853685
z = zarr.create(
36863686
shape=arr.shape,
36873687
chunks=chunks,
36883688
dtype=arr.dtype,
3689-
store=mapper,
3689+
store=store,
36903690
path=component,
36913691
overwrite=overwrite,
36923692
**kwargs,

0 commit comments

Comments
 (0)
0