Skip to content

Commit 04118ab

Browse files
authored
Use obspec as dev dependency (#337)
1 parent 5e4c834 commit 04118ab

16 files changed

+53
-263
lines changed

docs/api/attributes.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

docs/api/get.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
::: obstore.get_range_async
77
::: obstore.get_ranges
88
::: obstore.get_ranges_async
9-
::: obstore.GetOptions
109
::: obstore.GetResult
1110
::: obstore.BytesStream
1211
::: obstore.Bytes
13-
::: obstore.OffsetRange
14-
::: obstore.SuffixRange

docs/api/list.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
::: obstore.list
44
::: obstore.list_with_delimiter
55
::: obstore.list_with_delimiter_async
6-
::: obstore.ObjectMeta
76
::: obstore.ListResult
87
::: obstore.ListStream
98
::: obstore.ListChunkType

docs/api/put.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,3 @@
22

33
::: obstore.put
44
::: obstore.put_async
5-
::: obstore.PutResult
6-
::: obstore.UpdateVersion
7-
::: obstore.PutMode

docs/blog/posts/obstore-0.4.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Obstore version 0.5 is expected to improve on extensible credentials by enabling
7272

7373
## Return Arrow data from `list_with_delimiter`
7474

75-
By default, the [`obstore.list`][] and [`obstore.list_with_delimiter`][] APIs [return standard Python `dict`s][obstore.ObjectMeta]. However, if you're listing a large bucket, the overhead of materializing all those Python objects can become significant.
75+
By default, the [`obstore.list`][] and [`obstore.list_with_delimiter`][] APIs [return standard Python `dict`s][obspec.ObjectMeta]. However, if you're listing a large bucket, the overhead of materializing all those Python objects can become significant.
7676

7777
[`obstore.list`][] and [`obstore.list_with_delimiter`][] now both support a `return_arrow` keyword parameter. If set to `True`, an Arrow [`RecordBatch`][arro3.core.RecordBatch] or [`Table`][arro3.core.Table] will be returned, which is both faster and more memory efficient.
7878

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ nav:
6262
- api/put.md
6363
- api/rename.md
6464
- api/sign.md
65-
- api/attributes.md
6665
- api/exceptions.md
6766
- api/file.md
6867
- obstore.fsspec: api/fsspec.md
@@ -157,6 +156,7 @@ plugins:
157156
- https://arrow.apache.org/docs/objects.inv
158157
- https://boto3.amazonaws.com/v1/documentation/api/latest/objects.inv
159158
- https://botocore.amazonaws.com/v1/documentation/api/latest/objects.inv
159+
- https://developmentseed.org/obspec/latest/objects.inv
160160
- https://docs.aiohttp.org/en/stable/objects.inv
161161
- https://docs.pola.rs/api/python/stable/objects.inv
162162
- https://docs.python.org/3/objects.inv

obstore/python/obstore/_attributes.pyi

Lines changed: 0 additions & 47 deletions
This file was deleted.

obstore/python/obstore/_buffered.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import sys
22
from contextlib import AbstractAsyncContextManager, AbstractContextManager
33
from typing import Self
44

5-
from ._attributes import Attributes
5+
# TODO: fix import
6+
from obspec._attributes import Attributes
7+
68
from ._bytes import Bytes
79
from ._list import ObjectMeta
810
from .store import ObjectStore

obstore/python/obstore/_get.pyi

Lines changed: 10 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,13 @@
11
from collections.abc import Sequence
2-
from datetime import datetime
3-
from typing import TypedDict
42

5-
from ._attributes import Attributes
3+
# TODO: fix imports
4+
from obspec._attributes import Attributes
5+
from obspec._get import GetOptions
6+
67
from ._bytes import Bytes
78
from ._list import ObjectMeta
89
from .store import ObjectStore
910

10-
class OffsetRange(TypedDict):
11-
"""Request all bytes starting from a given byte offset."""
12-
13-
offset: int
14-
"""The byte offset for the offset range request."""
15-
16-
class SuffixRange(TypedDict):
17-
"""Request up to the last `n` bytes."""
18-
19-
suffix: int
20-
"""The number of bytes from the suffix to request."""
21-
22-
class GetOptions(TypedDict, total=False):
23-
"""Options for a get request.
24-
25-
All options are optional.
26-
"""
27-
28-
if_match: str | None
29-
"""
30-
Request will succeed if the `ObjectMeta::e_tag` matches
31-
otherwise returning [`PreconditionError`][obstore.exceptions.PreconditionError].
32-
33-
See <https://datatracker.ietf.org/doc/html/rfc9110#name-if-match>
34-
35-
Examples:
36-
37-
```text
38-
If-Match: "xyzzy"
39-
If-Match: "xyzzy", "r2d2xxxx", "c3piozzzz"
40-
If-Match: *
41-
```
42-
"""
43-
44-
if_none_match: str | None
45-
"""
46-
Request will succeed if the `ObjectMeta::e_tag` does not match
47-
otherwise returning [`NotModifiedError`][obstore.exceptions.NotModifiedError].
48-
49-
See <https://datatracker.ietf.org/doc/html/rfc9110#section-13.1.2>
50-
51-
Examples:
52-
53-
```text
54-
If-None-Match: "xyzzy"
55-
If-None-Match: "xyzzy", "r2d2xxxx", "c3piozzzz"
56-
If-None-Match: *
57-
```
58-
"""
59-
60-
if_unmodified_since: datetime | None
61-
"""
62-
Request will succeed if the object has been modified since
63-
64-
<https://datatracker.ietf.org/doc/html/rfc9110#section-13.1.3>
65-
"""
66-
67-
if_modified_since: datetime | None
68-
"""
69-
Request will succeed if the object has not been modified since
70-
otherwise returning [`PreconditionError`][obstore.exceptions.PreconditionError].
71-
72-
Some stores, such as S3, will only return `NotModified` for exact
73-
timestamp matches, instead of for any timestamp greater than or equal.
74-
75-
<https://datatracker.ietf.org/doc/html/rfc9110#section-13.1.4>
76-
"""
77-
78-
range: tuple[int, int] | list[int] | OffsetRange | SuffixRange
79-
"""
80-
Request transfer of only the specified range of bytes
81-
otherwise returning [`NotModifiedError`][obstore.exceptions.NotModifiedError].
82-
83-
The semantics of this tuple are:
84-
85-
- `(int, int)`: Request a specific range of bytes `(start, end)`.
86-
87-
If the given range is zero-length or starts after the end of the object, an
88-
error will be returned. Additionally, if the range ends after the end of the
89-
object, the entire remainder of the object will be returned. Otherwise, the
90-
exact requested range will be returned.
91-
92-
The `end` offset is _exclusive_.
93-
94-
- `{"offset": int}`: Request all bytes starting from a given byte offset.
95-
96-
This is equivalent to `bytes={int}-` as an HTTP header.
97-
98-
- `{"suffix": int}`: Request the last `int` bytes. Note that here, `int` is _the
99-
size of the request_, not the byte offset. This is equivalent to `bytes=-{int}`
100-
as an HTTP header.
101-
102-
<https://datatracker.ietf.org/doc/html/rfc9110#name-range>
103-
"""
104-
105-
version: str | None
106-
"""
107-
Request a particular object version
108-
"""
109-
110-
head: bool
111-
"""
112-
Request transfer of no content
113-
114-
<https://datatracker.ietf.org/doc/html/rfc9110#name-head>
115-
"""
116-
11711
class GetResult:
11812
"""Result for a get request.
11913
@@ -142,6 +36,9 @@ class GetResult:
14236
14337
Note that after calling `bytes`, `bytes_async`, or `stream`, you will no longer be
14438
able to call other methods on this object, such as the `meta` attribute.
39+
40+
This implements [`obspec.GetResult`][], but is redefined here to specialize the
41+
exact instance of the `bytes` return type to be [`obstore.Bytes`][].
14542
"""
14643

14744
@property
@@ -229,6 +126,9 @@ class BytesStream:
229126
230127
To fix this, set the `timeout` parameter in the
231128
[`client_options`][obstore.store.ClientConfig] passed when creating the store.
129+
130+
This implements [`obspec.BufferStream`][], but is redefined here to specialize the
131+
exact instance of the buffer return type to be [`obstore.Bytes`][].
232132
"""
233133

234134
def __aiter__(self) -> BytesStream:

obstore/python/obstore/_head.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
from ._list import ObjectMeta
1+
# TODO: fix improt
2+
from obspec._meta import ObjectMeta
3+
24
from .store import ObjectStore
35

46
def head(store: ObjectStore, path: str) -> ObjectMeta:

obstore/python/obstore/_list.pyi

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,23 @@
55
# ruff: noqa: A001
66
# Variable `list` is shadowing a Python builtinRuff
77

8-
from datetime import datetime
98
from typing import Generic, List, Literal, Self, TypedDict, TypeVar, overload
109

1110
from arro3.core import RecordBatch, Table
11+
from obspec._meta import ObjectMeta
1212

1313
from .store import ObjectStore
1414

15-
class ObjectMeta(TypedDict):
16-
"""The metadata that describes an object."""
17-
18-
path: str
19-
"""The full path to the object"""
20-
21-
last_modified: datetime
22-
"""The last modified time"""
23-
24-
size: int
25-
"""The size in bytes of the object"""
26-
27-
e_tag: str | None
28-
"""The unique identifier for the object
29-
30-
<https://datatracker.ietf.org/doc/html/rfc9110#name-etag>
31-
"""
32-
33-
version: str | None
34-
"""A version indicator for this object"""
35-
3615
ListChunkType = TypeVar("ListChunkType", List[ObjectMeta], RecordBatch, Table) # noqa: PYI001
3716
"""The data structure used for holding list results.
3817
39-
By default, listing APIs return a `list` of [`ObjectMeta`][obstore.ObjectMeta]. However
18+
By default, listing APIs return a `list` of [`ObjectMeta`][obspec.ObjectMeta]. However
4019
for improved performance when listing large buckets, you can pass `return_arrow=True`.
4120
Then an Arrow `RecordBatch` will be returned instead.
21+
22+
This implements [`obspec.ListChunkType_co`][], but is redefined here to specialize the
23+
exact instance of the Arrow return type, given that in the obstore implementation, an
24+
[`arro3.core.RecordBatch`][] or [`arro3.core.Table`][] will always be returned.
4225
"""
4326

4427
class ListResult(TypedDict, Generic[ListChunkType]):
@@ -47,6 +30,8 @@ class ListResult(TypedDict, Generic[ListChunkType]):
4730
Includes objects, prefixes (directories) and a token for the next set of results.
4831
Individual result sets may be limited to 1,000 objects based on the underlying
4932
object storage's limitations.
33+
34+
This implements [`obspec.ListResult`][].
5035
"""
5136

5237
common_prefixes: List[str]
@@ -56,8 +41,10 @@ class ListResult(TypedDict, Generic[ListChunkType]):
5641
"""Object metadata for the listing"""
5742

5843
class ListStream(Generic[ListChunkType]):
59-
"""A stream of [ObjectMeta][obstore.ObjectMeta] that can be polled in a sync or
44+
"""A stream of [ObjectMeta][obspec.ObjectMeta] that can be polled in a sync or
6045
async fashion.
46+
47+
This implements [`obspec.ListStream`][].
6148
""" # noqa: D205
6249

6350
def __aiter__(self) -> Self:
@@ -170,7 +157,7 @@ def list(
170157
```
171158
172159
!!! note
173-
The order of returned [`ObjectMeta`][obstore.ObjectMeta] is not
160+
The order of returned [`ObjectMeta`][obspec.ObjectMeta] is not
174161
guaranteed
175162
176163
!!! note

obstore/python/obstore/_obstore.pyi

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from ._attributes import Attribute as Attribute
2-
from ._attributes import Attributes as Attributes
31
from ._buffered import AsyncReadableFile as AsyncReadableFile
42
from ._buffered import AsyncWritableFile as AsyncWritableFile
53
from ._buffered import ReadableFile as ReadableFile
@@ -14,10 +12,7 @@ from ._copy import copy_async as copy_async
1412
from ._delete import delete as delete
1513
from ._delete import delete_async as delete_async
1614
from ._get import BytesStream as BytesStream
17-
from ._get import GetOptions as GetOptions
1815
from ._get import GetResult as GetResult
19-
from ._get import OffsetRange as OffsetRange
20-
from ._get import SuffixRange as SuffixRange
2116
from ._get import get as get
2217
from ._get import get_async as get_async
2318
from ._get import get_range as get_range
@@ -29,13 +24,9 @@ from ._head import head_async as head_async
2924
from ._list import ListChunkType as ListChunkType
3025
from ._list import ListResult as ListResult
3126
from ._list import ListStream as ListStream
32-
from ._list import ObjectMeta as ObjectMeta
3327
from ._list import list as list # noqa: A004
3428
from ._list import list_with_delimiter as list_with_delimiter
3529
from ._list import list_with_delimiter_async as list_with_delimiter_async
36-
from ._put import PutMode as PutMode
37-
from ._put import PutResult as PutResult
38-
from ._put import UpdateVersion as UpdateVersion
3930
from ._put import put as put
4031
from ._put import put_async as put_async
4132
from ._rename import rename as rename

0 commit comments

Comments
 (0)