| @@ -87,10 +87,6 @@ mod ffi { | |||||
| } | } | ||||
| } | } | ||||
| mod arrow_ffi { | |||||
| pub use arrow::ffi::{FFI_ArrowArray, FFI_ArrowSchema}; | |||||
| } | |||||
| #[cfg(feature = "ros2-bridge")] | #[cfg(feature = "ros2-bridge")] | ||||
| pub mod ros2 { | pub mod ros2 { | ||||
| pub use dora_ros2_bridge::*; | pub use dora_ros2_bridge::*; | ||||
| @@ -215,7 +211,7 @@ unsafe fn event_as_arrow_input( | |||||
| } | } | ||||
| } | } | ||||
| Err(e) => ffi::DoraResult { | Err(e) => ffi::DoraResult { | ||||
| error: format!("Error exporting Arrow array to C++: {:?}", e), | |||||
| error: format!("Error exporting Arrow array to C++: {e:?}"), | |||||
| }, | }, | ||||
| } | } | ||||
| } | } | ||||
| @@ -276,7 +272,7 @@ unsafe fn send_arrow_output( | |||||
| } | } | ||||
| } | } | ||||
| Err(e) => ffi::DoraResult { | Err(e) => ffi::DoraResult { | ||||
| error: format!("Error importing array from C++: {:?}", e), | |||||
| error: format!("Error importing array from C++: {e:?}"), | |||||
| }, | }, | ||||
| } | } | ||||
| } | } | ||||
| @@ -320,6 +320,7 @@ impl Events { | |||||
| } | } | ||||
| } | } | ||||
| #[allow(clippy::large_enum_variant)] | |||||
| enum EventsInner { | enum EventsInner { | ||||
| Dora(EventStream), | Dora(EventStream), | ||||
| Merged(Box<dyn Stream<Item = MergedEvent<PyObject>> + Unpin + Send + Sync>), | Merged(Box<dyn Stream<Item = MergedEvent<PyObject>> + Unpin + Send + Sync>), | ||||
| @@ -214,25 +214,13 @@ pub fn pydict_to_metadata(dict: Option<Bound<'_, PyDict>>) -> Result<MetadataPar | |||||
| parameters.insert(key, Parameter::Float(value.extract::<f64>()?)) | parameters.insert(key, Parameter::Float(value.extract::<f64>()?)) | ||||
| } else if value.is_instance_of::<PyString>() { | } else if value.is_instance_of::<PyString>() { | ||||
| parameters.insert(key, Parameter::String(value.extract()?)) | parameters.insert(key, Parameter::String(value.extract()?)) | ||||
| } else if value.is_instance_of::<PyTuple>() | |||||
| } else if (value.is_instance_of::<PyTuple>() || value.is_instance_of::<PyList>()) | |||||
| && value.len()? > 0 | && value.len()? > 0 | ||||
| && value.get_item(0)?.is_exact_instance_of::<PyInt>() | && value.get_item(0)?.is_exact_instance_of::<PyInt>() | ||||
| { | { | ||||
| let list: Vec<i64> = value.extract()?; | let list: Vec<i64> = value.extract()?; | ||||
| parameters.insert(key, Parameter::ListInt(list)) | parameters.insert(key, Parameter::ListInt(list)) | ||||
| } else if value.is_instance_of::<PyList>() | |||||
| && value.len()? > 0 | |||||
| && value.get_item(0)?.is_exact_instance_of::<PyInt>() | |||||
| { | |||||
| let list: Vec<i64> = value.extract()?; | |||||
| parameters.insert(key, Parameter::ListInt(list)) | |||||
| } else if value.is_instance_of::<PyTuple>() | |||||
| && value.len()? > 0 | |||||
| && value.get_item(0)?.is_exact_instance_of::<PyFloat>() | |||||
| { | |||||
| let list: Vec<f64> = value.extract()?; | |||||
| parameters.insert(key, Parameter::ListFloat(list)) | |||||
| } else if value.is_instance_of::<PyList>() | |||||
| } else if (value.is_instance_of::<PyTuple>() || value.is_instance_of::<PyList>()) | |||||
| && value.len()? > 0 | && value.len()? > 0 | ||||
| && value.get_item(0)?.is_exact_instance_of::<PyFloat>() | && value.get_item(0)?.is_exact_instance_of::<PyFloat>() | ||||
| { | { | ||||
| @@ -8,6 +8,7 @@ use futures_concurrency::stream::Merge; | |||||
| /// A Dora event or an event from an external source. | /// A Dora event or an event from an external source. | ||||
| #[derive(Debug)] | #[derive(Debug)] | ||||
| #[allow(clippy::large_enum_variant)] | |||||
| pub enum MergedEvent<E> { | pub enum MergedEvent<E> { | ||||
| /// A Dora event | /// A Dora event | ||||
| Dora(super::Event), | Dora(super::Event), | ||||
| @@ -55,25 +55,24 @@ impl Executable for SelfSubCommand { | |||||
| ); | ); | ||||
| } else { | } else { | ||||
| println!( | println!( | ||||
| "Dora CLI is already at the latest version: {}", | |||||
| current_version | |||||
| "Dora CLI is already at the latest version: {current_version}" | |||||
| ); | ); | ||||
| } | } | ||||
| } | } | ||||
| Err(e) => println!("Failed to check for updates: {}", e), | |||||
| Err(e) => println!("Failed to check for updates: {e}"), | |||||
| } | } | ||||
| } else { | } else { | ||||
| // Perform the actual update | // Perform the actual update | ||||
| match status.update() { | match status.update() { | ||||
| Ok(update_status) => match update_status { | Ok(update_status) => match update_status { | ||||
| self_update::Status::UpToDate(version) => { | self_update::Status::UpToDate(version) => { | ||||
| println!("Dora CLI is already at the latest version: {}", version); | |||||
| println!("Dora CLI is already at the latest version: {version}"); | |||||
| } | } | ||||
| self_update::Status::Updated(version) => { | self_update::Status::Updated(version) => { | ||||
| println!("Successfully updated Dora CLI to version: {}", version); | |||||
| println!("Successfully updated Dora CLI to version: {version}"); | |||||
| } | } | ||||
| }, | }, | ||||
| Err(e) => println!("Failed to update: {}", e), | |||||
| Err(e) => println!("Failed to update: {e}"), | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -1070,7 +1070,7 @@ impl Daemon { | |||||
| for task in tasks { | for task in tasks { | ||||
| let NodeBuildTask { | let NodeBuildTask { | ||||
| node_id, | node_id, | ||||
| dynamic_node, | |||||
| dynamic_node: _, | |||||
| task, | task, | ||||
| } = task; | } = task; | ||||
| let node = task | let node = task | ||||
| @@ -2680,6 +2680,7 @@ impl Event { | |||||
| } | } | ||||
| #[derive(Debug)] | #[derive(Debug)] | ||||
| #[allow(clippy::large_enum_variant)] | |||||
| pub enum DaemonNodeEvent { | pub enum DaemonNodeEvent { | ||||
| OutputsDone { | OutputsDone { | ||||
| reply_sender: oneshot::Sender<DaemonReply>, | reply_sender: oneshot::Sender<DaemonReply>, | ||||
| @@ -416,7 +416,7 @@ struct Indent<'a>(&'a str); | |||||
| impl std::fmt::Display for Indent<'_> { | impl std::fmt::Display for Indent<'_> { | ||||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||||
| for line in self.0.lines() { | for line in self.0.lines() { | ||||
| write!(f, " {}", line)?; | |||||
| write!(f, " {line}")?; | |||||
| } | } | ||||
| Ok(()) | Ok(()) | ||||
| } | } | ||||
| @@ -152,7 +152,7 @@ pub async fn spawn_listener_loop( | |||||
| if !tmpfile_dir.exists() { | if !tmpfile_dir.exists() { | ||||
| std::fs::create_dir_all(&tmpfile_dir).context("could not create tmp dir")?; | std::fs::create_dir_all(&tmpfile_dir).context("could not create tmp dir")?; | ||||
| } | } | ||||
| let socket_file = tmpfile_dir.join(format!("{}.sock", node_id)); | |||||
| let socket_file = tmpfile_dir.join(format!("{node_id}.sock")); | |||||
| let socket = match UnixListener::bind(&socket_file) { | let socket = match UnixListener::bind(&socket_file) { | ||||
| Ok(socket) => socket, | Ok(socket) => socket, | ||||
| Err(err) => { | Err(err) => { | ||||
| @@ -42,6 +42,7 @@ pub async fn listener_loop( | |||||
| Listener::run(connection, daemon_tx, clock).await | Listener::run(connection, daemon_tx, clock).await | ||||
| } | } | ||||
| #[allow(clippy::large_enum_variant)] | |||||
| enum Operation { | enum Operation { | ||||
| Receive(oneshot::Sender<eyre::Result<Option<Timestamped<DaemonRequest>>>>), | Receive(oneshot::Sender<eyre::Result<Option<Timestamped<DaemonRequest>>>>), | ||||
| Send { | Send { | ||||
| @@ -633,7 +633,7 @@ async fn path_spawn_command( | |||||
| .wrap_err("failed to download custom node")? | .wrap_err("failed to download custom node")? | ||||
| } else { | } else { | ||||
| resolve_path(source, working_dir) | resolve_path(source, working_dir) | ||||
| .wrap_err_with(|| format!("failed to resolve node source `{}`", source))? | |||||
| .wrap_err_with(|| format!("failed to resolve node source `{source}`"))? | |||||
| }; | }; | ||||
| // If extension is .py, use python to run the script | // If extension is .py, use python to run the script | ||||
| @@ -34,7 +34,7 @@ fn main() -> eyre::Result<()> { | |||||
| for data in &data { | for data in &data { | ||||
| for _ in 0..1 { | for _ in 0..1 { | ||||
| node.send_output_raw(latency.clone(), Default::default(), data.len(), |out| { | node.send_output_raw(latency.clone(), Default::default(), data.len(), |out| { | ||||
| out.copy_from_slice(&data); | |||||
| out.copy_from_slice(data); | |||||
| })?; | })?; | ||||
| // sleep a bit to avoid queue buildup | // sleep a bit to avoid queue buildup | ||||
| @@ -49,7 +49,7 @@ fn main() -> eyre::Result<()> { | |||||
| for data in &data { | for data in &data { | ||||
| for _ in 0..100 { | for _ in 0..100 { | ||||
| node.send_output_raw(throughput.clone(), Default::default(), data.len(), |out| { | node.send_output_raw(throughput.clone(), Default::default(), data.len(), |out| { | ||||
| out.copy_from_slice(&data); | |||||
| out.copy_from_slice(data); | |||||
| })?; | })?; | ||||
| } | } | ||||
| // notify sink that all messages have been sent | // notify sink that all messages have been sent | ||||
| @@ -14,7 +14,7 @@ fn main() -> eyre::Result<()> { | |||||
| "message" => { | "message" => { | ||||
| let received_string: &str = | let received_string: &str = | ||||
| TryFrom::try_from(&data).context("expected string message")?; | TryFrom::try_from(&data).context("expected string message")?; | ||||
| println!("sink received message: {}", received_string); | |||||
| println!("sink received message: {received_string}"); | |||||
| if !received_string.starts_with("operator received random value ") { | if !received_string.starts_with("operator received random value ") { | ||||
| bail!("unexpected message format (should start with 'operator received random value')") | bail!("unexpected message format (should start with 'operator received random value')") | ||||
| } | } | ||||
| @@ -15,7 +15,7 @@ fn main() -> eyre::Result<()> { | |||||
| "message" => { | "message" => { | ||||
| let received_string: &str = | let received_string: &str = | ||||
| TryFrom::try_from(&data).context("expected string message")?; | TryFrom::try_from(&data).context("expected string message")?; | ||||
| println!("sink received message: {}", received_string); | |||||
| println!("sink received message: {received_string}"); | |||||
| if !received_string.starts_with("operator received random value ") { | if !received_string.starts_with("operator received random value ") { | ||||
| bail!("unexpected message format (should start with 'operator received random value')") | bail!("unexpected message format (should start with 'operator received random value')") | ||||
| } | } | ||||
| @@ -14,7 +14,7 @@ fn main() -> eyre::Result<()> { | |||||
| "message" => { | "message" => { | ||||
| let received_string: &str = | let received_string: &str = | ||||
| TryFrom::try_from(&data).context("expected string message")?; | TryFrom::try_from(&data).context("expected string message")?; | ||||
| println!("sink received message: {}", received_string); | |||||
| println!("sink received message: {received_string}"); | |||||
| if !received_string.starts_with("operator received random value ") { | if !received_string.starts_with("operator received random value ") { | ||||
| bail!("unexpected message format (should start with 'operator received random value')") | bail!("unexpected message format (should start with 'operator received random value')") | ||||
| } | } | ||||
| @@ -17,10 +17,8 @@ fn main() -> eyre::Result<()> { | |||||
| "random" => { | "random" => { | ||||
| let value = u64::try_from(&data).context("unexpected data type")?; | let value = u64::try_from(&data).context("unexpected data type")?; | ||||
| let output = format!( | |||||
| "operator received random value {value:#x} after {} ticks", | |||||
| ticks | |||||
| ); | |||||
| let output = | |||||
| format!("operator received random value {value:#x} after {ticks} ticks"); | |||||
| node.send_output( | node.send_output( | ||||
| status_output.clone(), | status_output.clone(), | ||||
| metadata.parameters, | metadata.parameters, | ||||
| @@ -21,10 +21,7 @@ impl ZenohCommunicationLayer { | |||||
| /// and [`subscriber`][Self::subscribe] methods. Pass an empty string if no prefix is | /// and [`subscriber`][Self::subscribe] methods. Pass an empty string if no prefix is | ||||
| /// desired. | /// desired. | ||||
| pub fn init(config: Config, prefix: String) -> Result<Self, BoxError> { | pub fn init(config: Config, prefix: String) -> Result<Self, BoxError> { | ||||
| let zenoh = ::zenoh::open(config) | |||||
| .res_sync() | |||||
| .map_err(BoxError::from)? | |||||
| .into_arc(); | |||||
| let zenoh = ::zenoh::open(config).res_sync()?.into_arc(); | |||||
| Ok(Self { | Ok(Self { | ||||
| zenoh, | zenoh, | ||||
| topic_prefix: prefix, | topic_prefix: prefix, | ||||
| @@ -43,8 +40,7 @@ impl CommunicationLayer for ZenohCommunicationLayer { | |||||
| .declare_publisher(self.prefixed(topic)) | .declare_publisher(self.prefixed(topic)) | ||||
| .congestion_control(CongestionControl::Block) | .congestion_control(CongestionControl::Block) | ||||
| .priority(Priority::RealTime) | .priority(Priority::RealTime) | ||||
| .res_sync() | |||||
| .map_err(BoxError::from)?; | |||||
| .res_sync()?; | |||||
| Ok(Box::new(ZenohPublisher { publisher })) | Ok(Box::new(ZenohPublisher { publisher })) | ||||
| } | } | ||||
| @@ -54,8 +50,7 @@ impl CommunicationLayer for ZenohCommunicationLayer { | |||||
| .zenoh | .zenoh | ||||
| .declare_subscriber(self.prefixed(topic)) | .declare_subscriber(self.prefixed(topic)) | ||||
| .reliable() | .reliable() | ||||
| .res_sync() | |||||
| .map_err(BoxError::from)?; | |||||
| .res_sync()?; | |||||
| Ok(Box::new(ZenohReceiver(subscriber))) | Ok(Box::new(ZenohReceiver(subscriber))) | ||||
| } | } | ||||
| @@ -102,10 +97,7 @@ impl<'a> crate::PublishSample<'a> for ZenohPublishSample { | |||||
| } | } | ||||
| fn publish(self: Box<Self>) -> Result<(), BoxError> { | fn publish(self: Box<Self>) -> Result<(), BoxError> { | ||||
| self.publisher | |||||
| .put(self.sample) | |||||
| .res_sync() | |||||
| .map_err(BoxError::from) | |||||
| self.publisher.put(self.sample).res_sync() | |||||
| } | } | ||||
| } | } | ||||
| @@ -15,7 +15,7 @@ pub struct GitManager { | |||||
| pub clones_in_use: BTreeMap<PathBuf, BTreeSet<DataflowId>>, | pub clones_in_use: BTreeMap<PathBuf, BTreeSet<DataflowId>>, | ||||
| /// Builds that are prepared, but not done yet. | /// Builds that are prepared, but not done yet. | ||||
| prepared_builds: BTreeMap<SessionId, PreparedBuild>, | prepared_builds: BTreeMap<SessionId, PreparedBuild>, | ||||
| reuse_for: BTreeMap<PathBuf, PathBuf>, | |||||
| // reuse_for: BTreeMap<PathBuf, PathBuf>, | |||||
| } | } | ||||
| #[derive(Default)] | #[derive(Default)] | ||||
| @@ -8,6 +8,11 @@ use eyre::Context; | |||||
| pub trait ArrowTypeInfoExt { | pub trait ArrowTypeInfoExt { | ||||
| fn empty() -> Self; | fn empty() -> Self; | ||||
| fn byte_array(data_len: usize) -> Self; | fn byte_array(data_len: usize) -> Self; | ||||
| /// # Safety | |||||
| /// | |||||
| /// This function assumes that the `ArrayData` is backed by a memory region that starts at `region_start` | |||||
| /// and has a length of `region_len`. It will panic if the `ArrayData` does not conform to this assumption. | |||||
| unsafe fn from_array( | unsafe fn from_array( | ||||
| array: &ArrayData, | array: &ArrayData, | ||||
| region_start: *const u8, | region_start: *const u8, | ||||
| @@ -40,17 +40,17 @@ fn parse_action_string(pkg_name: &str, action_name: &str, action_string: &str) - | |||||
| name: action_name.into(), | name: action_name.into(), | ||||
| goal: parse_message_string( | goal: parse_message_string( | ||||
| pkg_name, | pkg_name, | ||||
| &format!("{}{}", action_name, ACTION_GOAL_SUFFIX), | |||||
| &format!("{action_name}{ACTION_GOAL_SUFFIX}"), | |||||
| action_blocks[0], | action_blocks[0], | ||||
| )?, | )?, | ||||
| result: parse_message_string( | result: parse_message_string( | ||||
| pkg_name, | pkg_name, | ||||
| &format!("{}{}", action_name, ACTION_RESULT_SUFFIX), | |||||
| &format!("{action_name}{ACTION_RESULT_SUFFIX}"), | |||||
| action_blocks[1], | action_blocks[1], | ||||
| )?, | )?, | ||||
| feedback: parse_message_string( | feedback: parse_message_string( | ||||
| pkg_name, | pkg_name, | ||||
| &format!("{}{}", action_name, ACTION_FEEDBACK_SUFFIX), | |||||
| &format!("{action_name}{ACTION_FEEDBACK_SUFFIX}"), | |||||
| action_blocks[2], | action_blocks[2], | ||||
| )?, | )?, | ||||
| }) | }) | ||||
| @@ -18,11 +18,9 @@ fn nestable_type_default(nestable_type: NestableType, default: &str) -> Result<V | |||||
| ensure!(rest.is_empty()); | ensure!(rest.is_empty()); | ||||
| Ok(vec![default]) | Ok(vec![default]) | ||||
| } | } | ||||
| NestableType::NamedType(t) => { | |||||
| Err(RclMsgError::InvalidDefaultError(format!("{}", t)).into()) | |||||
| } | |||||
| NestableType::NamedType(t) => Err(RclMsgError::InvalidDefaultError(format!("{t}")).into()), | |||||
| NestableType::NamespacedType(t) => { | NestableType::NamespacedType(t) => { | ||||
| Err(RclMsgError::InvalidDefaultError(format!("{}", t)).into()) | |||||
| Err(RclMsgError::InvalidDefaultError(format!("{t}")).into()) | |||||
| } | } | ||||
| NestableType::GenericString(t) => { | NestableType::GenericString(t) => { | ||||
| let (rest, default) = literal::get_string_literal_parser(t)(default) | let (rest, default) = literal::get_string_literal_parser(t)(default) | ||||
| @@ -41,11 +39,9 @@ fn array_type_default(value_type: NestableType, default: &str) -> Result<Vec<Str | |||||
| ensure!(rest.is_empty()); | ensure!(rest.is_empty()); | ||||
| Ok(default) | Ok(default) | ||||
| } | } | ||||
| NestableType::NamedType(t) => { | |||||
| Err(RclMsgError::InvalidDefaultError(format!("{}", t)).into()) | |||||
| } | |||||
| NestableType::NamedType(t) => Err(RclMsgError::InvalidDefaultError(format!("{t}")).into()), | |||||
| NestableType::NamespacedType(t) => { | NestableType::NamespacedType(t) => { | ||||
| Err(RclMsgError::InvalidDefaultError(format!("{}", t)).into()) | |||||
| Err(RclMsgError::InvalidDefaultError(format!("{t}")).into()) | |||||
| } | } | ||||
| NestableType::GenericString(_) => { | NestableType::GenericString(_) => { | ||||
| let (rest, default) = literal::string_literal_sequence(default) | let (rest, default) = literal::string_literal_sequence(default) | ||||
| @@ -39,12 +39,12 @@ fn parse_service_string(pkg_name: &str, srv_name: &str, service_string: &str) -> | |||||
| name: srv_name.into(), | name: srv_name.into(), | ||||
| request: parse_message_string( | request: parse_message_string( | ||||
| pkg_name, | pkg_name, | ||||
| &format!("{}{}", srv_name, SERVICE_REQUEST_SUFFIX), | |||||
| &format!("{srv_name}{SERVICE_REQUEST_SUFFIX}"), | |||||
| service_blocks[0], | service_blocks[0], | ||||
| )?, | )?, | ||||
| response: parse_message_string( | response: parse_message_string( | ||||
| pkg_name, | pkg_name, | ||||
| &format!("{}{}", srv_name, SERVICE_RESPONSE_SUFFIX), | |||||
| &format!("{srv_name}{SERVICE_RESPONSE_SUFFIX}"), | |||||
| service_blocks[1], | service_blocks[1], | ||||
| )?, | )?, | ||||
| }) | }) | ||||
| @@ -97,7 +97,7 @@ impl Action { | |||||
| let request = Message { | let request = Message { | ||||
| package: self.package.clone(), | package: self.package.clone(), | ||||
| name: format!("{}_Request", common), | |||||
| name: format!("{common}_Request"), | |||||
| members: vec![ | members: vec![ | ||||
| goal_id_type(), | goal_id_type(), | ||||
| Member { | Member { | ||||
| @@ -115,7 +115,7 @@ impl Action { | |||||
| }; | }; | ||||
| let response = Message { | let response = Message { | ||||
| package: self.package.clone(), | package: self.package.clone(), | ||||
| name: format!("{}_Response", common), | |||||
| name: format!("{common}_Response"), | |||||
| members: vec![ | members: vec![ | ||||
| Member { | Member { | ||||
| name: "accepted".into(), | name: "accepted".into(), | ||||
| @@ -149,13 +149,13 @@ impl Action { | |||||
| let request = Message { | let request = Message { | ||||
| package: self.package.clone(), | package: self.package.clone(), | ||||
| name: format!("{}_Request", common), | |||||
| name: format!("{common}_Request"), | |||||
| members: vec![goal_id_type()], | members: vec![goal_id_type()], | ||||
| constants: vec![], | constants: vec![], | ||||
| }; | }; | ||||
| let response = Message { | let response = Message { | ||||
| package: self.package.clone(), | package: self.package.clone(), | ||||
| name: format!("{}_Response", common), | |||||
| name: format!("{common}_Response"), | |||||
| members: vec![ | members: vec![ | ||||
| Member { | Member { | ||||
| name: "status".into(), | name: "status".into(), | ||||
| @@ -7,6 +7,7 @@ use crate::{ | |||||
| }; | }; | ||||
| #[derive(Debug, serde::Deserialize, serde::Serialize)] | #[derive(Debug, serde::Deserialize, serde::Serialize)] | ||||
| #[allow(clippy::large_enum_variant)] | |||||
| pub enum InterDaemonEvent { | pub enum InterDaemonEvent { | ||||
| Output { | Output { | ||||
| dataflow_id: DataflowId, | dataflow_id: DataflowId, | ||||
| @@ -46,6 +46,7 @@ pub enum DaemonCommunication { | |||||
| #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] | #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] | ||||
| #[must_use] | #[must_use] | ||||
| #[allow(clippy::large_enum_variant)] | |||||
| pub enum DaemonReply { | pub enum DaemonReply { | ||||
| Result(Result<(), String>), | Result(Result<(), String>), | ||||
| PreparedMessage { shared_memory_id: SharedMemoryId }, | PreparedMessage { shared_memory_id: SharedMemoryId }, | ||||
| @@ -56,6 +57,7 @@ pub enum DaemonReply { | |||||
| } | } | ||||
| #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] | #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] | ||||
| #[allow(clippy::large_enum_variant)] | |||||
| pub enum NodeEvent { | pub enum NodeEvent { | ||||
| Stop, | Stop, | ||||
| Reload { | Reload { | ||||
| @@ -108,6 +108,7 @@ pub struct ResolvedNode { | |||||
| #[derive(Debug, Clone, Serialize, Deserialize)] | #[derive(Debug, Clone, Serialize, Deserialize)] | ||||
| #[serde(rename_all = "lowercase")] | #[serde(rename_all = "lowercase")] | ||||
| #[allow(clippy::large_enum_variant)] | |||||
| pub enum CoreNodeKind { | pub enum CoreNodeKind { | ||||
| /// Dora runtime node | /// Dora runtime node | ||||
| #[serde(rename = "operators")] | #[serde(rename = "operators")] | ||||
| @@ -72,12 +72,12 @@ pub fn lib_main() -> Result<()> { | |||||
| .map(|s| s.as_str()) | .map(|s| s.as_str()) | ||||
| .unwrap_or("av1"); | .unwrap_or("av1"); | ||||
| if encoding != "av1" { | if encoding != "av1" { | ||||
| warn!("Unsupported encoding {}", encoding); | |||||
| warn!("Unsupported encoding {encoding}"); | |||||
| continue; | continue; | ||||
| } | } | ||||
| match dec.send_data(data, None, None, None) { | match dec.send_data(data, None, None, None) { | ||||
| Err(e) => { | Err(e) => { | ||||
| warn!("Error sending data to the decoder: {}", e); | |||||
| warn!("Error sending data to the decoder: {e}"); | |||||
| } | } | ||||
| Ok(()) => { | Ok(()) => { | ||||
| if let Ok(p) = dec.get_picture() { | if let Ok(p) = dec.get_picture() { | ||||
| @@ -136,8 +136,7 @@ pub fn lib_main() -> Result<()> { | |||||
| } | } | ||||
| _ => { | _ => { | ||||
| warn!( | warn!( | ||||
| "Unsupported output encoding {}", | |||||
| output_encoding | |||||
| "Unsupported output encoding {output_encoding}" | |||||
| ); | ); | ||||
| continue; | continue; | ||||
| } | } | ||||
| @@ -32,7 +32,7 @@ pub fn lib_main() -> eyre::Result<()> { | |||||
| let mut com = serial::open(&serial_port).wrap_err(Error::Connect(serial_port))?; | let mut com = serial::open(&serial_port).wrap_err(Error::Connect(serial_port))?; | ||||
| com.configure(&COM_SETTINGS) | com.configure(&COM_SETTINGS) | ||||
| .wrap_err(Error::SettingsSet(format!("{:?}", COM_SETTINGS)))?; | |||||
| .wrap_err(Error::SettingsSet(format!("{COM_SETTINGS:?}")))?; | |||||
| com.set_timeout(Duration::from_millis(1000)) | com.set_timeout(Duration::from_millis(1000)) | ||||
| .wrap_err(Error::SetTimeout("1000ms".to_string()))?; | .wrap_err(Error::SetTimeout("1000ms".to_string()))?; | ||||
| @@ -13,7 +13,7 @@ async fn main() -> eyre::Result<()> { | |||||
| .with_logging() | .with_logging() | ||||
| .build() | .build() | ||||
| .await | .await | ||||
| .map_err(|e| Report::msg(format!("Model Build error: {}", e))) // Convert error | |||||
| .map_err(|e| Report::msg(format!("Model Build error: {e}"))) // Convert error | |||||
| .expect("Failed to build model"); | .expect("Failed to build model"); | ||||
| while let Some(event) = events.recv_async().await { | while let Some(event) = events.recv_async().await { | ||||
| @@ -33,7 +33,7 @@ async fn main() -> eyre::Result<()> { | |||||
| let response = model | let response = model | ||||
| .send_chat_request(messages) | .send_chat_request(messages) | ||||
| .await | .await | ||||
| .map_err(|e| Report::msg(format!("Model Response error: {}", e))) // Convert error | |||||
| .map_err(|e| Report::msg(format!("Model Response error: {e}"))) // Convert error | |||||
| .expect("Failed to get response from model"); | .expect("Failed to get response from model"); | ||||
| let output = response.choices[0].message.content.as_ref().unwrap(); | let output = response.choices[0].message.content.as_ref().unwrap(); | ||||
| @@ -76,7 +76,7 @@ fn metadata_to_exif(metadata: &MetadataParameters) -> Result<Vec<u8>> { | |||||
| } | } | ||||
| let vector = metadata_exif.as_u8_vec(little_exif::filetype::FileExtension::HEIF)?; | let vector = metadata_exif.as_u8_vec(little_exif::filetype::FileExtension::HEIF)?; | ||||
| return Ok(vector); | |||||
| Ok(vector) | |||||
| } | } | ||||
| fn bgr8_to_yuv420(bgr_data: Vec<u8>, width: usize, height: usize) -> (Vec<u8>, Vec<u8>, Vec<u8>) { | fn bgr8_to_yuv420(bgr_data: Vec<u8>, width: usize, height: usize) -> (Vec<u8>, Vec<u8>, Vec<u8>) { | ||||
| @@ -79,7 +79,7 @@ async fn main() -> eyre::Result<()> { | |||||
| if let Err(e) = | if let Err(e) = | ||||
| write_event(&mut writer, data, &metadata, schema.clone()).await | write_event(&mut writer, data, &metadata, schema.clone()).await | ||||
| { | { | ||||
| println!("Error writing event data into parquet file: {:?}", e) | |||||
| println!("Error writing event data into parquet file: {e:?}") | |||||
| }; | }; | ||||
| } | } | ||||
| writer.close().await | writer.close().await | ||||
| @@ -101,7 +101,7 @@ async fn main() -> eyre::Result<()> { | |||||
| Some(tx) => drop(tx), | Some(tx) => drop(tx), | ||||
| }, | }, | ||||
| Event::Error(err) => { | Event::Error(err) => { | ||||
| println!("Error: {}", err); | |||||
| println!("Error: {err}"); | |||||
| } | } | ||||
| event => { | event => { | ||||
| println!("Event: {event:#?}") | println!("Event: {event:#?}") | ||||
| @@ -147,7 +147,7 @@ pub fn update_boxes2d( | |||||
| }); | }); | ||||
| } | } | ||||
| if values.len() == 0 { | |||||
| if values.is_empty() { | |||||
| rec.log(id.as_str(), &rerun::Clear::flat()) | rec.log(id.as_str(), &rerun::Clear::flat()) | ||||
| .wrap_err("Could not log Boxes2D")?; | .wrap_err("Could not log Boxes2D")?; | ||||
| return Ok(()); | return Ok(()); | ||||
| @@ -178,7 +178,7 @@ pub fn update_boxes2d( | |||||
| }); | }); | ||||
| } | } | ||||
| if values.len() == 0 { | |||||
| if values.is_empty() { | |||||
| rec.log(id.as_str(), &rerun::Clear::flat()) | rec.log(id.as_str(), &rerun::Clear::flat()) | ||||
| .wrap_err("Could not log Boxes2D")?; | .wrap_err("Could not log Boxes2D")?; | ||||
| return Ok(()); | return Ok(()); | ||||
| @@ -209,7 +209,7 @@ pub fn update_boxes2d( | |||||
| }); | }); | ||||
| } | } | ||||
| if values.len() == 0 { | |||||
| if values.is_empty() { | |||||
| rec.log(id.as_str(), &rerun::Clear::flat()) | rec.log(id.as_str(), &rerun::Clear::flat()) | ||||
| .wrap_err("Could not log Boxes2D")?; | .wrap_err("Could not log Boxes2D")?; | ||||
| return Ok(()); | return Ok(()); | ||||
| @@ -239,7 +239,7 @@ pub fn update_boxes2d( | |||||
| } | } | ||||
| }); | }); | ||||
| } | } | ||||
| if values.len() == 0 { | |||||
| if values.is_empty() { | |||||
| rec.log(id.as_str(), &rerun::Clear::flat()) | rec.log(id.as_str(), &rerun::Clear::flat()) | ||||
| .wrap_err("Could not log Boxes2D")?; | .wrap_err("Could not log Boxes2D")?; | ||||
| return Ok(()); | return Ok(()); | ||||
| @@ -76,7 +76,7 @@ pub fn lib_main() -> Result<()> { | |||||
| let id = node.dataflow_id(); | let id = node.dataflow_id(); | ||||
| let path = Path::new("out") | let path = Path::new("out") | ||||
| .join(id.to_string()) | .join(id.to_string()) | ||||
| .join(format!("archive-{}.rerun", id)); | |||||
| .join(format!("archive-{id}.rerun")); | |||||
| rerun::RecordingStreamBuilder::new("dora-rerun") | rerun::RecordingStreamBuilder::new("dora-rerun") | ||||
| .save(path) | .save(path) | ||||
| @@ -368,7 +368,7 @@ pub fn lib_main() -> Result<()> { | |||||
| "jointstate" | "jointstate" | ||||
| }; | }; | ||||
| if encoding != "jointstate" { | if encoding != "jointstate" { | ||||
| warn!("Got unexpected encoding: {} on position pose", encoding); | |||||
| warn!("Got unexpected encoding: {encoding} on position pose"); | |||||
| continue; | continue; | ||||
| } | } | ||||
| // Convert to Vec<f32> | // Convert to Vec<f32> | ||||
| @@ -386,6 +386,7 @@ pub fn lib_main() -> Result<()> { | |||||
| if dof < positions.len() { | if dof < positions.len() { | ||||
| positions.truncate(dof); | positions.truncate(dof); | ||||
| } else { | } else { | ||||
| #[allow(clippy::same_item_push)] | |||||
| for _ in 0..(dof - positions.len()) { | for _ in 0..(dof - positions.len()) { | ||||
| positions.push(0.); | positions.push(0.); | ||||
| } | } | ||||
| @@ -393,7 +394,7 @@ pub fn lib_main() -> Result<()> { | |||||
| update_visualization(&rec, chain, &id, &positions)?; | update_visualization(&rec, chain, &id, &positions)?; | ||||
| } else { | } else { | ||||
| println!("Could not find chain for {}. You may not have set its", id); | |||||
| println!("Could not find chain for {id}. You may not have set its"); | |||||
| } | } | ||||
| } else if id.as_str().contains("series") { | } else if id.as_str().contains("series") { | ||||
| update_series(&rec, id, data).context("could not plot series")?; | update_series(&rec, id, data).context("could not plot series")?; | ||||
| @@ -452,7 +453,7 @@ pub fn lib_main() -> Result<()> { | |||||
| .context("could not log points")?; | .context("could not log points")?; | ||||
| } | } | ||||
| } else { | } else { | ||||
| println!("Could not find handler for {}", id); | |||||
| println!("Could not find handler for {id}"); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -82,7 +82,7 @@ pub fn init_urdf(rec: &RecordingStream) -> Result<HashMap<String, Chain<f32>>> { | |||||
| PathBuf::from(urdf_path) | PathBuf::from(urdf_path) | ||||
| }; | }; | ||||
| let chain = k::Chain::<f32>::from_urdf_file(&urdf_path) | let chain = k::Chain::<f32>::from_urdf_file(&urdf_path) | ||||
| .context(format!("Could not load URDF {:#?}", urdf_path))?; | |||||
| .context(format!("Could not load URDF {urdf_path:#?}"))?; | |||||
| let path = key.replace("_urdf", ".urdf").replace("_URDF", ".urdf"); | let path = key.replace("_urdf", ".urdf").replace("_URDF", ".urdf"); | ||||
| let transform = key.replace("_urdf", "_transform"); | let transform = key.replace("_urdf", "_transform"); | ||||
| @@ -94,10 +94,9 @@ pub fn init_urdf(rec: &RecordingStream) -> Result<HashMap<String, Chain<f32>>> { | |||||
| } | } | ||||
| rec.log_file_from_path(&urdf_path, None, true) | rec.log_file_from_path(&urdf_path, None, true) | ||||
| .context(format!( | .context(format!( | ||||
| "Could not log URDF file {:#?} within rerun-urdf-loader", | |||||
| urdf_path | |||||
| "Could not log URDF file {urdf_path:#?} within rerun-urdf-loader" | |||||
| ))?; | ))?; | ||||
| println!("Logging URDF file: {:#?}", urdf_path); | |||||
| println!("Logging URDF file: {urdf_path:#?}"); | |||||
| // Get transform by replacing URDF_ with TRANSFORM_ | // Get transform by replacing URDF_ with TRANSFORM_ | ||||
| if let Ok(transform) = std::env::var(transform) { | if let Ok(transform) = std::env::var(transform) { | ||||
| @@ -320,7 +320,7 @@ async fn chat_completions_handler( | |||||
| let body_bytes = match to_bytes(req.body_mut()).await { | let body_bytes = match to_bytes(req.body_mut()).await { | ||||
| Ok(body_bytes) => body_bytes, | Ok(body_bytes) => body_bytes, | ||||
| Err(e) => { | Err(e) => { | ||||
| let err_msg = format!("Fail to read buffer from request body. {}", e); | |||||
| let err_msg = format!("Fail to read buffer from request body. {e}"); | |||||
| // log | // log | ||||
| error!(target: "stdout", "{}", &err_msg); | error!(target: "stdout", "{}", &err_msg); | ||||
| @@ -331,10 +331,10 @@ async fn chat_completions_handler( | |||||
| let mut chat_request: ChatCompletionRequest = match serde_json::from_slice(&body_bytes) { | let mut chat_request: ChatCompletionRequest = match serde_json::from_slice(&body_bytes) { | ||||
| Ok(chat_request) => chat_request, | Ok(chat_request) => chat_request, | ||||
| Err(e) => { | Err(e) => { | ||||
| let mut err_msg = format!("Fail to deserialize chat completion request: {}.", e); | |||||
| let mut err_msg = format!("Fail to deserialize chat completion request: {e}."); | |||||
| if let Ok(json_value) = serde_json::from_slice::<serde_json::Value>(&body_bytes) { | if let Ok(json_value) = serde_json::from_slice::<serde_json::Value>(&body_bytes) { | ||||
| err_msg = format!("{}\njson_value: {}", err_msg, json_value); | |||||
| err_msg = format!("{err_msg}\njson_value: {json_value}"); | |||||
| } | } | ||||
| // log | // log | ||||
| @@ -393,7 +393,7 @@ async fn chat_completions_handler( | |||||
| response | response | ||||
| } | } | ||||
| Err(e) => { | Err(e) => { | ||||
| let err_msg = format!("Failed chat completions in stream mode. Reason: {}", e); | |||||
| let err_msg = format!("Failed chat completions in stream mode. Reason: {e}"); | |||||
| // log | // log | ||||
| error!(target: "stdout", "{}", &err_msg); | error!(target: "stdout", "{}", &err_msg); | ||||
| @@ -411,7 +411,7 @@ async fn chat_completions_handler( | |||||
| let s = match serde_json::to_string(&chat_completion_object) { | let s = match serde_json::to_string(&chat_completion_object) { | ||||
| Ok(s) => s, | Ok(s) => s, | ||||
| Err(e) => { | Err(e) => { | ||||
| let err_msg = format!("Failed to serialize chat completion object. {}", e); | |||||
| let err_msg = format!("Failed to serialize chat completion object. {e}"); | |||||
| // log | // log | ||||
| error!(target: "stdout", "{}", &err_msg); | error!(target: "stdout", "{}", &err_msg); | ||||
| @@ -438,7 +438,7 @@ async fn chat_completions_handler( | |||||
| } | } | ||||
| Err(e) => { | Err(e) => { | ||||
| let err_msg = | let err_msg = | ||||
| format!("Failed chat completions in non-stream mode. Reason: {}", e); | |||||
| format!("Failed chat completions in non-stream mode. Reason: {e}"); | |||||
| // log | // log | ||||
| error!(target: "stdout", "{}", &err_msg); | error!(target: "stdout", "{}", &err_msg); | ||||
| @@ -448,7 +448,7 @@ async fn chat_completions_handler( | |||||
| } | } | ||||
| } | } | ||||
| Err(e) => { | Err(e) => { | ||||
| let err_msg = format!("Failed to get chat completions. Reason: {}", e); | |||||
| let err_msg = format!("Failed to get chat completions. Reason: {e}"); | |||||
| // log | // log | ||||
| error!(target: "stdout", "{}", &err_msg); | error!(target: "stdout", "{}", &err_msg); | ||||
| @@ -19,10 +19,10 @@ fn main() -> eyre::Result<()> { | |||||
| dora_node_api::arrow::datatypes::DataType::Utf8 => { | dora_node_api::arrow::datatypes::DataType::Utf8 => { | ||||
| let received_string: &str = | let received_string: &str = | ||||
| TryFrom::try_from(&data).context("expected string message")?; | TryFrom::try_from(&data).context("expected string message")?; | ||||
| println!("Received id: {}, data: {}", id, received_string); | |||||
| println!("Received id: {id}, data: {received_string}"); | |||||
| } | } | ||||
| _other => { | _other => { | ||||
| println!("Received id: {}, data: {:#?}", id, data); | |||||
| println!("Received id: {id}, data: {data:#?}"); | |||||
| } | } | ||||
| }, | }, | ||||
| _other => {} | _other => {} | ||||
| @@ -33,7 +33,7 @@ fn main() -> eyre::Result<()> { | |||||
| } | } | ||||
| Err(err) => { | Err(err) => { | ||||
| if err.to_string() == printed_error { | if err.to_string() == printed_error { | ||||
| println!("{:#?}", err); | |||||
| println!("{err:#?}"); | |||||
| println!("🕐 waiting for node `terminal-print` to be available..."); | println!("🕐 waiting for node `terminal-print` to be available..."); | ||||
| printed_error = err.to_string(); | printed_error = err.to_string(); | ||||
| } | } | ||||
| @@ -26,7 +26,7 @@ fn main() -> eyre::Result<()> { | |||||
| let _time: u64 = data.values()[0]; | let _time: u64 = data.values()[0]; | ||||
| let time_metadata = metadata.timestamp(); | let time_metadata = metadata.timestamp(); | ||||
| let duration_metadata = time_metadata.get_time().to_system_time().elapsed()?; | let duration_metadata = time_metadata.get_time().to_system_time().elapsed()?; | ||||
| println!("Latency duration: {:?}", duration_metadata); | |||||
| println!("Latency duration: {duration_metadata:?}"); | |||||
| assert!( | assert!( | ||||
| duration_metadata < Duration::from_millis(500), | duration_metadata < Duration::from_millis(500), | ||||
| "Time difference should be less than 500ms" | "Time difference should be less than 500ms" | ||||