@@ -693,12 +693,12 @@ async def getitem(
693693 # Consolidated metadata lets us avoid some I/O operations so try that first.
694694 if self .metadata .consolidated_metadata is not None :
695695 return self ._getitem_consolidated (store_path , key , prefix = self .name )
696- elif self . metadata . zarr_format == 3 :
697- return await _read_node_v3 ( store = self . store , path = store_path . path )
698- elif self .metadata .zarr_format == 2 :
699- return await _read_node_v2 ( store = self . store , path = store_path . path )
700- else :
701- raise ValueError ( f"unexpected zarr_format: { self . metadata . zarr_format } " )
696+ try :
697+ return await _read_node_a (
698+ store = store_path . store , path = store_path . path , zarr_format = self .metadata .zarr_format
699+ )
700+ except FileNotFoundError as e :
701+ raise KeyError ( key ) from e
702702
703703 def _getitem_consolidated (
704704 self , store_path : StorePath , key : str , prefix : str
@@ -3419,7 +3419,7 @@ async def _read_metadata_v2(store: Store, path: str) -> ArrayV2Metadata | GroupM
34193419 """
34203420 Given a store_path, return ArrayV2Metadata or GroupMetadata defined by the metadata
34213421 document stored at store_path.path / (.zgroup | .zarray). If no such document is found,
3422- raise a KeyError .
3422+ raise a FileNotFoundError .
34233423 """
34243424 # TODO: consider first fetching array metadata, and only fetching group metadata when we don't
34253425 # find an array
0 commit comments