Browse Source

Replace `pythonize` with `pyarrow`

tags/v0.2.5-alpha.2
haixuanTao 3 years ago
parent
commit
0a853032fc
2 changed files with 7 additions and 10 deletions
  1. +2
    -3
      python/Cargo.toml
  2. +5
    -7
      python/src/lib.rs

+ 2
- 3
python/Cargo.toml View File

@@ -7,13 +7,12 @@ edition = "2021"
[dependencies]
dora-ros2-bridge = { path = "..", default-features = false }
dora-ros2-bridge-msg-gen = { path = "../msg-gen" }
pyo3 = { version = "0.18", features = ["eyre", "abi3-py37", "serde"] }
pyo3 = { version = "0.19", features = ["eyre", "abi3-py37", "serde"] }
eyre = "0.6"
serde = "1.0.166"
serde_yaml = "0.8.23"
flume = "0.10.14"
arrow = { version = "35.0.0", features = ["pyarrow"] }
pythonize = "0.18.0"
arrow = { version = "45.0.0", features = ["pyarrow"] }

[lib]
name = "dora_ros2_bridge"


+ 5
- 7
python/src/lib.rs View File

@@ -6,6 +6,7 @@ use std::{
};

use ::dora_ros2_bridge::{ros2_client, rustdds};
use arrow::pyarrow::{FromPyArrow, ToPyArrow};
use dora_ros2_bridge_msg_gen::types::Message;
use eyre::{eyre, Context, ContextCompat};
use pyo3::{
@@ -182,10 +183,9 @@ pub struct Ros2Publisher {
impl Ros2Publisher {
pub fn publish(&self, data: &PyAny) -> eyre::Result<()> {
// TODO: add support for arrow types
let value = pythonize::depythonize(data).context("failed to depythonize data")?;

// add type info to ensure correct serialization (e.g. struct types
// and map types need to be serialized differently)
let value = arrow::array::ArrayData::from_pyarrow(data)?;
//// add type info to ensure correct serialization (e.g. struct types
//// and map types need to be serialized differently)
let typed_value = TypedValue {
value: &value,
type_info: &self.type_info,
@@ -217,9 +217,7 @@ impl Ros2Subscription {
return Ok(None)
};

let message =
pythonize::pythonize(py, value.deref()).context("failed to pythonize value")?;

let message = value.to_pyarrow(py)?;
// TODO: add `info`

Ok(Some(message))


Loading…
Cancel
Save