Skip to content

Commit 35eaf11

Browse files
authored
Allow obstore.store input into tiff class (#53)
* Allow obstore.store input to store method * Allow obstore type check
1 parent 355f377 commit 35eaf11

File tree

6 files changed

+99
-7
lines changed

6 files changed

+99
-7
lines changed

python/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ object_store = "0.12"
2323
pyo3 = { version = "0.23.0", features = ["macros"] }
2424
pyo3-async-runtimes = "0.23"
2525
pyo3-bytes = "0.1.3"
26-
pyo3-object_store = "0.1.0-beta.2"
26+
pyo3-object_store = "0.1.0-beta.4"
2727
rayon = "1.10.0"
2828
tokio-rayon = "2.1.0"
2929
thiserror = "1"

python/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ dev-dependencies = [
3131
"mkdocstrings-python>=1.13.0",
3232
"mkdocstrings>=0.27.0",
3333
"numpy>=1",
34+
"obstore",
3435
"pip>=24.2",
3536
"pytest-asyncio>=0.24.0",
3637
"pytest>=8.3.3",

python/python/async_tiff/_tiff.pyi

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
import obstore
12
from ._tile import Tile
23
from ._ifd import ImageFileDirectory
34
from .store import ObjectStore
45

56
class TIFF:
67
@classmethod
78
async def open(
8-
cls, path: str, *, store: ObjectStore, prefetch: int | None = 16384
9+
cls,
10+
path: str,
11+
*,
12+
store: obstore.store.ObjectStore | ObjectStore,
13+
prefetch: int | None = 16384,
914
) -> TIFF: ...
1015
@property
1116
def ifds(self) -> list[ImageFileDirectory]: ...

python/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ fn _async_tiff(py: Python, m: &Bound<PyModule>) -> PyResult<()> {
5454
m.add_class::<PyThreadPool>()?;
5555
m.add_class::<PyTIFF>()?;
5656

57-
pyo3_object_store::register_store_module(py, m, "async_tiff")?;
58-
pyo3_object_store::register_exceptions_module(py, m, "async_tiff")?;
57+
pyo3_object_store::register_store_module(py, m, "async_tiff", "store")?;
58+
pyo3_object_store::register_exceptions_module(py, m, "async_tiff", "exceptions")?;
5959

6060
Ok(())
6161
}

python/src/tiff.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use pyo3::exceptions::PyIndexError;
66
use pyo3::prelude::*;
77
use pyo3::types::PyType;
88
use pyo3_async_runtimes::tokio::future_into_py;
9-
use pyo3_object_store::PyObjectStore;
9+
use pyo3_object_store::AnyObjectStore;
1010

1111
use crate::tile::PyTile;
1212
use crate::PyImageFileDirectory;
@@ -25,10 +25,10 @@ impl PyTIFF {
2525
_cls: &'py Bound<PyType>,
2626
py: Python<'py>,
2727
path: String,
28-
store: PyObjectStore,
28+
store: AnyObjectStore,
2929
prefetch: Option<u64>,
3030
) -> PyResult<Bound<'py, PyAny>> {
31-
let reader = ObjectReader::new(store.into_inner(), path.into());
31+
let reader = ObjectReader::new(store.into_dyn(), path.into());
3232
let object_reader = reader.clone();
3333

3434
let cog_reader = future_into_py(py, async move {

0 commit comments

Comments
 (0)