Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions obstore/python/obstore/_get.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ else:
from typing_extensions import Buffer as _Buffer

class GetOptions(TypedDict, total=False):
"""Options for a get request, such as range.
"""Options for a get request.

All options are optional.
"""
Expand Down Expand Up @@ -67,7 +67,7 @@ class GetOptions(TypedDict, total=False):
<https://datatracker.ietf.org/doc/html/rfc9110#section-13.1.4>
"""

range: Tuple[int | None, int | None]
# range: Tuple[int | None, int | None]
"""
Request transfer of only the specified range of bytes
otherwise returning [`Error::NotModified`]
Expand Down Expand Up @@ -161,7 +161,7 @@ class GetResult:
"""

@property
def range(self) -> ObjectMeta:
def range(self) -> Tuple[int, int]:
"""The range of bytes returned by this request.

This must be accessed _before_ calling `stream`, `bytes`, or `bytes_async`.
Expand Down
10 changes: 7 additions & 3 deletions obstore/src/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ pub(crate) struct PyGetOptions {
if_none_match: Option<String>,
if_modified_since: Option<DateTime<Utc>>,
if_unmodified_since: Option<DateTime<Utc>>,
range: Option<PyGetRange>,
// Taking out of public API until we can decide the right way to expose this
// range: Option<PyGetRange>,
version: Option<String>,
head: bool,
}
Expand All @@ -48,7 +49,7 @@ impl<'py> FromPyObject<'py> for PyGetOptions {
.get("if_unmodified_since")
.map(|x| x.extract())
.transpose()?,
range: dict.get("range").map(|x| x.extract()).transpose()?,
// range: dict.get("range").map(|x| x.extract()).transpose()?,
version: dict.get("version").map(|x| x.extract()).transpose()?,
head: dict
.get("head")
Expand All @@ -66,15 +67,18 @@ impl From<PyGetOptions> for GetOptions {
if_none_match: value.if_none_match,
if_modified_since: value.if_modified_since,
if_unmodified_since: value.if_unmodified_since,
range: value.range.map(|x| x.0),
range: Default::default(),
version: value.version,
head: value.head,
}
}
}

#[allow(dead_code)]
pub(crate) struct PyGetRange(GetRange);

// TODO: think of a better API here so that the distinction between each of these is easy to
// understand.
impl<'py> FromPyObject<'py> for PyGetRange {
fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult<Self> {
let range = ob.extract::<[Option<usize>; 2]>()?;
Expand Down
1 change: 1 addition & 0 deletions tests/test_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ async def test_stream_async():
assert pos == len(data)


@pytest.mark.skip("Skip until we restore range in get_options")
def test_get_with_options():
store = MemoryStore()

Expand Down