From 6fe1448ed8541907e44c43c8fe8a6e38e25ff002 Mon Sep 17 00:00:00 2001 From: ymski <114902604+ymski@users.noreply.github.com> Date: Mon, 25 Dec 2023 17:54:54 +0900 Subject: [PATCH 1/9] check lttng session Signed-off-by: ymski <114902604+ymski@users.noreply.github.com> --- ros2caret/verb/record.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ros2caret/verb/record.py b/ros2caret/verb/record.py index 77761d5..ce092d2 100644 --- a/ros2caret/verb/record.py +++ b/ros2caret/verb/record.py @@ -181,6 +181,13 @@ def main(self, *, args): context_names = names.DEFAULT_CONTEXT events_kernel = [] + # check lttng session exist + is_lttng_session_exist = subprocess.run("lttng list | grep --quiet \'\\[active\\]\'", + shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + if len(is_lttng_session_exist.stdout) != 0: + print('LTTng session is already active.') + exit(0) + rclpy.init() node = CaretSessionNode() From 243f373eaecd65a75143b0f3f7b1e9ed37a85af1 Mon Sep 17 00:00:00 2001 From: ymski <114902604+ymski@users.noreply.github.com> Date: Mon, 25 Dec 2023 18:05:00 +0900 Subject: [PATCH 2/9] fix terminate order Signed-off-by: ymski <114902604+ymski@users.noreply.github.com> --- ros2caret/verb/record.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ros2caret/verb/record.py b/ros2caret/verb/record.py index ce092d2..ebf9372 100644 --- a/ros2caret/verb/record.py +++ b/ros2caret/verb/record.py @@ -236,12 +236,12 @@ def _run(): def _fini(): node.stop_progress() - node.end() if clock_recorder: # cspell: ignore killpg, getpgid os.killpg(os.getpgid(clock_recorder.pid), signal.SIGTERM) print('stopping & destroying tracing session') lttng.lttng_fini(session_name=args.session_name) + node.end() if args.record_clock: # cspell: ignore preexec, setpgrp From 2490e459100357f700d0cc83d8e24c881957727d Mon Sep 17 00:00:00 2001 From: ymski <114902604+ymski@users.noreply.github.com> Date: Mon, 25 Dec 2023 18:52:47 +0900 Subject: [PATCH 3/9] changed to be able to loads multiple trace data Signed-off-by: ymski <114902604+ymski@users.noreply.github.com> --- ros2caret/verb/chain_latency.py | 5 +++-- ros2caret/verb/create_architecture.py | 4 ++-- ros2caret/verb/message_flow.py | 5 +++-- ros2caret/verb/node_summary.py | 2 +- ros2caret/verb/summary.py | 3 ++- ros2caret/verb/topic_summary.py | 2 +- ros2caret/verb/trace_point_summary.py | 2 +- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/ros2caret/verb/chain_latency.py b/ros2caret/verb/chain_latency.py index f1acd45..6441385 100644 --- a/ros2caret/verb/chain_latency.py +++ b/ros2caret/verb/chain_latency.py @@ -21,7 +21,7 @@ class ChainLatencyVerb(VerbExtension): def add_arguments(self, parser, cli_name): parser.add_argument( - '-t', '--trace_directory', dest='trace_directory', type=str, + '-t', '--trace_directory', dest='trace_directory', type=str, nargs='+', help='the path to the main trace directory results path', required=True ) @@ -43,7 +43,8 @@ def add_arguments(self, parser, cli_name): help='granularity of trace points to be visualized') def main(self, *, args): - lttng = Lttng(args.trace_directory, force_conversion=True) + lttng = Lttng(args.trace_directory, force_conversion=True, + validate=isinstance(args.trace_directory, list)) app = Application(args.architecture_path, 'yaml', lttng) if args.path_name not in app.path.keys(): print(f'Failed to find path : {args.path_name}') diff --git a/ros2caret/verb/create_architecture.py b/ros2caret/verb/create_architecture.py index 609271e..bd04b17 100644 --- a/ros2caret/verb/create_architecture.py +++ b/ros2caret/verb/create_architecture.py @@ -54,7 +54,7 @@ class CreateArchitectureVerb(VerbExtension): def add_arguments(self, parser, cli_name): parser.add_argument( - 'trace_dir', type=str, + 'trace_dir', type=str, nargs='+', help='the path to the main trace directory' ) parser.add_argument( @@ -92,7 +92,7 @@ class CreateArchitecture: def __init__( self, - trace_dir: str, + trace_dir: str | list[str], max_callback_construction_order_on_path_searching: int, architecture: Optional[Architecture] = None ) -> None: diff --git a/ros2caret/verb/message_flow.py b/ros2caret/verb/message_flow.py index 2ae7779..d88a0a5 100644 --- a/ros2caret/verb/message_flow.py +++ b/ros2caret/verb/message_flow.py @@ -21,7 +21,7 @@ class MessageFlowVerb(VerbExtension): def add_arguments(self, parser, cli_name): parser.add_argument( - '-t', '--trace_dir', dest='trace_dir', + '-t', '--trace_dir', dest='trace_dir', nargs='+', help='trace dir', required=True) parser.add_argument( @@ -41,7 +41,8 @@ def add_arguments(self, parser, cli_name): help='granularity of trace points to be visualized') def main(self, *, args): - lttng = Lttng(args.trace_dir, force_conversion=True) + lttng = Lttng(args.trace_dir, force_conversion=True, + validate=isinstance(args.trace_directory, list)) app = Application(args.architecture_path, 'yaml', lttng) path = app.path[args.path_name] diff --git a/ros2caret/verb/node_summary.py b/ros2caret/verb/node_summary.py index 61a4e27..367c1fc 100644 --- a/ros2caret/verb/node_summary.py +++ b/ros2caret/verb/node_summary.py @@ -21,7 +21,7 @@ class NodeSummaryVerb(VerbExtension): def add_arguments(self, parser, cli_name): parser.add_argument( - 'trace_dir', type=str, + 'trace_dir', type=str, nargs='+', help='the path to the trace directory' ) parser.add_argument( diff --git a/ros2caret/verb/summary.py b/ros2caret/verb/summary.py index c7d5bad..ee51ae6 100644 --- a/ros2caret/verb/summary.py +++ b/ros2caret/verb/summary.py @@ -43,7 +43,8 @@ def __init__( filters = self._get_filters(args.d_filter_args, args.s_filter_args) - self._lttng = Lttng(args.trace_dir, event_filters=filters) + self._lttng = Lttng(args.trace_dir, event_filters=filters, + validate=isinstance(args.trace_dir, list)) self._summary_df = self._get_summary_df(self._lttng, groupby) self._filtered = len(filters) > 0 diff --git a/ros2caret/verb/topic_summary.py b/ros2caret/verb/topic_summary.py index db169ef..c38acde 100644 --- a/ros2caret/verb/topic_summary.py +++ b/ros2caret/verb/topic_summary.py @@ -21,7 +21,7 @@ class TopicSummaryVerb(VerbExtension): def add_arguments(self, parser, cli_name): parser.add_argument( - 'trace_dir', type=str, + 'trace_dir', type=str, nargs='+', help='the path to the trace directory' ) parser.add_argument( diff --git a/ros2caret/verb/trace_point_summary.py b/ros2caret/verb/trace_point_summary.py index 46540d0..7c9e515 100644 --- a/ros2caret/verb/trace_point_summary.py +++ b/ros2caret/verb/trace_point_summary.py @@ -21,7 +21,7 @@ class TracePointSummaryVerb(VerbExtension): def add_arguments(self, parser, cli_name): parser.add_argument( - 'trace_dir', type=str, + 'trace_dir', type=str, nargs='+', help='the path to the trace directory' ) parser.add_argument( From 9df562fb7bfc55175b85e65a21b7fa324b4fe33c Mon Sep 17 00:00:00 2001 From: ymski <114902604+ymski@users.noreply.github.com> Date: Mon, 25 Dec 2023 19:04:05 +0900 Subject: [PATCH 4/9] Added message to check_ctf for loading multiple trace data. Verification of multiple trace data is not possible with CARET. Signed-off-by: ymski <114902604+ymski@users.noreply.github.com> --- ros2caret/verb/check_ctf.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ros2caret/verb/check_ctf.py b/ros2caret/verb/check_ctf.py index f71c4c2..c204d2b 100644 --- a/ros2caret/verb/check_ctf.py +++ b/ros2caret/verb/check_ctf.py @@ -27,7 +27,7 @@ class CheckCTFVerb(VerbExtension): def add_arguments(self, parser, cli_name): parser.add_argument( - 'trace_dir', type=str, + 'trace_dir', type=str, nargs='+', help='the path to the trace directory to be checked') parser.add_argument( '-m', '--max_callback_construction_order_on_path_searching', @@ -40,6 +40,9 @@ def add_arguments(self, parser, cli_name): ) def main(self, *, args): + if len(args.trace_dir) >= 2: + print('Validating multiple trace data is not supported.') + exit(0) try: if args.max_callback_construction_order_on_path_searching >= 0: Lttng(args.trace_dir) From 3573ddf5c41d56a04bcec298e3d63e502d86bb77 Mon Sep 17 00:00:00 2001 From: ymski <114902604+ymski@users.noreply.github.com> Date: Tue, 16 Jan 2024 11:43:43 +0900 Subject: [PATCH 5/9] fix: modify method to verify the existence of an active lttng session Signed-off-by: ymski <114902604+ymski@users.noreply.github.com> --- ros2caret/verb/record.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ros2caret/verb/record.py b/ros2caret/verb/record.py index ebf9372..062eb84 100644 --- a/ros2caret/verb/record.py +++ b/ros2caret/verb/record.py @@ -182,9 +182,10 @@ def main(self, *, args): events_kernel = [] # check lttng session exist - is_lttng_session_exist = subprocess.run("lttng list | grep --quiet \'\\[active\\]\'", - shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - if len(is_lttng_session_exist.stdout) != 0: + command = "lttng list | grep --quiet \'\\[active\\]\'" + ps = subprocess.run(command, shell=True, capture_output=True, text=True) + ret = ps.returncode + if ret == 0: print('LTTng session is already active.') exit(0) From e99ab806bfce4081ec38827c3ccc821ed0370006 Mon Sep 17 00:00:00 2001 From: ymski <114902604+ymski@users.noreply.github.com> Date: Fri, 19 Jan 2024 15:40:38 +0900 Subject: [PATCH 6/9] remove unnecessary options Signed-off-by: ymski <114902604+ymski@users.noreply.github.com> --- ros2caret/verb/record.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ros2caret/verb/record.py b/ros2caret/verb/record.py index 062eb84..c03bf91 100644 --- a/ros2caret/verb/record.py +++ b/ros2caret/verb/record.py @@ -183,9 +183,8 @@ def main(self, *, args): # check lttng session exist command = "lttng list | grep --quiet \'\\[active\\]\'" - ps = subprocess.run(command, shell=True, capture_output=True, text=True) - ret = ps.returncode - if ret == 0: + ps = subprocess.run(command, shell=True) + if ps.returncode == 0: print('LTTng session is already active.') exit(0) From 8192885c7bc1479679e0b913dd5fb9e16c85130d Mon Sep 17 00:00:00 2001 From: ymski <114902604+ymski@users.noreply.github.com> Date: Tue, 23 Jan 2024 18:47:16 +0900 Subject: [PATCH 7/9] remove unused funtions Signed-off-by: ymski <114902604+ymski@users.noreply.github.com> --- ros2caret/verb/callback_graph.py | 58 -------------------------------- ros2caret/verb/chain_latency.py | 54 ----------------------------- ros2caret/verb/message_flow.py | 50 --------------------------- setup.py | 4 --- 4 files changed, 166 deletions(-) delete mode 100644 ros2caret/verb/callback_graph.py delete mode 100644 ros2caret/verb/chain_latency.py delete mode 100644 ros2caret/verb/message_flow.py diff --git a/ros2caret/verb/callback_graph.py b/ros2caret/verb/callback_graph.py deleted file mode 100644 index af11719..0000000 --- a/ros2caret/verb/callback_graph.py +++ /dev/null @@ -1,58 +0,0 @@ -# Copyright 2021 Research Institute of Systems Planning, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from caret_analyze import Application -from caret_analyze.plot import callback_graph -from ros2caret.verb import VerbExtension - - -class CallbackGraphVerb(VerbExtension): - - def add_arguments(self, parser, cli_name): - parser.add_argument( - '-a', '--architecture_path', type=str, dest='architecture_path', - help='the path to the architecture file', required=True) - - parser.add_argument( - '-o', '--output_path', dest='output_path', type=str, - help='the output path to the callback graph file', required=True) - - parser.add_argument( - '-p', '--path_name', dest='path_name', type=str, default=None, - help='the path_name to highlight') - - parser.add_argument( - '-s', '--separate', dest='separate', type=bool, default=False, - help='If True, split topics. default: false.') - - parser.add_argument( - '-t', '--target_path_only', dest='target_path_only', - type=bool, default=False, - help=('Show only the path of the target. ' - 'The path must be specified with --path_name.') - ) - - def main(self, *, args): - app = Application(args.architecture_path, 'yaml', None) - callbacks = [] - if args.path_name: - path = app.path[args.path_name] - callbacks = path.callbacks - callback_graph( - app._arch, - callbacks, - args.output_path, - args.separate, - args.target_path_only - ) diff --git a/ros2caret/verb/chain_latency.py b/ros2caret/verb/chain_latency.py deleted file mode 100644 index 6441385..0000000 --- a/ros2caret/verb/chain_latency.py +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright 2021 Research Institute of Systems Planning, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from caret_analyze import Application, Lttng -from caret_analyze.plot import chain_latency -from ros2caret.verb import VerbExtension - - -class ChainLatencyVerb(VerbExtension): - - def add_arguments(self, parser, cli_name): - parser.add_argument( - '-t', '--trace_directory', dest='trace_directory', type=str, nargs='+', - help='the path to the main trace directory results path', - required=True - ) - - parser.add_argument( - '-a', '--architecture_path', dest='architecture_path', type=str, - help='the path to the architecture file', required=True) - - parser.add_argument( - '-o', '--output_path', dest='output_path', type=str, - help='output', required=True) - - parser.add_argument( - '-p', '--path_name', dest='path_name', type=str, - help='path_name', required=True) - - parser.add_argument( - '-g', '--granularity', dest='granularity', type=str, default=None, - help='granularity of trace points to be visualized') - - def main(self, *, args): - lttng = Lttng(args.trace_directory, force_conversion=True, - validate=isinstance(args.trace_directory, list)) - app = Application(args.architecture_path, 'yaml', lttng) - if args.path_name not in app.path.keys(): - print(f'Failed to find path : {args.path_name}') - return 1 - path = app.path[args.path_name] - chain_latency(path, export_path=args.output_path, - granularity=args.granularity) diff --git a/ros2caret/verb/message_flow.py b/ros2caret/verb/message_flow.py deleted file mode 100644 index d88a0a5..0000000 --- a/ros2caret/verb/message_flow.py +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2021 Research Institute of Systems Planning, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from caret_analyze import Application, Lttng -from caret_analyze.plot import message_flow -from ros2caret.verb import VerbExtension - - -class MessageFlowVerb(VerbExtension): - - def add_arguments(self, parser, cli_name): - parser.add_argument( - '-t', '--trace_dir', dest='trace_dir', nargs='+', - help='trace dir', required=True) - - parser.add_argument( - '-a', '--architecture_path', dest='architecture_path', - help='architecture', required=True) - - parser.add_argument( - '-o', '--output_path', dest='output_path', - help='output path to the message flow file', required=True) - - parser.add_argument( - '-p', '--path_name', dest='path_name', - help='path name of trace points to be visualized', required=True) - - parser.add_argument( - '-g', '--granularity', dest='granularity', default=None, - help='granularity of trace points to be visualized') - - def main(self, *, args): - lttng = Lttng(args.trace_dir, force_conversion=True, - validate=isinstance(args.trace_directory, list)) - app = Application(args.architecture_path, 'yaml', lttng) - path = app.path[args.path_name] - - message_flow(path, export_path=args.output_path, - granularity=args.granularity) diff --git a/setup.py b/setup.py index ede7ff8..4dba6be 100644 --- a/setup.py +++ b/setup.py @@ -44,10 +44,6 @@ ros2caret.verb.record:RecordVerb', 'version = \ ros2caret.verb.version:CaretVersionVerb', - # 'callback_graph = \ - # ros2caret.verb.callback_graph:CallbackGraphVerb', - # 'chain_latency = ros2caret.verb.chain_latency:ChainLatencyVerb', - # 'message_flow = ros2caret.verb.message_flow:MessageFlowVerb', ] }, ) From b2f2c2800258340d1ce03a87ef2c12c21550b1e8 Mon Sep 17 00:00:00 2001 From: ymski <114902604+ymski@users.noreply.github.com> Date: Thu, 25 Jan 2024 17:37:28 +0900 Subject: [PATCH 8/9] fix: remove type annotations for which no use case exists Signed-off-by: ymski <114902604+ymski@users.noreply.github.com> --- ros2caret/verb/create_architecture.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ros2caret/verb/create_architecture.py b/ros2caret/verb/create_architecture.py index bd04b17..12f3497 100644 --- a/ros2caret/verb/create_architecture.py +++ b/ros2caret/verb/create_architecture.py @@ -92,7 +92,7 @@ class CreateArchitecture: def __init__( self, - trace_dir: str | list[str], + trace_dir: list[str], max_callback_construction_order_on_path_searching: int, architecture: Optional[Architecture] = None ) -> None: From e539cd01344d69d13e5e1bd022465f6a901001ca Mon Sep 17 00:00:00 2001 From: ymski <114902604+ymski@users.noreply.github.com> Date: Thu, 25 Jan 2024 17:51:51 +0900 Subject: [PATCH 9/9] fix: fix validate option when passing single data Signed-off-by: ymski <114902604+ymski@users.noreply.github.com> --- ros2caret/verb/summary.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ros2caret/verb/summary.py b/ros2caret/verb/summary.py index ee51ae6..2549f89 100644 --- a/ros2caret/verb/summary.py +++ b/ros2caret/verb/summary.py @@ -44,7 +44,7 @@ def __init__( filters = self._get_filters(args.d_filter_args, args.s_filter_args) self._lttng = Lttng(args.trace_dir, event_filters=filters, - validate=isinstance(args.trace_dir, list)) + validate=len(args.trace_dir) == 1) self._summary_df = self._get_summary_df(self._lttng, groupby) self._filtered = len(filters) > 0