Skip to content

Commit fdd2a79

Browse files
committed
Merge branch 'kyle/fsspec-integration' of https://github.com/developmentseed/object-store-rs into kyle/fsspec-integration
2 parents bf4f5e0 + a9b0d51 commit fdd2a79

File tree

4 files changed

+96
-1
lines changed

4 files changed

+96
-1
lines changed

object-store-rs/python/object_store_rs/fsspec.py

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import object_store_rs as obs
2828

2929

30-
3130
class AsyncFsspecStore(fsspec.asyn.AsyncFileSystem):
3231

3332
def __init__(

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ dev-dependencies = [
2020
"mkdocstrings[python]>=0.26.1",
2121
"pandas>=2.2.3",
2222
"pip>=24.2",
23+
"pyarrow>=17.0.0",
2324
"pytest-asyncio>=0.24.0",
2425
"pytest>=8.3.3",
2526
]

tests/test_fsspec.py

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import os
2+
3+
import pytest
4+
pytest.importorskip("moto")
5+
from moto.moto_server.threaded_moto_server import ThreadedMotoServer
6+
7+
from object_store_rs.store import S3Store
8+
import object_store_rs as obs
9+
import pyarrow.parquet as pq
10+
from object_store_rs.fsspec import AsyncFsspecStore
11+
12+
13+
ip = "localhost"
14+
port = 5555
15+
endpoint_uri = f"http://{ip}:{port}"
16+
test_bucket_name = "test"
17+
18+
19+
@pytest.fixture(scope="module")
20+
def s3_base():
21+
server = ThreadedMotoServer(ip_address=ip, port=port)
22+
server.start()
23+
os.environ["AWS_SECRET_ACCESS_KEY"] = "foo"
24+
os.environ["AWS_ACCESS_KEY_ID"] = "foo"
25+
os.environ["AWS_ENDPOINT_URL"] = endpoint_uri
26+
27+
print("server up")
28+
yield
29+
print("moto done")
30+
server.stop()
31+
32+
33+
@pytest.fixture()
34+
def s3(s3_base):
35+
from botocore.session import Session
36+
session = Session()
37+
client = session.create_client("s3", endpoint_url=endpoint_uri)
38+
client.create_bucket(Bucket=test_bucket_name, ACL="public-read")
39+
client.put_object(Bucket=test_bucket_name, Key="afile", Body=b"hello world")
40+
41+
42+
@pytest.fixture(autouse=True)
43+
def reset_s3_fixture():
44+
import requests
45+
# We reuse the MotoServer for all tests
46+
# But we do want a clean state for every test
47+
try:
48+
requests.post(f"{endpoint_uri}/moto-api/reset")
49+
except:
50+
pass
51+
52+
53+
@pytest.fixture()
54+
def fs(s3):
55+
return AsyncFsspecStore(S3Store.from_env(test_bucket_name))
56+
57+
58+
def test_list(fs):
59+
out = fs.ls("", detail=False)
60+
breakpoint()
61+
1
62+
63+
64+
def test_remote_parquet():
65+
store = obs.store.HTTPStore.from_url("https://github.com")
66+
fs = AsyncFsspecStore(store)
67+
url = "opengeospatial/geoparquet/raw/refs/heads/main/examples/example.parquet"
68+
pq.read_metadata(url, filesystem=fs)

uv.lock

+27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)