Skip to content

Commit a4f915a

Browse files
authored
Add class methods wrapper (#331)
* Add class methods wrapper * fix local tests * Don't override store module from rust * exceptions module * Update imports * fix store wrapper imports * Re-export _store for correct type inference * Instantiate subclasses in from_url * Ensure from_url instantiates subclasses * Ensure correct error raised * Convert tests to use store api * lint * Add obspec validation tests * use published obspec * hyperlinks
1 parent 152955a commit a4f915a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1157
-286
lines changed

docs/api/list.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,3 @@
33
::: obstore.list
44
::: obstore.list_with_delimiter
55
::: obstore.list_with_delimiter_async
6-
::: obstore.ListResult
7-
::: obstore.ListStream
8-
::: obstore.ListChunkType

docs/api/store/aws.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# AWS S3
22

33
::: obstore.store.S3Store
4+
options:
5+
inherited_members: true
6+
show_bases: false
47
::: obstore.store.S3Config
58
options:
69
show_if_no_docstring: true

docs/api/store/azure.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Microsoft Azure
22

33
::: obstore.store.AzureStore
4+
options:
5+
inherited_members: true
6+
show_bases: false
47
::: obstore.store.AzureConfig
58
options:
69
show_if_no_docstring: true

docs/api/store/gcs.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Google Cloud Storage
22

33
::: obstore.store.GCSStore
4+
options:
5+
inherited_members: true
6+
show_bases: false
47
::: obstore.store.GCSConfig
58
options:
69
show_if_no_docstring: true

docs/api/store/http.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# HTTP
22

33
::: obstore.store.HTTPStore
4+
options:
5+
inherited_members: true
6+
show_bases: false

docs/api/store/local.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# Local
22

33
::: obstore.store.LocalStore
4+
options:
5+
inherited_members: true
6+
show_bases: false

docs/api/store/memory.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# Memory
22

33
::: obstore.store.MemoryStore
4+
options:
5+
inherited_members: true
6+
show_bases: false

docs/cookbook.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@ store = ... # store of your choice
3939
# Get a stream of Arrow RecordBatches of metadata
4040
list_stream = obs.list(store, prefix="data", return_arrow=True)
4141
for record_batch in list_stream:
42+
# Perform zero-copy conversion to your arrow-backed library of choice
43+
#
44+
# To pyarrow:
45+
# pyarrow.record_batch(record_batch)
46+
#
47+
# To polars:
48+
# polars.DataFrame(record_batch)
49+
#
50+
# To pandas (with Arrow-backed data-types):
51+
# pyarrow.record_batch(record_batch).to_pandas(types_mapper=pd.ArrowDtype)
52+
#
53+
# To arro3:
54+
# arro3.core.RecordBatch(record_batch)
4255
print(record_batch.num_rows)
4356
```
4457

obstore/python/obstore/__init__.py

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,50 @@
11
from typing import TYPE_CHECKING
22

3-
from ._obstore import *
4-
from ._obstore import ___version
3+
from . import store
4+
from ._obstore import (
5+
Bytes,
6+
___version,
7+
copy,
8+
copy_async,
9+
delete,
10+
delete_async,
11+
get,
12+
get_async,
13+
get_range,
14+
get_range_async,
15+
get_ranges,
16+
get_ranges_async,
17+
head,
18+
head_async,
19+
list, # noqa: A004
20+
list_with_delimiter,
21+
list_with_delimiter_async,
22+
open_reader,
23+
open_reader_async,
24+
open_writer,
25+
open_writer_async,
26+
put,
27+
put_async,
28+
rename,
29+
rename_async,
30+
sign,
31+
sign_async,
32+
)
533

634
if TYPE_CHECKING:
7-
from . import exceptions, store
8-
35+
from . import _store, exceptions
36+
from ._obstore import (
37+
HTTP_METHOD,
38+
AsyncReadableFile,
39+
AsyncWritableFile,
40+
Bytes,
41+
BytesStream,
42+
GetResult,
43+
ListChunkType,
44+
ListResult,
45+
ListStream,
46+
ReadableFile,
47+
SignCapableStore,
48+
WritableFile,
49+
)
950
__version__: str = ___version()

obstore/python/obstore/_buffered.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ from obspec._attributes import Attributes
77

88
from ._bytes import Bytes
99
from ._list import ObjectMeta
10-
from .store import ObjectStore
10+
from ._store import ObjectStore
1111

1212
if sys.version_info >= (3, 12):
1313
from collections.abc import Buffer

0 commit comments

Comments
 (0)