|
6 | 6 | from itertools import starmap
|
7 | 7 | from typing import TYPE_CHECKING, Protocol, runtime_checkable
|
8 | 8 |
|
9 |
| -from zarr.core.buffer.core import default_buffer_prototype |
10 |
| -from zarr.core.common import concurrent_map |
11 |
| -from zarr.core.config import config |
12 |
| - |
13 | 9 | if TYPE_CHECKING:
|
14 | 10 | from collections.abc import AsyncGenerator, AsyncIterator, Iterable
|
15 | 11 | from types import TracebackType
|
@@ -438,6 +434,9 @@ async def getsize(self, key: str) -> int:
|
438 | 434 | # Note to implementers: this default implementation is very inefficient since
|
439 | 435 | # it requires reading the entire object. Many systems will have ways to get the
|
440 | 436 | # size of an object without reading it.
|
| 437 | + # avoid circular import |
| 438 | + from zarr.core.buffer.core import default_buffer_prototype |
| 439 | + |
441 | 440 | value = await self.get(key, prototype=default_buffer_prototype())
|
442 | 441 | if value is None:
|
443 | 442 | raise FileNotFoundError(key)
|
@@ -476,6 +475,11 @@ async def getsize_prefix(self, prefix: str) -> int:
|
476 | 475 | # on to getting sizes. Ideally we would overlap those two, which should
|
477 | 476 | # improve tail latency and might reduce memory pressure (since not all keys
|
478 | 477 | # would be in memory at once).
|
| 478 | + |
| 479 | + # avoid circular import |
| 480 | + from zarr.core.common import concurrent_map |
| 481 | + from zarr.core.config import config |
| 482 | + |
479 | 483 | keys = [(x,) async for x in self.list_prefix(prefix)]
|
480 | 484 | limit = config.get("async.concurrency")
|
481 | 485 | sizes = await concurrent_map(keys, self.getsize, limit=limit)
|
|
0 commit comments