Skip to content

Commit cf047af

Browse files
authored
chore: upgrade pyo3 to 0.27 (from 0.26) (#286)
Signed-off-by: Vigith Maurice <[email protected]>
1 parent b0c7e7b commit cf047af

File tree

7 files changed

+19
-19
lines changed

7 files changed

+19
-19
lines changed

packages/pynumaflow-lite/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ crate-type = ["cdylib", "rlib"]
1010

1111
[dependencies]
1212
numaflow = { git = "https://github.com/numaproj/numaflow-rs.git", rev = "fde3deafea634abbc347032ff409d33d4e1514b1" }
13-
pyo3 = { version = "0.26.0", features = ["chrono", "experimental-inspect"] }
13+
pyo3 = { version = "0.27.1", features = ["chrono", "experimental-inspect"] }
1414
tokio = "1.47.1"
1515
tonic = "0.14.2"
1616
tokio-stream = "0.1.17"
1717
tower = "0.5.2"
1818
hyper-util = "0.1.16"
1919
prost-types = "0.14.1"
2020
chrono = "0.4.42"
21-
pyo3-async-runtimes = { version = "0.26.0", features = ["tokio-runtime"] }
21+
pyo3-async-runtimes = { version = "0.27.0", features = ["tokio-runtime"] }
2222
futures-core = "0.3.31"
2323
pin-project = "1.1.10"
2424

packages/pynumaflow-lite/src/accumulate/server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl accumulator::AccumulatorCreator for PyAccumulatorCreator {
3333
match &self.init_args {
3434
Some(args) => {
3535
let bound = args.as_ref().bind(py);
36-
let py_tuple = bound.downcast::<PyTuple>()?;
36+
let py_tuple = bound.cast::<PyTuple>()?;
3737
class.call1(py, py_tuple)
3838
}
3939
None => class.call0(py),
@@ -82,7 +82,7 @@ impl accumulator::Accumulator for PyAccumulatorRunner {
8282
.expect("python handler method raised before returning async iterable");
8383

8484
// Keep as Py<PyAny>
85-
agen.extract(py).unwrap_or(agen)
85+
agen.clone_ref(py).extract(py).unwrap_or(agen)
8686
});
8787

8888
// Wrap the Python AsyncIterable in a Rust Stream that yields incrementally

packages/pynumaflow-lite/src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ fn pynumaflow_lite(py: Python, m: &Bound<PyModule>) -> PyResult<()> {
8282

8383
// Ensure it's importable as `pynumaflow_lite.mapper` as well as attribute access
8484
let binding = m.getattr("mapper")?;
85-
let sub = binding.downcast::<PyModule>()?;
85+
let sub = binding.cast::<PyModule>()?;
8686
let fullname = "pynumaflow_lite.mapper";
8787
sub.setattr("__name__", fullname)?;
8888
py.import("sys")?
@@ -91,7 +91,7 @@ fn pynumaflow_lite(py: Python, m: &Bound<PyModule>) -> PyResult<()> {
9191

9292
// Ensure it's importable as `pynumaflow_lite.batchmapper` as well
9393
let binding = m.getattr("batchmapper")?;
94-
let sub = binding.downcast::<PyModule>()?;
94+
let sub = binding.cast::<PyModule>()?;
9595
let fullname = "pynumaflow_lite.batchmapper";
9696
sub.setattr("__name__", fullname)?;
9797
py.import("sys")?
@@ -100,7 +100,7 @@ fn pynumaflow_lite(py: Python, m: &Bound<PyModule>) -> PyResult<()> {
100100

101101
// Ensure it's importable as `pynumaflow_lite.mapstreamer` as well
102102
let binding = m.getattr("mapstreamer")?;
103-
let sub = binding.downcast::<PyModule>()?;
103+
let sub = binding.cast::<PyModule>()?;
104104
let fullname = "pynumaflow_lite.mapstreamer";
105105
sub.setattr("__name__", fullname)?;
106106
py.import("sys")?
@@ -109,7 +109,7 @@ fn pynumaflow_lite(py: Python, m: &Bound<PyModule>) -> PyResult<()> {
109109

110110
// Ensure it's importable as `pynumaflow_lite.reducer` as well
111111
let binding = m.getattr("reducer")?;
112-
let sub = binding.downcast::<PyModule>()?;
112+
let sub = binding.cast::<PyModule>()?;
113113
let fullname = "pynumaflow_lite.reducer";
114114
sub.setattr("__name__", fullname)?;
115115
py.import("sys")?
@@ -118,7 +118,7 @@ fn pynumaflow_lite(py: Python, m: &Bound<PyModule>) -> PyResult<()> {
118118

119119
// Ensure it's importable as `pynumaflow_lite.session_reducer` as well
120120
let binding = m.getattr("session_reducer")?;
121-
let sub = binding.downcast::<PyModule>()?;
121+
let sub = binding.cast::<PyModule>()?;
122122
let fullname = "pynumaflow_lite.session_reducer";
123123
sub.setattr("__name__", fullname)?;
124124
py.import("sys")?
@@ -127,7 +127,7 @@ fn pynumaflow_lite(py: Python, m: &Bound<PyModule>) -> PyResult<()> {
127127

128128
// Ensure it's importable as `pynumaflow_lite.accumulator` as well
129129
let binding = m.getattr("accumulator")?;
130-
let sub = binding.downcast::<PyModule>()?;
130+
let sub = binding.cast::<PyModule>()?;
131131
let fullname = "pynumaflow_lite.accumulator";
132132
sub.setattr("__name__", fullname)?;
133133
py.import("sys")?
@@ -136,7 +136,7 @@ fn pynumaflow_lite(py: Python, m: &Bound<PyModule>) -> PyResult<()> {
136136

137137
// Ensure it's importable as `pynumaflow_lite.sinker` as well
138138
let binding = m.getattr("sinker")?;
139-
let sub = binding.downcast::<PyModule>()?;
139+
let sub = binding.cast::<PyModule>()?;
140140
let fullname = "pynumaflow_lite.sinker";
141141
sub.setattr("__name__", fullname)?;
142142
py.import("sys")?
@@ -145,7 +145,7 @@ fn pynumaflow_lite(py: Python, m: &Bound<PyModule>) -> PyResult<()> {
145145

146146
// Ensure it's importable as `pynumaflow_lite.sourcer` as well
147147
let binding = m.getattr("sourcer")?;
148-
let sub = binding.downcast::<PyModule>()?;
148+
let sub = binding.cast::<PyModule>()?;
149149
let fullname = "pynumaflow_lite.sourcer";
150150
sub.setattr("__name__", fullname)?;
151151
py.import("sys")?

packages/pynumaflow-lite/src/mapstream/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl mapstream::MapStreamer for PyMapStreamRunner {
2727
.call1(py, (keys, datum))
2828
.expect("python handler raised before returning async iterable");
2929
// Keep as Py<PyAny>
30-
agen.extract(py).unwrap_or(agen)
30+
agen.clone_ref(py).extract(py).unwrap_or(agen)
3131
});
3232

3333
// Wrap the Python AsyncIterable in a Rust Stream that yields incrementally

packages/pynumaflow-lite/src/pyiterables.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub struct PyAsyncIterStream<M> {
3131

3232
impl<M> PyAsyncIterStream<M>
3333
where
34-
M: for<'py> FromPyObject<'py> + Send + 'static,
34+
M: for<'a, 'py> FromPyObject<'a, 'py> + Send + 'static,
3535
{
3636
/// Given a Python AsyncIterator and the event loop, build a stream over its items.
3737
/// It calls `__aiter__` on the `async_iterable` to get the iterator.
@@ -48,7 +48,7 @@ where
4848

4949
impl<M> Stream for PyAsyncIterStream<M>
5050
where
51-
M: for<'py> FromPyObject<'py> + Send + 'static,
51+
M: for<'a, 'py> FromPyObject<'a, 'py> + Send + 'static,
5252
{
5353
type Item = PyResult<M>;
5454

@@ -117,7 +117,7 @@ where
117117
match res {
118118
Ok(obj) => {
119119
// Convert PyObject -> M
120-
let m = Python::attach(|py| obj.extract::<M>(py));
120+
let m = Python::attach(|py| obj.extract::<M>(py).map_err(Into::into));
121121
Poll::Ready(Some(m))
122122
}
123123
Err(err) => {

packages/pynumaflow-lite/src/reduce/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl reduce::ReducerCreator for PyReduceCreator {
4343
match &self.init_args {
4444
Some(args) => {
4545
let bound = args.as_ref().bind(py);
46-
let py_tuple = bound.downcast::<PyTuple>()?;
46+
let py_tuple = bound.cast::<PyTuple>()?;
4747
class.call1(py, py_tuple)
4848
}
4949
None => class.call0(py),

packages/pynumaflow-lite/src/session_reduce/server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl session_reduce::SessionReducerCreator for PySessionReduceCreator {
3333
match &self.init_args {
3434
Some(args) => {
3535
let bound = args.as_ref().bind(py);
36-
let py_tuple = bound.downcast::<PyTuple>()?;
36+
let py_tuple = bound.cast::<PyTuple>()?;
3737
class.call1(py, py_tuple)
3838
}
3939
None => class.call0(py),
@@ -83,7 +83,7 @@ impl session_reduce::SessionReducer for PySessionReduceRunner {
8383
.expect("python session_reduce method raised before returning async iterable");
8484

8585
// Keep as Py<PyAny>
86-
agen.extract(py).unwrap_or(agen)
86+
agen.clone_ref(py).extract(py).unwrap_or(agen)
8787
});
8888

8989
// Wrap the Python AsyncIterable in a Rust Stream that yields incrementally

0 commit comments

Comments
 (0)