From 852417a270f16db57208fd0a6a16c3d4f4389b17 Mon Sep 17 00:00:00 2001 From: Shar-jeel-Sajid Date: Tue, 11 Mar 2025 19:00:41 +0500 Subject: [PATCH] replacing to_object --- apis/python/operator/src/lib.rs | 48 +++++++++++++++++++++---- binaries/runtime/src/operator/python.rs | 2 +- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/apis/python/operator/src/lib.rs b/apis/python/operator/src/lib.rs index e73b625b..16165cda 100644 --- a/apis/python/operator/src/lib.rs +++ b/apis/python/operator/src/lib.rs @@ -81,15 +81,41 @@ impl PyEvent { pub fn to_py_dict(self, py: Python<'_>) -> PyResult> { let mut pydict = HashMap::new(); match &self.event { - MergedEvent::Dora(_) => pydict.insert("kind", "dora".to_object(py)), - MergedEvent::External(_) => pydict.insert("kind", "external".to_object(py)), + MergedEvent::Dora(_) => pydict.insert( + "kind", + "dora" + .into_pyobject(py) + .context("Failed to create pystring")? + .unbind() + .into(), + ), + MergedEvent::External(_) => pydict.insert( + "kind", + "external" + .into_pyobject(py) + .context("Failed to create pystring")? + .unbind() + .into(), + ), }; match &self.event { MergedEvent::Dora(event) => { if let Some(id) = Self::id(event) { - pydict.insert("id", id.into_py(py)); + pydict.insert( + "id", + id.into_pyobject(py) + .context("Failed to create id pyobject")? + .into(), + ); } - pydict.insert("type", Self::ty(event).to_object(py)); + pydict.insert( + "type", + Self::ty(event) + .into_pyobject(py) + .context("Failed to create event pyobject")? + .unbind() + .into(), + ); if let Some(value) = self.value(py)? { pydict.insert("value", value); @@ -98,7 +124,14 @@ impl PyEvent { pydict.insert("metadata", metadata); } if let Some(error) = Self::error(event) { - pydict.insert("error", error.to_object(py)); + pydict.insert( + "error", + error + .into_pyobject(py) + .context("Failed to create error pyobject")? + .unbind() + .into(), + ); } } MergedEvent::External(event) => { @@ -151,7 +184,10 @@ impl PyEvent { Event::Input { metadata, .. } => Ok(Some( metadata_to_pydict(metadata, py) .context("Issue deserializing metadata")? - .to_object(py), + .into_pyobject(py) + .context("Failed to create metadata_to_pydice")? + .unbind() + .into(), )), _ => Ok(None), } diff --git a/binaries/runtime/src/operator/python.rs b/binaries/runtime/src/operator/python.rs index 93e918bd..b6895bda 100644 --- a/binaries/runtime/src/operator/python.rs +++ b/binaries/runtime/src/operator/python.rs @@ -24,7 +24,7 @@ use tokio::sync::{mpsc::Sender, oneshot}; use tracing::{error, field, span, warn}; fn traceback(err: pyo3::PyErr) -> eyre::Report { - let traceback = Python::with_gil(|py| err.traceback_bound(py).and_then(|t| t.format().ok())); + let traceback = Python::with_gil(|py| err.traceback(py).and_then(|t| t.format().ok())); if let Some(traceback) = traceback { eyre::eyre!("{traceback}\n{err}") } else {