Browse Source

Fix all clippy warning (#1076)

pull/1080/head
Philipp Oppermann GitHub 6 months ago
parent
commit
2d780ee5f1
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
36 changed files with 83 additions and 102 deletions
  1. +2
    -6
      apis/c++/node/src/lib.rs
  2. +1
    -0
      apis/python/node/src/lib.rs
  3. +2
    -14
      apis/python/operator/src/lib.rs
  4. +1
    -0
      apis/rust/node/src/event_stream/merged.rs
  5. +5
    -6
      binaries/cli/src/command/self_.rs
  6. +2
    -1
      binaries/daemon/src/lib.rs
  7. +1
    -1
      binaries/daemon/src/log.rs
  8. +1
    -1
      binaries/daemon/src/node_communication/mod.rs
  9. +1
    -0
      binaries/daemon/src/node_communication/shmem.rs
  10. +1
    -1
      binaries/daemon/src/spawn.rs
  11. +2
    -2
      examples/benchmark/node/src/main.rs
  12. +1
    -1
      examples/multiple-daemons/sink/src/main.rs
  13. +1
    -1
      examples/rust-dataflow/sink-dynamic/src/main.rs
  14. +1
    -1
      examples/rust-dataflow/sink/src/main.rs
  15. +2
    -4
      examples/rust-dataflow/status-node/src/main.rs
  16. +4
    -12
      libraries/communication-layer/pub-sub/src/zenoh.rs
  17. +1
    -1
      libraries/core/src/build/git.rs
  18. +5
    -0
      libraries/core/src/metadata.rs
  19. +3
    -3
      libraries/extensions/ros2-bridge/msg-gen/src/parser/action.rs
  20. +4
    -8
      libraries/extensions/ros2-bridge/msg-gen/src/parser/member.rs
  21. +2
    -2
      libraries/extensions/ros2-bridge/msg-gen/src/parser/service.rs
  22. +4
    -4
      libraries/extensions/ros2-bridge/msg-gen/src/types/action.rs
  23. +1
    -0
      libraries/message/src/daemon_to_daemon.rs
  24. +2
    -0
      libraries/message/src/daemon_to_node.rs
  25. +1
    -0
      libraries/message/src/descriptor.rs
  26. +3
    -4
      node-hub/dora-dav1d/src/lib.rs
  27. +1
    -1
      node-hub/dora-kit-car/src/lib.rs
  28. +2
    -2
      node-hub/dora-mistral-rs/src/main.rs
  29. +1
    -1
      node-hub/dora-rav1e/src/lib.rs
  30. +2
    -2
      node-hub/dora-record/src/main.rs
  31. +4
    -4
      node-hub/dora-rerun/src/boxes2d.rs
  32. +5
    -4
      node-hub/dora-rerun/src/lib.rs
  33. +3
    -4
      node-hub/dora-rerun/src/urdf.rs
  34. +7
    -7
      node-hub/openai-proxy-server/src/main.rs
  35. +3
    -3
      node-hub/terminal-print/src/main.rs
  36. +1
    -1
      tests/queue_size_latest_data_rust/receive_data/src/main.rs

+ 2
- 6
apis/c++/node/src/lib.rs View File

@@ -87,10 +87,6 @@ mod ffi {
}
}

mod arrow_ffi {
pub use arrow::ffi::{FFI_ArrowArray, FFI_ArrowSchema};
}

#[cfg(feature = "ros2-bridge")]
pub mod ros2 {
pub use dora_ros2_bridge::*;
@@ -215,7 +211,7 @@ unsafe fn event_as_arrow_input(
}
}
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 {
error: format!("Error importing array from C++: {:?}", e),
error: format!("Error importing array from C++: {e:?}"),
},
}
}


+ 1
- 0
apis/python/node/src/lib.rs View File

@@ -320,6 +320,7 @@ impl Events {
}
}

#[allow(clippy::large_enum_variant)]
enum EventsInner {
Dora(EventStream),
Merged(Box<dyn Stream<Item = MergedEvent<PyObject>> + Unpin + Send + Sync>),


+ 2
- 14
apis/python/operator/src/lib.rs View File

@@ -214,25 +214,13 @@ pub fn pydict_to_metadata(dict: Option<Bound<'_, PyDict>>) -> Result<MetadataPar
parameters.insert(key, Parameter::Float(value.extract::<f64>()?))
} else if value.is_instance_of::<PyString>() {
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.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::<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.get_item(0)?.is_exact_instance_of::<PyFloat>()
{


+ 1
- 0
apis/rust/node/src/event_stream/merged.rs View File

@@ -8,6 +8,7 @@ use futures_concurrency::stream::Merge;

/// A Dora event or an event from an external source.
#[derive(Debug)]
#[allow(clippy::large_enum_variant)]
pub enum MergedEvent<E> {
/// A Dora event
Dora(super::Event),


+ 5
- 6
binaries/cli/src/command/self_.rs View File

@@ -55,25 +55,24 @@ impl Executable for SelfSubCommand {
);
} else {
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 {
// Perform the actual update
match status.update() {
Ok(update_status) => match update_status {
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) => {
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}"),
}
}
}


+ 2
- 1
binaries/daemon/src/lib.rs View File

@@ -1070,7 +1070,7 @@ impl Daemon {
for task in tasks {
let NodeBuildTask {
node_id,
dynamic_node,
dynamic_node: _,
task,
} = task;
let node = task
@@ -2680,6 +2680,7 @@ impl Event {
}

#[derive(Debug)]
#[allow(clippy::large_enum_variant)]
pub enum DaemonNodeEvent {
OutputsDone {
reply_sender: oneshot::Sender<DaemonReply>,


+ 1
- 1
binaries/daemon/src/log.rs View File

@@ -416,7 +416,7 @@ struct Indent<'a>(&'a str);
impl std::fmt::Display for Indent<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
for line in self.0.lines() {
write!(f, " {}", line)?;
write!(f, " {line}")?;
}
Ok(())
}


+ 1
- 1
binaries/daemon/src/node_communication/mod.rs View File

@@ -152,7 +152,7 @@ pub async fn spawn_listener_loop(
if !tmpfile_dir.exists() {
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) {
Ok(socket) => socket,
Err(err) => {


+ 1
- 0
binaries/daemon/src/node_communication/shmem.rs View File

@@ -42,6 +42,7 @@ pub async fn listener_loop(
Listener::run(connection, daemon_tx, clock).await
}

#[allow(clippy::large_enum_variant)]
enum Operation {
Receive(oneshot::Sender<eyre::Result<Option<Timestamped<DaemonRequest>>>>),
Send {


+ 1
- 1
binaries/daemon/src/spawn.rs View File

@@ -633,7 +633,7 @@ async fn path_spawn_command(
.wrap_err("failed to download custom node")?
} else {
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


+ 2
- 2
examples/benchmark/node/src/main.rs View File

@@ -34,7 +34,7 @@ fn main() -> eyre::Result<()> {
for data in &data {
for _ in 0..1 {
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
@@ -49,7 +49,7 @@ fn main() -> eyre::Result<()> {
for data in &data {
for _ in 0..100 {
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


+ 1
- 1
examples/multiple-daemons/sink/src/main.rs View File

@@ -14,7 +14,7 @@ fn main() -> eyre::Result<()> {
"message" => {
let received_string: &str =
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 ") {
bail!("unexpected message format (should start with 'operator received random value')")
}


+ 1
- 1
examples/rust-dataflow/sink-dynamic/src/main.rs View File

@@ -15,7 +15,7 @@ fn main() -> eyre::Result<()> {
"message" => {
let received_string: &str =
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 ") {
bail!("unexpected message format (should start with 'operator received random value')")
}


+ 1
- 1
examples/rust-dataflow/sink/src/main.rs View File

@@ -14,7 +14,7 @@ fn main() -> eyre::Result<()> {
"message" => {
let received_string: &str =
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 ") {
bail!("unexpected message format (should start with 'operator received random value')")
}


+ 2
- 4
examples/rust-dataflow/status-node/src/main.rs View File

@@ -17,10 +17,8 @@ fn main() -> eyre::Result<()> {
"random" => {
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(
status_output.clone(),
metadata.parameters,


+ 4
- 12
libraries/communication-layer/pub-sub/src/zenoh.rs View File

@@ -21,10 +21,7 @@ impl ZenohCommunicationLayer {
/// and [`subscriber`][Self::subscribe] methods. Pass an empty string if no prefix is
/// desired.
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 {
zenoh,
topic_prefix: prefix,
@@ -43,8 +40,7 @@ impl CommunicationLayer for ZenohCommunicationLayer {
.declare_publisher(self.prefixed(topic))
.congestion_control(CongestionControl::Block)
.priority(Priority::RealTime)
.res_sync()
.map_err(BoxError::from)?;
.res_sync()?;

Ok(Box::new(ZenohPublisher { publisher }))
}
@@ -54,8 +50,7 @@ impl CommunicationLayer for ZenohCommunicationLayer {
.zenoh
.declare_subscriber(self.prefixed(topic))
.reliable()
.res_sync()
.map_err(BoxError::from)?;
.res_sync()?;

Ok(Box::new(ZenohReceiver(subscriber)))
}
@@ -102,10 +97,7 @@ impl<'a> crate::PublishSample<'a> for ZenohPublishSample {
}

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()
}
}



+ 1
- 1
libraries/core/src/build/git.rs View File

@@ -15,7 +15,7 @@ pub struct GitManager {
pub clones_in_use: BTreeMap<PathBuf, BTreeSet<DataflowId>>,
/// Builds that are prepared, but not done yet.
prepared_builds: BTreeMap<SessionId, PreparedBuild>,
reuse_for: BTreeMap<PathBuf, PathBuf>,
// reuse_for: BTreeMap<PathBuf, PathBuf>,
}

#[derive(Default)]


+ 5
- 0
libraries/core/src/metadata.rs View File

@@ -8,6 +8,11 @@ use eyre::Context;
pub trait ArrowTypeInfoExt {
fn empty() -> 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(
array: &ArrayData,
region_start: *const u8,


+ 3
- 3
libraries/extensions/ros2-bridge/msg-gen/src/parser/action.rs View File

@@ -40,17 +40,17 @@ fn parse_action_string(pkg_name: &str, action_name: &str, action_string: &str) -
name: action_name.into(),
goal: parse_message_string(
pkg_name,
&format!("{}{}", action_name, ACTION_GOAL_SUFFIX),
&format!("{action_name}{ACTION_GOAL_SUFFIX}"),
action_blocks[0],
)?,
result: parse_message_string(
pkg_name,
&format!("{}{}", action_name, ACTION_RESULT_SUFFIX),
&format!("{action_name}{ACTION_RESULT_SUFFIX}"),
action_blocks[1],
)?,
feedback: parse_message_string(
pkg_name,
&format!("{}{}", action_name, ACTION_FEEDBACK_SUFFIX),
&format!("{action_name}{ACTION_FEEDBACK_SUFFIX}"),
action_blocks[2],
)?,
})


+ 4
- 8
libraries/extensions/ros2-bridge/msg-gen/src/parser/member.rs View File

@@ -18,11 +18,9 @@ fn nestable_type_default(nestable_type: NestableType, default: &str) -> Result<V
ensure!(rest.is_empty());
Ok(vec![default])
}
NestableType::NamedType(t) => {
Err(RclMsgError::InvalidDefaultError(format!("{}", t)).into())
}
NestableType::NamedType(t) => Err(RclMsgError::InvalidDefaultError(format!("{t}")).into()),
NestableType::NamespacedType(t) => {
Err(RclMsgError::InvalidDefaultError(format!("{}", t)).into())
Err(RclMsgError::InvalidDefaultError(format!("{t}")).into())
}
NestableType::GenericString(t) => {
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());
Ok(default)
}
NestableType::NamedType(t) => {
Err(RclMsgError::InvalidDefaultError(format!("{}", t)).into())
}
NestableType::NamedType(t) => Err(RclMsgError::InvalidDefaultError(format!("{t}")).into()),
NestableType::NamespacedType(t) => {
Err(RclMsgError::InvalidDefaultError(format!("{}", t)).into())
Err(RclMsgError::InvalidDefaultError(format!("{t}")).into())
}
NestableType::GenericString(_) => {
let (rest, default) = literal::string_literal_sequence(default)


+ 2
- 2
libraries/extensions/ros2-bridge/msg-gen/src/parser/service.rs View File

@@ -39,12 +39,12 @@ fn parse_service_string(pkg_name: &str, srv_name: &str, service_string: &str) ->
name: srv_name.into(),
request: parse_message_string(
pkg_name,
&format!("{}{}", srv_name, SERVICE_REQUEST_SUFFIX),
&format!("{srv_name}{SERVICE_REQUEST_SUFFIX}"),
service_blocks[0],
)?,
response: parse_message_string(
pkg_name,
&format!("{}{}", srv_name, SERVICE_RESPONSE_SUFFIX),
&format!("{srv_name}{SERVICE_RESPONSE_SUFFIX}"),
service_blocks[1],
)?,
})


+ 4
- 4
libraries/extensions/ros2-bridge/msg-gen/src/types/action.rs View File

@@ -97,7 +97,7 @@ impl Action {

let request = Message {
package: self.package.clone(),
name: format!("{}_Request", common),
name: format!("{common}_Request"),
members: vec![
goal_id_type(),
Member {
@@ -115,7 +115,7 @@ impl Action {
};
let response = Message {
package: self.package.clone(),
name: format!("{}_Response", common),
name: format!("{common}_Response"),
members: vec![
Member {
name: "accepted".into(),
@@ -149,13 +149,13 @@ impl Action {

let request = Message {
package: self.package.clone(),
name: format!("{}_Request", common),
name: format!("{common}_Request"),
members: vec![goal_id_type()],
constants: vec![],
};
let response = Message {
package: self.package.clone(),
name: format!("{}_Response", common),
name: format!("{common}_Response"),
members: vec![
Member {
name: "status".into(),


+ 1
- 0
libraries/message/src/daemon_to_daemon.rs View File

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

#[derive(Debug, serde::Deserialize, serde::Serialize)]
#[allow(clippy::large_enum_variant)]
pub enum InterDaemonEvent {
Output {
dataflow_id: DataflowId,


+ 2
- 0
libraries/message/src/daemon_to_node.rs View File

@@ -46,6 +46,7 @@ pub enum DaemonCommunication {

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[must_use]
#[allow(clippy::large_enum_variant)]
pub enum DaemonReply {
Result(Result<(), String>),
PreparedMessage { shared_memory_id: SharedMemoryId },
@@ -56,6 +57,7 @@ pub enum DaemonReply {
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[allow(clippy::large_enum_variant)]
pub enum NodeEvent {
Stop,
Reload {


+ 1
- 0
libraries/message/src/descriptor.rs View File

@@ -108,6 +108,7 @@ pub struct ResolvedNode {

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
#[allow(clippy::large_enum_variant)]
pub enum CoreNodeKind {
/// Dora runtime node
#[serde(rename = "operators")]


+ 3
- 4
node-hub/dora-dav1d/src/lib.rs View File

@@ -72,12 +72,12 @@ pub fn lib_main() -> Result<()> {
.map(|s| s.as_str())
.unwrap_or("av1");
if encoding != "av1" {
warn!("Unsupported encoding {}", encoding);
warn!("Unsupported encoding {encoding}");
continue;
}
match dec.send_data(data, None, None, None) {
Err(e) => {
warn!("Error sending data to the decoder: {}", e);
warn!("Error sending data to the decoder: {e}");
}
Ok(()) => {
if let Ok(p) = dec.get_picture() {
@@ -136,8 +136,7 @@ pub fn lib_main() -> Result<()> {
}
_ => {
warn!(
"Unsupported output encoding {}",
output_encoding
"Unsupported output encoding {output_encoding}"
);
continue;
}


+ 1
- 1
node-hub/dora-kit-car/src/lib.rs View File

@@ -32,7 +32,7 @@ pub fn lib_main() -> eyre::Result<()> {

let mut com = serial::open(&serial_port).wrap_err(Error::Connect(serial_port))?;
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))
.wrap_err(Error::SetTimeout("1000ms".to_string()))?;



+ 2
- 2
node-hub/dora-mistral-rs/src/main.rs View File

@@ -13,7 +13,7 @@ async fn main() -> eyre::Result<()> {
.with_logging()
.build()
.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");

while let Some(event) = events.recv_async().await {
@@ -33,7 +33,7 @@ async fn main() -> eyre::Result<()> {
let response = model
.send_chat_request(messages)
.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");

let output = response.choices[0].message.content.as_ref().unwrap();


+ 1
- 1
node-hub/dora-rav1e/src/lib.rs View File

@@ -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)?;
return Ok(vector);
Ok(vector)
}

fn bgr8_to_yuv420(bgr_data: Vec<u8>, width: usize, height: usize) -> (Vec<u8>, Vec<u8>, Vec<u8>) {


+ 2
- 2
node-hub/dora-record/src/main.rs View File

@@ -79,7 +79,7 @@ async fn main() -> eyre::Result<()> {
if let Err(e) =
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
@@ -101,7 +101,7 @@ async fn main() -> eyre::Result<()> {
Some(tx) => drop(tx),
},
Event::Error(err) => {
println!("Error: {}", err);
println!("Error: {err}");
}
event => {
println!("Event: {event:#?}")


+ 4
- 4
node-hub/dora-rerun/src/boxes2d.rs View File

@@ -147,7 +147,7 @@ pub fn update_boxes2d(
});
}

if values.len() == 0 {
if values.is_empty() {
rec.log(id.as_str(), &rerun::Clear::flat())
.wrap_err("Could not log Boxes2D")?;
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())
.wrap_err("Could not log Boxes2D")?;
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())
.wrap_err("Could not log Boxes2D")?;
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())
.wrap_err("Could not log Boxes2D")?;
return Ok(());


+ 5
- 4
node-hub/dora-rerun/src/lib.rs View File

@@ -76,7 +76,7 @@ pub fn lib_main() -> Result<()> {
let id = node.dataflow_id();
let path = Path::new("out")
.join(id.to_string())
.join(format!("archive-{}.rerun", id));
.join(format!("archive-{id}.rerun"));

rerun::RecordingStreamBuilder::new("dora-rerun")
.save(path)
@@ -368,7 +368,7 @@ pub fn lib_main() -> Result<()> {
"jointstate"
};
if encoding != "jointstate" {
warn!("Got unexpected encoding: {} on position pose", encoding);
warn!("Got unexpected encoding: {encoding} on position pose");
continue;
}
// Convert to Vec<f32>
@@ -386,6 +386,7 @@ pub fn lib_main() -> Result<()> {
if dof < positions.len() {
positions.truncate(dof);
} else {
#[allow(clippy::same_item_push)]
for _ in 0..(dof - positions.len()) {
positions.push(0.);
}
@@ -393,7 +394,7 @@ pub fn lib_main() -> Result<()> {

update_visualization(&rec, chain, &id, &positions)?;
} 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") {
update_series(&rec, id, data).context("could not plot series")?;
@@ -452,7 +453,7 @@ pub fn lib_main() -> Result<()> {
.context("could not log points")?;
}
} else {
println!("Could not find handler for {}", id);
println!("Could not find handler for {id}");
}
}
}


+ 3
- 4
node-hub/dora-rerun/src/urdf.rs View File

@@ -82,7 +82,7 @@ pub fn init_urdf(rec: &RecordingStream) -> Result<HashMap<String, Chain<f32>>> {
PathBuf::from(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 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)
.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_
if let Ok(transform) = std::env::var(transform) {


+ 7
- 7
node-hub/openai-proxy-server/src/main.rs View File

@@ -320,7 +320,7 @@ async fn chat_completions_handler(
let body_bytes = match to_bytes(req.body_mut()).await {
Ok(body_bytes) => body_bytes,
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
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) {
Ok(chat_request) => chat_request,
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) {
err_msg = format!("{}\njson_value: {}", err_msg, json_value);
err_msg = format!("{err_msg}\njson_value: {json_value}");
}

// log
@@ -393,7 +393,7 @@ async fn chat_completions_handler(
response
}
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
error!(target: "stdout", "{}", &err_msg);
@@ -411,7 +411,7 @@ async fn chat_completions_handler(
let s = match serde_json::to_string(&chat_completion_object) {
Ok(s) => s,
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
error!(target: "stdout", "{}", &err_msg);
@@ -438,7 +438,7 @@ async fn chat_completions_handler(
}
Err(e) => {
let err_msg =
format!("Failed chat completions in non-stream mode. Reason: {}", e);
format!("Failed chat completions in non-stream mode. Reason: {e}");

// log
error!(target: "stdout", "{}", &err_msg);
@@ -448,7 +448,7 @@ async fn chat_completions_handler(
}
}
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
error!(target: "stdout", "{}", &err_msg);


+ 3
- 3
node-hub/terminal-print/src/main.rs View File

@@ -19,10 +19,10 @@ fn main() -> eyre::Result<()> {
dora_node_api::arrow::datatypes::DataType::Utf8 => {
let received_string: &str =
TryFrom::try_from(&data).context("expected string message")?;
println!("Received id: {}, data: {}", id, received_string);
println!("Received id: {id}, data: {received_string}");
}
_other => {
println!("Received id: {}, data: {:#?}", id, data);
println!("Received id: {id}, data: {data:#?}");
}
},
_other => {}
@@ -33,7 +33,7 @@ fn main() -> eyre::Result<()> {
}
Err(err) => {
if err.to_string() == printed_error {
println!("{:#?}", err);
println!("{err:#?}");
println!("🕐 waiting for node `terminal-print` to be available...");
printed_error = err.to_string();
}


+ 1
- 1
tests/queue_size_latest_data_rust/receive_data/src/main.rs View File

@@ -26,7 +26,7 @@ fn main() -> eyre::Result<()> {
let _time: u64 = data.values()[0];
let time_metadata = metadata.timestamp();
let duration_metadata = time_metadata.get_time().to_system_time().elapsed()?;
println!("Latency duration: {:?}", duration_metadata);
println!("Latency duration: {duration_metadata:?}");
assert!(
duration_metadata < Duration::from_millis(500),
"Time difference should be less than 500ms"


Loading…
Cancel
Save