Skip to content

Commit a2ca349

Browse files
authored
feat: upgrade object store 0.13.x (#600)
* bump dependencies * Update error shape * Embrace ObjectStoreExt
1 parent aec2ed5 commit a2ca349

11 files changed

Lines changed: 45 additions & 87 deletions

File tree

Cargo.lock

Lines changed: 3 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ chrono = "0.4.38"
2626
futures = "0.3.31"
2727
http = "1.2"
2828
indexmap = "2"
29-
object_store = "0.12.4"
29+
object_store = { version = "0.13.0", features = ["aws", "azure", "gcp", "http"] }
3030
pyo3 = { version = "0.27.1", features = ["macros", "indexmap"] }
3131
pyo3-async-runtimes = { version = "0.27", features = ["tokio-runtime"] }
3232
pyo3-file = { git = "https://github.com/kylebarron/pyo3-file", rev = "aacc18816591f9987247bac8b7011b452b4eeb3e" }

obstore/src/buffered.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::sync::Arc;
33

44
use bytes::Bytes;
55
use object_store::buffered::{BufReader, BufWriter};
6-
use object_store::{ObjectMeta, ObjectStore};
6+
use object_store::{ObjectMeta, ObjectStore, ObjectStoreExt};
77
use pyo3::exceptions::{PyIOError, PyStopAsyncIteration, PyStopIteration};
88
use pyo3::prelude::*;
99
use pyo3::types::PyString;

obstore/src/copy.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use object_store::ObjectStore;
1+
use std::{future::Future, pin::Pin};
2+
3+
use object_store::ObjectStoreExt;
24
use pyo3::prelude::*;
35
use pyo3_async_runtimes::tokio::get_runtime;
46
use pyo3_object_store::{PyObjectStore, PyObjectStoreError, PyObjectStoreResult};
@@ -18,10 +20,10 @@ pub(crate) fn copy(
1820
let from_ = from_.into();
1921
let to = to.into();
2022
py.detach(|| {
21-
let fut = if overwrite {
22-
store.as_ref().copy(&from_, &to)
23+
let fut: Pin<Box<dyn Future<Output = _> + Send>> = if overwrite {
24+
Box::pin(store.as_ref().copy(&from_, &to))
2325
} else {
24-
store.as_ref().copy_if_not_exists(&from_, &to)
26+
Box::pin(store.as_ref().copy_if_not_exists(&from_, &to))
2527
};
2628
runtime.block_on(fut)?;
2729
Ok::<_, PyObjectStoreError>(())
@@ -40,10 +42,10 @@ pub(crate) fn copy_async(
4042
let from_ = from_.into();
4143
let to = to.into();
4244
pyo3_async_runtimes::tokio::future_into_py(py, async move {
43-
let fut = if overwrite {
44-
store.as_ref().copy(&from_, &to)
45+
let fut: Pin<Box<dyn Future<Output = _> + Send>> = if overwrite {
46+
Box::pin(store.as_ref().copy(&from_, &to))
4547
} else {
46-
store.as_ref().copy_if_not_exists(&from_, &to)
48+
Box::pin(store.as_ref().copy_if_not_exists(&from_, &to))
4749
};
4850
fut.await.map_err(PyObjectStoreError::ObjectStoreError)?;
4951
Ok(PyNone)

obstore/src/delete.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use futures::{StreamExt, TryStreamExt};
2+
use object_store::ObjectStoreExt;
23
use pyo3::prelude::*;
34
use pyo3_async_runtimes::tokio::get_runtime;
45
use pyo3_object_store::{PyObjectStore, PyObjectStoreError, PyObjectStoreResult};

obstore/src/get.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ use bytes::Bytes;
66
use chrono::{DateTime, Utc};
77
use futures::stream::{BoxStream, Fuse};
88
use futures::StreamExt;
9-
use object_store::{Attributes, GetOptions, GetRange, GetResult, ObjectMeta, ObjectStore};
9+
use object_store::{
10+
Attributes, GetOptions, GetRange, GetResult, ObjectMeta, ObjectStore, ObjectStoreExt,
11+
};
1012
use pyo3::exceptions::{PyStopAsyncIteration, PyStopIteration, PyValueError};
1113
use pyo3::prelude::*;
1214
use pyo3_async_runtimes::tokio::get_runtime;
@@ -347,7 +349,7 @@ pub(crate) fn get(
347349
let fut = if let Some(options) = options {
348350
store.as_ref().get_opts(path, options.into())
349351
} else {
350-
store.as_ref().get(path)
352+
Box::pin(store.as_ref().get(path))
351353
};
352354
let out = runtime.block_on(fut)?;
353355
Ok::<_, PyObjectStoreError>(PyGetResult::new(out))
@@ -367,7 +369,7 @@ pub(crate) fn get_async(
367369
let fut = if let Some(options) = options {
368370
store.as_ref().get_opts(path, options.into())
369371
} else {
370-
store.as_ref().get(path)
372+
Box::pin(store.as_ref().get(path))
371373
};
372374
let out = fut.await.map_err(PyObjectStoreError::ObjectStoreError)?;
373375
Ok(PyGetResult::new(out))

obstore/src/head.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use object_store::ObjectStoreExt;
12
use pyo3::prelude::*;
23
use pyo3_async_runtimes::tokio::get_runtime;
34
use pyo3_object_store::{PyObjectStore, PyObjectStoreError, PyObjectStoreResult, PyPath};

obstore/src/rename.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use object_store::ObjectStore;
1+
use std::{future::Future, pin::Pin};
2+
3+
use object_store::ObjectStoreExt;
24
use pyo3::prelude::*;
35
use pyo3_async_runtimes::tokio::get_runtime;
46
use pyo3_object_store::{PyObjectStore, PyObjectStoreError, PyObjectStoreResult};
@@ -18,10 +20,10 @@ pub(crate) fn rename(
1820
let from_ = from_.into();
1921
let to = to.into();
2022
py.detach(|| {
21-
let fut = if overwrite {
22-
store.as_ref().rename(&from_, &to)
23+
let fut: Pin<Box<dyn Future<Output = _> + Send>> = if overwrite {
24+
Box::pin(store.as_ref().rename(&from_, &to))
2325
} else {
24-
store.as_ref().rename_if_not_exists(&from_, &to)
26+
Box::pin(store.as_ref().rename_if_not_exists(&from_, &to))
2527
};
2628
runtime.block_on(fut)?;
2729
Ok::<_, PyObjectStoreError>(())
@@ -40,10 +42,10 @@ pub(crate) fn rename_async(
4042
let from_ = from_.into();
4143
let to = to.into();
4244
pyo3_async_runtimes::tokio::future_into_py(py, async move {
43-
let fut = if overwrite {
44-
store.as_ref().rename(&from_, &to)
45+
let fut: Pin<Box<dyn Future<Output = _> + Send>> = if overwrite {
46+
Box::pin(store.as_ref().rename(&from_, &to))
4547
} else {
46-
store.as_ref().rename_if_not_exists(&from_, &to)
48+
Box::pin(store.as_ref().rename_if_not_exists(&from_, &to))
4749
};
4850
fut.await.map_err(PyObjectStoreError::ObjectStoreError)?;
4951
Ok(PyNone)

pyo3-object_store/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ humantime = "2.1"
2828
http = "1"
2929
# This is already an object_store dependency
3030
itertools = "0.14.0"
31-
object_store = { version = "0.12.4", features = [
31+
object_store = { version = "0.13.0", features = [
3232
"aws",
3333
"azure",
3434
"gcp",

pyo3-object_store/src/error.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,10 @@ impl From<PyObjectStoreError> for PyErr {
131131
object_store::Error::NotModified { path: _, source: _ } => {
132132
NotModifiedError::new_err(print_with_debug(err))
133133
}
134-
object_store::Error::NotImplemented => {
135-
PyNotImplementedError::new_err(print_with_debug(err))
136-
}
134+
object_store::Error::NotImplemented {
135+
operation: _,
136+
implementer: _,
137+
} => PyNotImplementedError::new_err(print_with_debug(err)),
137138
object_store::Error::PermissionDenied { path: _, source: _ } => {
138139
PermissionDeniedError::new_err(print_with_debug(err))
139140
}

0 commit comments

Comments
 (0)