# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.# SPDX-License-Identifier: Apache-2.0## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.importosfromconcurrent.futuresimportThreadPoolExecutor,as_completedfromtypingimportTYPE_CHECKING,Any,Iterator,Mapping,Optional,Sequence,Tupleimportzarras_zarrfromzarr.storageimportBaseStorefrom..shortcutsimportresolve_storage_clientfrom..typesimportMSC_PROTOCOLifTYPE_CHECKING:from..clientimportStorageClient
[docs]defopen_consolidated(*args:Any,**kwargs:Any)->_zarr.Group:""" Adapt ``zarr.open_consolidated`` to use :py:class:`LazyZarrStore` when path matches the ``msc`` protocol. If the path starts with the MSC protocol, it uses :py:class:`LazyZarrStore` with a resolved storage client and prefix, passing ``msc_max_workers`` if provided. Otherwise, it directly calls ``zarr.open_consolidated``. """args_list=list(args)path=args_list[0]ifargs_listelsekwargs.get("store")msc_max_workers=kwargs.pop("msc_max_workers",None)ifisinstance(path,str)andpath.startswith(MSC_PROTOCOL):storage_client,prefix=resolve_storage_client(path)zarr_store=LazyZarrStore(storage_client,prefix=prefix,msc_max_workers=msc_max_workers)ifpath==args_list[0]:args_list[0]=zarr_storeelse:kwargs["store"]=zarr_storereturn_zarr.open_consolidated(*args_list,**kwargs)# pyright: ignore [reportReturnType]return_zarr.open_consolidated(*args,**kwargs)# pyright: ignore [reportReturnType]