Skip to content

Commit 1e3162b

Browse files
authored
Rename AsyncFsspecStore to FsspecStore (#297)
1 parent 6ecee42 commit 1e3162b

File tree

3 files changed

+30
-30
lines changed

3 files changed

+30
-30
lines changed

docs/getting-started.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ File-like object support is also provided:
6969

7070
- [`open_reader`][obstore.open_reader]: Open a remote object as a readable file-like object, similar to a Python [`BufferedReader`](https://docs.python.org/3/library/io.html#io.BufferedReader).
7171
- [`open_writer`][obstore.open_writer]: Open a remote object as a writable file-like object, similar to a Python [`BufferedWriter`](https://docs.python.org/3/library/io.html#io.BufferedWriter)
72-
- [`AsyncFsspecStore`][obstore.fsspec.AsyncFsspecStore] adapter for use with [`fsspec`](https://github.com/fsspec/filesystem_spec).
72+
- [`FsspecStore`][obstore.fsspec.FsspecStore] adapter for use with [`fsspec`](https://github.com/fsspec/filesystem_spec).
7373

7474
**All operations have a comparable async method** with the same name plus an `_async` suffix.
7575

obstore/python/obstore/fsspec.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
}
8383

8484

85-
class AsyncFsspecStore(fsspec.asyn.AsyncFileSystem):
85+
class FsspecStore(fsspec.asyn.AsyncFileSystem):
8686
"""An fsspec implementation based on a obstore Store.
8787
8888
You should be able to pass an instance of this class into any API that expects an
@@ -151,7 +151,7 @@ def __init__( # noqa: PLR0913
151151
loop: Any = None,
152152
batch_size: int | None = None,
153153
) -> None:
154-
"""Construct a new AsyncFsspecStore.
154+
"""Construct a new FsspecStore.
155155
156156
Args:
157157
protocol: The storage protocol to use, such as "s3",
@@ -183,9 +183,9 @@ def __init__( # noqa: PLR0913
183183
**Examples:**
184184
185185
```py
186-
from obstore.fsspec import AsyncFsspecStore
186+
from obstore.fsspec import FsspecStore
187187
188-
store = AsyncFsspecStore(protocol="https")
188+
store = FsspecStore(protocol="https")
189189
resp = store.cat("https://example.com")
190190
assert resp.startswith(b"<!doctype html>")
191191
```
@@ -535,7 +535,7 @@ class BufferedFile(fsspec.spec.AbstractBufferedFile):
535535
@overload
536536
def __init__(
537537
self,
538-
fs: AsyncFsspecStore,
538+
fs: FsspecStore,
539539
path: str,
540540
mode: Literal["rb"] = "rb",
541541
*,
@@ -545,7 +545,7 @@ def __init__(
545545
@overload
546546
def __init__(
547547
self,
548-
fs: AsyncFsspecStore,
548+
fs: FsspecStore,
549549
path: str,
550550
mode: Literal["wb"],
551551
*,
@@ -556,7 +556,7 @@ def __init__(
556556
) -> None: ...
557557
def __init__( # noqa: PLR0913
558558
self,
559-
fs: AsyncFsspecStore,
559+
fs: FsspecStore,
560560
path: str,
561561
mode: Literal["rb", "wb"] = "rb",
562562
*,
@@ -748,15 +748,15 @@ def loc(self, value: int) -> None:
748748

749749

750750
def register(protocol: str | Iterable[str], *, asynchronous: bool = False) -> None:
751-
"""Dynamically register a subclass of AsyncFsspecStore for the given protocol(s).
751+
"""Dynamically register a subclass of FsspecStore for the given protocol(s).
752752
753-
This function creates a new subclass of AsyncFsspecStore with the specified
753+
This function creates a new subclass of FsspecStore with the specified
754754
protocol and registers it with fsspec. If multiple protocols are provided,
755755
the function registers each one individually.
756756
757757
Args:
758758
protocol (str | list[str]): A single protocol (e.g., "s3", "gcs", "abfs") or
759-
a list of protocols to register AsyncFsspecStore for.
759+
a list of protocols to register FsspecStore for.
760760
asynchronous (bool, optional): If True, the registered store will support
761761
asynchronous operations. Defaults to False.
762762
@@ -769,8 +769,8 @@ def register(protocol: str | Iterable[str], *, asynchronous: bool = False) -> No
769769
770770
Notes:
771771
- Each protocol gets a dynamically generated subclass named
772-
`AsyncFsspecStore_<protocol>`. This avoids modifying the original
773-
AsyncFsspecStore class.
772+
`FsspecStore_<protocol>`. This avoids modifying the original
773+
FsspecStore class.
774774
775775
"""
776776
if isinstance(protocol, str):
@@ -785,8 +785,8 @@ def _register(protocol: str, *, asynchronous: bool) -> None:
785785
fsspec.register_implementation(
786786
protocol,
787787
type(
788-
f"AsyncFsspecStore_{protocol}", # Unique class name
789-
(AsyncFsspecStore,), # Base class
788+
f"FsspecStore_{protocol}", # Unique class name
789+
(FsspecStore,), # Base class
790790
{
791791
"protocol": protocol,
792792
"asynchronous": asynchronous,

tests/test_fsspec.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import pytest
1111
from fsspec.registry import _registry
1212

13-
from obstore.fsspec import AsyncFsspecStore, register
13+
from obstore.fsspec import FsspecStore, register
1414
from tests.conftest import TEST_BUCKET_NAME
1515

1616
if TYPE_CHECKING:
@@ -45,8 +45,8 @@ def test_register():
4545

4646
assert issubclass(
4747
fs_class,
48-
AsyncFsspecStore,
49-
), "Registered class should be a subclass of AsyncFsspecStore"
48+
FsspecStore,
49+
), "Registered class should be a subclass of FsspecStore"
5050
assert fs_class.protocol == "s3", (
5151
"Registered class should have the correct protocol"
5252
)
@@ -55,7 +55,7 @@ def test_register():
5555
fs_instance = fs_class()
5656
assert isinstance(
5757
fs_instance,
58-
AsyncFsspecStore,
58+
FsspecStore,
5959
), "Registered class should be instantiable"
6060

6161
# test register asynchronous
@@ -65,13 +65,13 @@ def test_register():
6565

6666
# test multiple registrations
6767
register(["file", "abfs"])
68-
assert issubclass(fsspec.get_filesystem_class("file"), AsyncFsspecStore)
69-
assert issubclass(fsspec.get_filesystem_class("abfs"), AsyncFsspecStore)
68+
assert issubclass(fsspec.get_filesystem_class("file"), FsspecStore)
69+
assert issubclass(fsspec.get_filesystem_class("abfs"), FsspecStore)
7070

7171

7272
def test_construct_store_cache_diff_bucket_name(s3_store_config: S3Config):
7373
register("s3")
74-
fs: AsyncFsspecStore = fsspec.filesystem(
74+
fs: FsspecStore = fsspec.filesystem(
7575
"s3",
7676
config=s3_store_config,
7777
client_options={"allow_http": True},
@@ -167,7 +167,7 @@ def test_fsspec_filesystem_cache(s3_store_config: S3Config):
167167
)
168168

169169

170-
def test_split_path(fs: AsyncFsspecStore):
170+
def test_split_path(fs: FsspecStore):
171171
# in url format, with bucket
172172
assert fs._split_path("s3://mybucket/path/to/file") == ("mybucket", "path/to/file")
173173
assert fs._split_path("s3://data-bucket/") == ("data-bucket", "")
@@ -193,7 +193,7 @@ def test_split_path(fs: AsyncFsspecStore):
193193
assert fs._split_path("/data-bucket/") == ("", "/data-bucket/")
194194

195195

196-
def test_list(fs: AsyncFsspecStore):
196+
def test_list(fs: FsspecStore):
197197
out = fs.ls(f"{TEST_BUCKET_NAME}", detail=False)
198198
assert out == [f"{TEST_BUCKET_NAME}/afile"]
199199
fs.pipe_file(f"{TEST_BUCKET_NAME}/dir/bfile", b"data")
@@ -258,7 +258,7 @@ def test_remote_parquet(s3_store_config: S3Config):
258258
)
259259

260260

261-
def test_multi_file_ops(fs: AsyncFsspecStore):
261+
def test_multi_file_ops(fs: FsspecStore):
262262
data = {
263263
f"{TEST_BUCKET_NAME}/dir/test1": b"test data1",
264264
f"{TEST_BUCKET_NAME}/dir/test2": b"test data2",
@@ -282,7 +282,7 @@ def test_multi_file_ops(fs: AsyncFsspecStore):
282282
assert out == [f"{TEST_BUCKET_NAME}/afile"]
283283

284284

285-
def test_cat_ranges_one(fs: AsyncFsspecStore):
285+
def test_cat_ranges_one(fs: FsspecStore):
286286
data1 = os.urandom(10000)
287287
fs.pipe_file(f"{TEST_BUCKET_NAME}/data1", data1)
288288

@@ -327,7 +327,7 @@ def test_cat_ranges_one(fs: AsyncFsspecStore):
327327
assert out == [data1[10:20], data1[0:60]]
328328

329329

330-
def test_cat_ranges_two(fs: AsyncFsspecStore):
330+
def test_cat_ranges_two(fs: FsspecStore):
331331
data1 = os.urandom(10000)
332332
data2 = os.urandom(10000)
333333
fs.pipe({f"{TEST_BUCKET_NAME}/data1": data1, f"{TEST_BUCKET_NAME}/data2": data2})
@@ -342,7 +342,7 @@ def test_cat_ranges_two(fs: AsyncFsspecStore):
342342

343343

344344
@pytest.mark.xfail(reason="negative and mixed ranges not implemented")
345-
def test_cat_ranges_mixed(fs: AsyncFsspecStore):
345+
def test_cat_ranges_mixed(fs: FsspecStore):
346346
data1 = os.urandom(10000)
347347
data2 = os.urandom(10000)
348348
fs.pipe({"data1": data1, "data2": data2})
@@ -353,13 +353,13 @@ def test_cat_ranges_mixed(fs: AsyncFsspecStore):
353353

354354

355355
@pytest.mark.xfail(reason="atomic writes not working on moto")
356-
def test_atomic_write(fs: AsyncFsspecStore):
356+
def test_atomic_write(fs: FsspecStore):
357357
fs.pipe_file("data1", b"data1")
358358
fs.pipe_file("data1", b"data1", mode="overwrite")
359359
with pytest.raises(ValueError): # noqa: PT011
360360
fs.pipe_file("data1", b"data1", mode="create")
361361

362362

363-
def test_cat_ranges_error(fs: AsyncFsspecStore):
363+
def test_cat_ranges_error(fs: FsspecStore):
364364
with pytest.raises(ValueError): # noqa: PT011
365365
fs.cat_ranges([f"{TEST_BUCKET_NAME}/path"], [], [])

0 commit comments

Comments
 (0)