|
4 | 4 | import os
|
5 | 5 | import time
|
6 | 6 | import traceback
|
| 7 | +from abc import ABC, abstractmethod |
7 | 8 | from collections.abc import Hashable, Iterable, Mapping, Sequence
|
8 | 9 | from glob import glob
|
9 | 10 | from typing import TYPE_CHECKING, Any, ClassVar, TypeVar, Union, overload
|
@@ -267,18 +268,22 @@ def robust_getitem(array, key, catch=Exception, max_retries=6, initial_delay=500
|
267 | 268 | time.sleep(1e-3 * next_delay)
|
268 | 269 |
|
269 | 270 |
|
270 |
| -class BackendArray(NdimSizeLenMixin, indexing.ExplicitlyIndexed): |
| 271 | +class BackendArray(ABC, NdimSizeLenMixin, indexing.ExplicitlyIndexed): |
271 | 272 | __slots__ = ()
|
272 | 273 |
|
| 274 | + @abstractmethod |
| 275 | + def __getitem__(key: indexing.ExplicitIndexer) -> np.typing.ArrayLike: ... |
| 276 | + |
| 277 | + async def async_getitem(key: indexing.ExplicitIndexer) -> np.typing.ArrayLike: |
| 278 | + raise NotImplementedError("Backend does not not support asynchronous loading") |
| 279 | + |
273 | 280 | def get_duck_array(self, dtype: np.typing.DTypeLike = None):
|
274 | 281 | key = indexing.BasicIndexer((slice(None),) * self.ndim)
|
275 | 282 | return self[key] # type: ignore[index]
|
276 | 283 |
|
277 | 284 | async def async_get_duck_array(self, dtype: np.typing.DTypeLike = None):
|
278 | 285 | key = indexing.BasicIndexer((slice(None),) * self.ndim)
|
279 |
| - # TODO use zarr-python async get method here? |
280 |
| - print("async inside BackendArray") |
281 |
| - return await self.getitem(key) # type: ignore[index] |
| 286 | + return await self.async_getitem(key) # type: ignore[index] |
282 | 287 |
|
283 | 288 |
|
284 | 289 | class AbstractDataStore:
|
|
0 commit comments