Skip to content
Merged
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream/v3' into fix/auto-remote-store
  • Loading branch information
TomAugspurger committed Sep 19, 2024
commit 940084ccbf84958e1e4a2421595dfa02a6ad7d12
18 changes: 16 additions & 2 deletions src/zarr/store/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,5 +222,19 @@ async def list_dir(self, prefix: str) -> AsyncGenerator[str, None]:
yield onefile.removeprefix(self.path).removeprefix("/")

async def list_prefix(self, prefix: str) -> AsyncGenerator[str, None]:
for onefile in await self.fs._ls(prefix, detail=False):
yield onefile
"""
Retrieve all keys in the store that begin with a given prefix. Keys are returned with the
common leading prefix removed.

Parameters
----------
prefix : str

Returns
-------
AsyncGenerator[str, None]
"""

find_str = "/".join([self.path, prefix])
for onefile in await self.fs._find(find_str, detail=False, maxdepth=None, withdirs=False):
yield onefile.removeprefix(find_str)
9 changes: 9 additions & 0 deletions tests/v3/test_store/test_remote.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from __future__ import annotations

import json
import os
from collections.abc import Generator
from typing import TYPE_CHECKING

import fsspec
import pytest
Expand All @@ -13,6 +16,12 @@
from zarr.store import RemoteStore
from zarr.testing.store import StoreTests

if TYPE_CHECKING:
from collections.abc import Generator

import botocore.client


s3fs = pytest.importorskip("s3fs")
requests = pytest.importorskip("requests")
moto_server = pytest.importorskip("moto.moto_server.threaded_moto_server")
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.