@@ -196,6 +196,7 @@ async def open(
196196 zarr_version : ZarrFormat | None = None , # deprecated
197197 zarr_format : ZarrFormat | None = None ,
198198 path : str | None = None ,
199+ storage_options : dict [str , Any ] | None = None ,
199200 ** kwargs : Any , # TODO: type kwargs as valid args to open_array
200201) -> AsyncArray | AsyncGroup :
201202 """Convenience function to open a group or array using file-mode-like semantics.
@@ -213,6 +214,9 @@ async def open(
213214 The zarr format to use when saving.
214215 path : str or None, optional
215216 The path within the store to open.
217+ storage_options : dict
218+ If using an fsspec URL to create the store, these will be passed to
219+ the backend implementation. Ignored otherwise.
216220 **kwargs
217221 Additional parameters are passed through to :func:`zarr.creation.open_array` or
218222 :func:`zarr.hierarchy.open_group`.
@@ -279,6 +283,7 @@ async def save_array(
279283 zarr_version : ZarrFormat | None = None , # deprecated
280284 zarr_format : ZarrFormat | None = None ,
281285 path : str | None = None ,
286+ storage_options : dict [str , Any ] | None = None ,
282287 ** kwargs : Any , # TODO: type kwargs as valid args to create
283288) -> None :
284289 """Convenience function to save a NumPy array to the local file system, following a
@@ -294,6 +299,9 @@ async def save_array(
294299 The zarr format to use when saving.
295300 path : str or None, optional
296301 The path within the store where the array will be saved.
302+ storage_options : dict
303+ If using an fsspec URL to create the store, these will be passed to
304+ the backend implementation. Ignored otherwise.
297305 kwargs
298306 Passed through to :func:`create`, e.g., compressor.
299307 """
@@ -329,6 +337,7 @@ async def save_group(
329337 zarr_version : ZarrFormat | None = None , # deprecated
330338 zarr_format : ZarrFormat | None = None ,
331339 path : str | None = None ,
340+ storage_options : dict [str , Any ] | None = None ,
332341 ** kwargs : NDArrayLike ,
333342) -> None :
334343 """Convenience function to save several NumPy arrays to the local file system, following a
@@ -344,22 +353,40 @@ async def save_group(
344353 The zarr format to use when saving.
345354 path : str or None, optional
346355 Path within the store where the group will be saved.
356+ storage_options : dict
357+ If using an fsspec URL to create the store, these will be passed to
358+ the backend implementation. Ignored otherwise.
347359 kwargs
348360 NumPy arrays with data to save.
349361 """
350362 zarr_format = (
351- _handle_zarr_version_or_format (zarr_version = zarr_version , zarr_format = zarr_format )
363+ _handle_zarr_version_or_format (
364+ zarr_version = zarr_version ,
365+ zarr_format = zarr_format ,
366+ )
352367 or _default_zarr_version ()
353368 )
354369
355370 if len (args ) == 0 and len (kwargs ) == 0 :
356371 raise ValueError ("at least one array must be provided" )
357372 aws = []
358373 for i , arr in enumerate (args ):
359- aws .append (save_array (store , arr , zarr_format = zarr_format , path = f"{ path } /arr_{ i } " ))
374+ aws .append (
375+ save_array (
376+ store ,
377+ arr ,
378+ zarr_format = zarr_format ,
379+ path = f"{ path } /arr_{ i } " ,
380+ storage_options = storage_options ,
381+ )
382+ )
360383 for k , arr in kwargs .items ():
361384 _path = f"{ path } /{ k } " if path is not None else k
362- aws .append (save_array (store , arr , zarr_format = zarr_format , path = _path ))
385+ aws .append (
386+ save_array (
387+ store , arr , zarr_format = zarr_format , path = _path , storage_options = storage_options
388+ )
389+ )
363390 await asyncio .gather (* aws )
364391
365392
@@ -428,6 +455,7 @@ async def group(
428455 zarr_format : ZarrFormat | None = None ,
429456 meta_array : Any | None = None , # not used
430457 attributes : dict [str , JSON ] | None = None ,
458+ storage_options : dict [str , Any ] | None = None ,
431459) -> AsyncGroup :
432460 """Create a group.
433461
@@ -454,6 +482,9 @@ async def group(
454482 to users. Use `numpy.empty(())` by default.
455483 zarr_format : {2, 3, None}, optional
456484 The zarr format to use when saving.
485+ storage_options : dict
486+ If using an fsspec URL to create the store, these will be passed to
487+ the backend implementation. Ignored otherwise.
457488
458489 Returns
459490 -------
@@ -484,7 +515,7 @@ async def group(
484515 try :
485516 return await AsyncGroup .open (store = store_path , zarr_format = zarr_format )
486517 except (KeyError , FileNotFoundError ):
487- return await AsyncGroup .create (
518+ return await AsyncGroup .from_store (
488519 store = store_path ,
489520 zarr_format = zarr_format or _default_zarr_version (),
490521 exists_ok = overwrite ,
@@ -493,14 +524,14 @@ async def group(
493524
494525
495526async def open_group (
496- * , # Note: this is a change from v2
497527 store : StoreLike | None = None ,
528+ * , # Note: this is a change from v2
498529 mode : AccessModeLiteral | None = None ,
499530 cache_attrs : bool | None = None , # not used, default changed
500531 synchronizer : Any = None , # not used
501532 path : str | None = None ,
502533 chunk_store : StoreLike | None = None , # not used
503- storage_options : dict [str , Any ] | None = None , # not used
534+ storage_options : dict [str , Any ] | None = None ,
504535 zarr_version : ZarrFormat | None = None , # deprecated
505536 zarr_format : ZarrFormat | None = None ,
506537 meta_array : Any | None = None , # not used
@@ -560,11 +591,6 @@ async def open_group(
560591 warnings .warn ("meta_array is not yet implemented" , RuntimeWarning , stacklevel = 2 )
561592 if chunk_store is not None :
562593 warnings .warn ("chunk_store is not yet implemented" , RuntimeWarning , stacklevel = 2 )
563- if storage_options is not None :
564- warnings .warn ("storage_options is not yet implemented" , RuntimeWarning , stacklevel = 2 )
565-
566- if mode is not None and isinstance (store , Store | StorePath ):
567- raise ValueError ("mode cannot be set when store is already initialized" )
568594
569595 store_path = await make_store_path (store , mode = mode )
570596 if path is not None :
@@ -576,7 +602,7 @@ async def open_group(
576602 try :
577603 return await AsyncGroup .open (store_path , zarr_format = zarr_format )
578604 except (KeyError , FileNotFoundError ):
579- return await AsyncGroup .create (
605+ return await AsyncGroup .from_store (
580606 store_path ,
581607 zarr_format = zarr_format or _default_zarr_version (),
582608 exists_ok = True ,
@@ -590,7 +616,7 @@ async def create(
590616 chunks : ChunkCoords | None = None , # TODO: v2 allowed chunks=True
591617 dtype : npt .DTypeLike | None = None ,
592618 compressor : dict [str , JSON ] | None = None , # TODO: default and type change
593- fill_value : Any = 0 , # TODO: need type
619+ fill_value : Any | None = 0 , # TODO: need type
594620 order : MemoryOrder | None = None , # TODO: default change
595621 store : str | StoreLike | None = None ,
596622 synchronizer : Any | None = None ,
@@ -618,6 +644,7 @@ async def create(
618644 ) = None ,
619645 codecs : Iterable [Codec | dict [str , JSON ]] | None = None ,
620646 dimension_names : Iterable [str ] | None = None ,
647+ storage_options : dict [str , Any ] | None = None ,
621648 ** kwargs : Any ,
622649) -> AsyncArray :
623650 """Create an array.
@@ -689,6 +716,9 @@ async def create(
689716 to users. Use `numpy.empty(())` by default.
690717
691718 .. versionadded:: 2.13
719+ storage_options : dict
720+ If using an fsspec URL to create the store, these will be passed to
721+ the backend implementation. Ignored otherwise.
692722
693723 Returns
694724 -------
@@ -848,7 +878,7 @@ async def full_like(a: ArrayLike, **kwargs: Any) -> AsyncArray:
848878 """
849879 like_kwargs = _like_args (a , kwargs )
850880 if isinstance (a , AsyncArray ):
851- kwargs .setdefault ("fill_value" , a .metadata .fill_value )
881+ like_kwargs .setdefault ("fill_value" , a .metadata .fill_value )
852882 return await full (** like_kwargs )
853883
854884
@@ -896,6 +926,7 @@ async def open_array(
896926 zarr_version : ZarrFormat | None = None , # deprecated
897927 zarr_format : ZarrFormat | None = None ,
898928 path : PathLike | None = None ,
929+ storage_options : dict [str , Any ] | None = None ,
899930 ** kwargs : Any , # TODO: type kwargs as valid args to save
900931) -> AsyncArray :
901932 """Open an array using file-mode-like semantics.
@@ -908,6 +939,9 @@ async def open_array(
908939 The zarr format to use when saving.
909940 path : string, optional
910941 Path in store to array.
942+ storage_options : dict
943+ If using an fsspec URL to create the store, these will be passed to
944+ the backend implementation. Ignored otherwise.
911945 **kwargs
912946 Any keyword arguments to pass to the array constructor.
913947
0 commit comments