|
27 | 27 | from typing import Any, TypeVar, Union, cast
|
28 | 28 |
|
29 | 29 | import numpy as np
|
30 |
| -from fsspec import get_mapper |
31 | 30 | from tlz import accumulate, concat, first, frequencies, groupby, partition
|
32 | 31 | from tlz.curried import pluck
|
33 | 32 |
|
@@ -3562,11 +3561,13 @@ def from_zarr(
|
3562 | 3561 | elif isinstance(url, (str, os.PathLike)):
|
3563 | 3562 | if isinstance(url, os.PathLike):
|
3564 | 3563 | 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) |
3567 | 3569 | 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) |
3570 | 3571 | chunks = chunks if chunks is not None else z.chunks
|
3571 | 3572 | if name is None:
|
3572 | 3573 | name = "from-zarr-" + tokenize(z, component, storage_options, chunks, **kwargs)
|
@@ -3674,19 +3675,18 @@ def to_zarr(
|
3674 | 3675 |
|
3675 | 3676 | storage_options = storage_options or {}
|
3676 | 3677 |
|
3677 |
| - if isinstance(url, str): |
3678 |
| - mapper = get_mapper(url, **storage_options) |
| 3678 | + if storage_options: |
| 3679 | + store = zarr.storage.FSStore(url, **storage_options) |
3679 | 3680 | else:
|
3680 |
| - # assume the object passed is already a mapper |
3681 |
| - mapper = url |
| 3681 | + store = url |
3682 | 3682 |
|
3683 | 3683 | chunks = [c[0] for c in arr.chunks]
|
3684 | 3684 |
|
3685 | 3685 | z = zarr.create(
|
3686 | 3686 | shape=arr.shape,
|
3687 | 3687 | chunks=chunks,
|
3688 | 3688 | dtype=arr.dtype,
|
3689 |
| - store=mapper, |
| 3689 | + store=store, |
3690 | 3690 | path=component,
|
3691 | 3691 | overwrite=overwrite,
|
3692 | 3692 | **kwargs,
|
|
0 commit comments