Skip to content

Commit

Permalink
fix: enhance error handling in RPC benchmark client for aimrt_py (Aim…
Browse files Browse the repository at this point in the history
…RT#113)

* fix: enhance error handling in RPC benchmark client

* chore: remove unused pybind11 includes

Clean up unused dependencies from the Python runtime type support headers to streamline the codebase and improve maintainability.

* fix: improve error logging for GetFooData failures

Enhance logging by using ToString() for status to provide clearer failure messages, aiding in troubleshooting and debugging.
  • Loading branch information
zhangyi1357 authored Nov 26, 2024
1 parent b41416c commit 94e0446
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
9 changes: 7 additions & 2 deletions src/examples/py/pb_rpc_bench/benchmark_rpc_client_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,13 @@ def StartBenchPlan(self, plan: dict) -> None:
status, _ = self.proxy.GetFooData(ctx, req)
task_end_time = time.perf_counter_ns()

assert status.Code() == aimrt_py.RpcStatusRetCode.OK, f"GetFooData failed: {status}"
assert task_end_time > task_start_time, "Task end time is less than start time"
if status.Code() != aimrt_py.RpcStatusRetCode.OK:
aimrt_py.error(self.logger, f"GetFooData failed: {status.ToString()}")
continue
if task_end_time <= task_start_time:
aimrt_py.error(self.logger, f"Task end time {task_end_time} is less than start time {task_start_time}")
continue

self.perf_data.append((task_end_time - task_start_time) / 1e3) # us

if plan['perf_mode'] == 'fixed-freq':
Expand Down
3 changes: 0 additions & 3 deletions src/runtime/python_runtime/export_pb_type_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
#include "aimrt_module_c_interface/util/type_support_base.h"
#include "aimrt_module_cpp_interface/util/string.h"

#include "pybind11/functional.h"
#include "pybind11/stl.h"

namespace aimrt::runtime::python_runtime {

class PyPbTypeSupport {
Expand Down
4 changes: 0 additions & 4 deletions src/runtime/python_runtime/export_ros2_type_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
#include "aimrt_module_cpp_interface/util/string.h"
#include "aimrt_module_ros2_interface/util/ros2_rcl_serialized_message_adapter.h"

#include "pybind11/functional.h"
#include "pybind11/stl.h"
#include "rosidl_runtime_cpp/message_type_support_decl.hpp"

#include "python_runtime/ros2_type_support_utils.h"

namespace aimrt::runtime::python_runtime {
Expand Down
1 change: 1 addition & 0 deletions src/runtime/python_runtime/ros2_type_support_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "rosidl_runtime_c/u16string.h"
#include "rosidl_runtime_c/u16string_functions.h" // IWYU pragma: keep
#include "rosidl_typesupport_introspection_c/field_types.h"
#include "rosidl_typesupport_introspection_c/identifier.h"
#include "rosidl_typesupport_introspection_c/message_introspection.h"

namespace aimrt::runtime::python_runtime {
Expand Down
1 change: 0 additions & 1 deletion src/runtime/python_runtime/ros2_type_support_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#include "pybind11/pybind11.h" // IWYU pragma: keep

#include "rosidl_typesupport_introspection_c/identifier.h"
#include "rosidl_typesupport_introspection_c/message_introspection.h"

namespace aimrt::runtime::python_runtime {
Expand Down

0 comments on commit 94e0446

Please sign in to comment.