Skip to content

Commit

Permalink
fix: error when drawn empty communication (#445)
Browse files Browse the repository at this point in the history
* fix: drawn empty dataframe

Signed-off-by: h-suzuki <[email protected]>

* fix: spelling miss

* feat: add NOTE comment

Signed-off-by: h-suzuki <[email protected]>

* fix: refactor NOTE comment

Signed-off-by: h-suzuki <[email protected]>

---------

Signed-off-by: h-suzuki <[email protected]>
  • Loading branch information
h-suzuki-isp authored Dec 12, 2023
1 parent 7b7fa18 commit 6f234b4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/caret_analyze/infra/lttng/records_provider_lttng.py
Original file line number Diff line number Diff line change
Expand Up @@ -1613,6 +1613,17 @@ def publish_records(
ColumnValue(COLUMN_NAME.SOURCE_TIMESTAMP),
]
)
# NOTE: There is concern that publisher_handles has only one publisher_handle.
if not set(publisher_handles) & set(grouped_records.keys()):
return RecordsFactory.create_instance(
None,
columns=[
ColumnValue(COLUMN_NAME.PUBLISHER_HANDLE),
ColumnValue(COLUMN_NAME.RCLCPP_PUBLISH_TIMESTAMP),
ColumnValue(COLUMN_NAME.MESSAGE_TIMESTAMP),
ColumnValue(COLUMN_NAME.SOURCE_TIMESTAMP),
]
)
sample_records = grouped_records[publisher_handles[0]]
column_values = Columns.from_str(sample_records.columns).to_value()
pub_records = RecordsFactory.create_instance(None, columns=column_values)
Expand Down
18 changes: 18 additions & 0 deletions src/test/infra/lttng/test_latency_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,24 @@ def test_generic_publisher(

assert generic_df.equals(generic_df_expect)

# non_communication
non_communicate_pub_handle = 20
publisher_lttng_mock = create_publisher_lttng(non_communicate_pub_handle)
publisher_struct_mock = create_publisher_struct('pub_topic')
setup_bridge_get_publisher(publisher_struct_mock, [publisher_lttng_mock])
pub_records = provider.publish_records(publisher_struct_mock)
pub_df = pub_records.to_dataframe()
pub_df_expect = pd.DataFrame(
[],
columns=[
f'{publisher_struct_mock.topic_name}/rclcpp_publish_timestamp',
f'{publisher_struct_mock.topic_name}/message_timestamp',
f'{publisher_struct_mock.topic_name}/source_timestamp',
],
dtype='Int64'
)
assert pub_df.equals(pub_df_expect)


class TestSubscriptionRecords:

Expand Down

0 comments on commit 6f234b4

Please sign in to comment.