Skip to content

Commit a145abb

Browse files
committed
Removed the on_error argument
1 parent 904e592 commit a145abb

File tree

2 files changed

+4
-23
lines changed

2 files changed

+4
-23
lines changed

zarr/_storage/store.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,7 @@ def _ensure_store(store: Any):
131131
f"wrap it in Zarr.storage.KVStore. Got {store}"
132132
)
133133

134-
def getitems(
135-
self, keys: Iterable[str], meta_array: NDArrayLike, *, on_error: str = "omit"
136-
) -> Mapping[str, Any]:
134+
def getitems(self, keys: Iterable[str], meta_array: NDArrayLike) -> Mapping[str, Any]:
137135
"""Retrieve data from multiple keys.
138136
139137
Parameters
@@ -144,10 +142,6 @@ def getitems(
144142
An array instance to use for determining the output type. For now, this is
145143
only a hint and can be ignore by the implementation, in which case the type
146144
of the output is the same as calling __getitem__() for each key in keys.
147-
on_error : str, optional
148-
The policy on how to handle exceptions when retrieving keys. For now, the
149-
only supported policy is "omit", which means that failing keys are omitted
150-
from the returned result.
151145
152146
Returns
153147
-------
@@ -161,17 +155,7 @@ def getitems(
161155
reads of multiple keys and/or to utilize the meta_array argument.
162156
"""
163157

164-
# Please overwrite `getitems` to support non-default values of `on_error`
165-
if on_error != "omit":
166-
raise ValueError(f"{self.__class__} doesn't support on_error='{on_error}'")
167-
168-
ret = {}
169-
for k in keys:
170-
try:
171-
ret[k] = self[k]
172-
except Exception:
173-
pass # Omit keys that fails
174-
return ret
158+
return {k: self[k] for k in keys if k in self}
175159

176160

177161
class Store(BaseStore):

zarr/storage.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,14 +1365,11 @@ def _normalize_key(self, key):
13651365
return key.lower() if self.normalize_keys else key
13661366

13671367
def getitems(
1368-
self, keys: Iterable[str], meta_array: NDArrayLike, *, on_error: str = "omit"
1368+
self, keys: Iterable[str], meta_array: NDArrayLike
13691369
) -> Mapping[str, Any]:
13701370

1371-
if on_error != "omit":
1372-
raise ValueError(f"{self.__class__} doesn't support on_error='{on_error}'")
1373-
13741371
keys_transformed = [self._normalize_key(key) for key in keys]
1375-
results = self.map.getitems(keys_transformed, on_error=on_error)
1372+
results = self.map.getitems(keys_transformed, on_error="omit")
13761373
# The function calling this method may not recognize the transformed keys
13771374
# So we send the values returned by self.map.getitems back into the original key space.
13781375
return {keys[keys_transformed.index(rk)]: rv for rk, rv in results.items()}

0 commit comments

Comments
 (0)