Skip to content

Commit

Permalink
feat: structure for scenario test (#143)
Browse files Browse the repository at this point in the history
* feat: change report_store_mount_name to relpath_from_report_store_dir

Signed-off-by: takeshi.iwanari <[email protected]>

* feat: add link to back in the top page

Signed-off-by: takeshi.iwanari <[email protected]>

* fix: remove caret_report_info.yaml

Signed-off-by: takeshi.iwanari <[email protected]>

* fix: change link_back to num_back

Signed-off-by: takeshi.iwanari <[email protected]>

---------

Signed-off-by: takeshi.iwanari <[email protected]>
  • Loading branch information
iwatake2222 authored Nov 22, 2023
1 parent 35e61cc commit e01b361
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 74 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test_autoware.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
export max_node_depth=20
export timeout=120
export draw_all_message_flow=false
export report_store_mount_name=report_store_dir
export relpath_from_report_store_dir=false
docker run --rm \
--user $(id -u):$(id -g) \
Expand All @@ -98,7 +98,7 @@ jobs:
-e max_node_depth \
-e timeout \
-e draw_all_message_flow \
-e report_store_mount_name \
-e relpath_from_report_store_dir \
${{ env.TAGS }}
- name: Upload report
Expand Down
4 changes: 2 additions & 2 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export target_path_json=target_path.json
export max_node_depth=20
export timeout=120
export draw_all_message_flow=false
export report_store_mount_name=report_store_dir
export relpath_from_report_store_dir=false

# Run script
docker run -it --rm \
Expand All @@ -65,6 +65,6 @@ docker run -it --rm \
-e max_node_depth \
-e timeout \
-e draw_all_message_flow \
-e report_store_mount_name \
-e relpath_from_report_store_dir \
caret/caret_report
```
4 changes: 2 additions & 2 deletions report/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export max_node_depth=20 # The number of depth to se
export timeout=120 # Timeout[sec] to search path. Increase it in case path is not found
export draw_all_message_flow=false # Flag to a create message flow graph for a whole time period (this will increase report creation time)
export report_store_dir=./output # Path to past report store if exist
export report_store_mount_name=report_store_dir # (optional) Links to past reports will be created assuming the current report is stored in the directory named this paraemter
export relpath_from_report_store_dir=false # Create a link to past reports assuming the current report is created under report_store_dir
export note_text_top=./note_text_top.txt # Path to setting file
export note_text_bottom=./note_text_bottom.txt # Path to setting file
export start_strip=120 # strip time at the start [sec] for analysis
Expand Down Expand Up @@ -55,7 +55,7 @@ export max_node_depth=20 # The number of depth to se
export timeout=120 # Timeout[sec] to search path. Increase it in case path is not found
export draw_all_message_flow=false # Flag to a create message flow graph for a whole time period (this will increase report creation time)
export report_store_dir=./output # Path to past report store if exist
export report_store_mount_name=report_store_dir # (optional) Links to past reports will be created assuming the current report is stored in the directory named this paraemter
export relpath_from_report_store_dir=false # Create a link to past reports assuming the current report is created under report_store_dir
export callback_list_csv=./callback_list.csv # Path to setting file
export note_text_top=./note_text_top.txt # Path to setting file
export note_text_bottom=./note_text_bottom.txt # Path to setting file
Expand Down
23 changes: 2 additions & 21 deletions report/report_analysis/make_report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,13 @@ fi
cp "${component_list_json}" "${report_dir_name}"/.
cp "${target_path_json}" "${report_dir_name}"/.

# Save parameters for report creation
report_info_access="${script_path}"/common/report_info_access.py
caret_report_info_file="${report_dir_name}"/caret_report_info.yaml
python3 ${report_info_access} ${caret_report_info_file} ${trace_data_name} save start_strip "${start_strip}"
python3 ${report_info_access} ${caret_report_info_file} ${trace_data_name} save end_strip "${end_strip}"
python3 ${report_info_access} ${caret_report_info_file} ${trace_data_name} save max_node_depth "${max_node_depth}"
python3 ${report_info_access} ${caret_report_info_file} ${trace_data_name} save timeout "${timeout}"
set +e
caret_version=$(ros2 caret version)
python3 ${report_info_access} ${caret_report_info_file} ${trace_data_name} save caret_version "${caret_version}"
caret_config_version=$(git log -n 1 --format=%H)
python3 ${report_info_access} ${caret_report_info_file} ${trace_data_name} save caret_config_version "${caret_config_version}"
current_dir=$(pwd)
cd ${script_path}
caret_report_version=$(git log -n 1 --format=%H)
cd ${current_dir}
python3 ${report_info_access} ${caret_report_info_file} ${trace_data_name} save caret_report_version "${caret_report_version}"
set -e

# Path analysis
python3 "${script_path}"/analyze_path/add_path_to_architecture.py "${trace_data}" "${target_path_json}" --architecture_file_path=architecture_path.yaml --max_node_depth="${max_node_depth}" --timeout="${timeout}" -v
python3 "${script_path}"/analyze_path/analyze_path.py "${trace_data}" "${report_dir_name}" --architecture_file_path=architecture_path.yaml --start_strip "${start_strip}" --end_strip "${end_strip}" -f -v -m "${draw_all_message_flow}"
python3 "${script_path}"/analyze_path/make_report_analyze_path.py "${report_dir_name}"

# Track of response time
python3 "${script_path}"/track_path/make_report_track_path.py "${report_dir_name}" "${report_store_dir}" --report_store_mount_name="${report_store_mount_name}"
python3 "${script_path}"/track_path/make_report_track_path.py "${report_dir_name}" "${report_store_dir}" --relpath_from_report_store_dir="${relpath_from_report_store_dir}"

# Node analysis
python3 "${script_path}"/analyze_node/analyze_node.py "${trace_data}" "${report_dir_name}" --component_list_json="${component_list_json}" --start_strip "${start_strip}" --end_strip "${end_strip}" -f -v
Expand All @@ -56,6 +37,6 @@ python3 "${script_path}"/analyze_node/make_report_analyze_node.py "${report_dir_
# python3 "${script_path}"/check_callback_timer/make_report_timer.py "${report_dir_name}"

# Make top page
python3 "${script_path}"/report_analysis/make_report_analysis.py "${trace_data}" "${report_dir_name}" --note_text_top "${note_text_top}" --note_text_bottom "${note_text_bottom}"
python3 "${script_path}"/report_analysis/make_report_analysis.py "${trace_data}" "${report_dir_name}" --note_text_top "${note_text_top}" --note_text_bottom "${note_text_bottom}" --num_back 3

echo "<<< OK. All report pages are created >>>"
8 changes: 5 additions & 3 deletions report/report_analysis/make_report_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@


def render_page(destination_path, template_path, component_list, stats_node_dict,
stats_path, note_text_top, note_text_bottom):
stats_path, note_text_top, note_text_bottom, num_back):
"""Render html page"""
title = f'Analysis report'
with app.app_context():
Expand All @@ -43,7 +43,8 @@ def render_page(destination_path, template_path, component_list, stats_node_dict
stats_node_dict=stats_node_dict,
stats_path=stats_path,
note_text_top=note_text_top,
note_text_bottom=note_text_bottom
note_text_bottom=note_text_bottom,
link_back='../' * num_back + 'index.html' if num_back > 0 else ''
)

with open(destination_path, 'w', encoding='utf-8') as f_html:
Expand Down Expand Up @@ -120,7 +121,7 @@ def make_report(args, index_filename: str='index'):
destination_path = f'{dest_dir}/{index_filename}.html'
template_path = f'{Path(__file__).resolve().parent}/template_report_analysis.html'
render_page(destination_path, template_path, component_list, stats_node_dict,
stats_path, note_text_top, note_text_bottom)
stats_path, note_text_top, note_text_bottom, args.num_back)


def parse_arg():
Expand All @@ -131,6 +132,7 @@ def parse_arg():
parser.add_argument('dest_dir', nargs=1, type=str)
parser.add_argument('--note_text_top', type=str, default='')
parser.add_argument('--note_text_bottom', type=str, default='')
parser.add_argument('--num_back', type=int, default=0)
args = parser.parse_args()
return args

Expand Down
3 changes: 3 additions & 0 deletions report/report_analysis/template_report_analysis.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
<div class="container">
<!-- <div> -->
<h1>{{ title }}</h1>
{% if link_back != "" %}
<p><a href={{ link_back }}>Back</a></p>
{% endif %}

<hr />
{% if note_text_top %} {{ note_text_top | safe }} {% endif %}
Expand Down
25 changes: 3 additions & 22 deletions report/report_validation/make_report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,6 @@ cp "${component_list_json}" "${report_dir_name}"/.
cp "${target_path_json}" "${report_dir_name}"/.
cp "${callback_list_csv}" "${report_dir_name}"/.

# Save parameters for report creation
report_info_access="${script_path}"/common/report_info_access.py
caret_report_info_file="${report_dir_name}"/caret_report_info.yaml
python3 ${report_info_access} ${caret_report_info_file} ${trace_data_name} save start_strip "${start_strip}"
python3 ${report_info_access} ${caret_report_info_file} ${trace_data_name} save end_strip "${end_strip}"
python3 ${report_info_access} ${caret_report_info_file} ${trace_data_name} save max_node_depth "${max_node_depth}"
python3 ${report_info_access} ${caret_report_info_file} ${trace_data_name} save timeout "${timeout}"
set +e
caret_version=$(ros2 caret version)
python3 ${report_info_access} ${caret_report_info_file} ${trace_data_name} save caret_version "${caret_version}"
caret_config_version=$(git log -n 1 --format=%H)
python3 ${report_info_access} ${caret_report_info_file} ${trace_data_name} save caret_config_version "${caret_config_version}"
current_dir=$(pwd)
cd ${script_path}
caret_report_version=$(git log -n 1 --format=%H)
cd ${current_dir}
python3 ${report_info_access} ${caret_report_info_file} ${trace_data_name} save caret_report_version "${caret_report_version}"
set -e

# Generate topic expectation list
python3 "${script_path}"/validate_topic/generate_expectation_list.py "${trace_data}" --report_directory="${report_dir_name}" --callback_list_filename="${callback_list_csv}" --topic_list_filename=topic_list.csv --expectation_csv_filename=topic_list_pubsub.csv

Expand All @@ -61,9 +42,9 @@ python3 "${script_path}"/analyze_path/analyze_path.py "${trace_data}" "${report_
python3 "${script_path}"/analyze_path/make_report_analyze_path.py "${report_dir_name}"

# Track of response time
python3 "${script_path}"/track_path/make_report_track_path.py "${report_dir_name}" "${report_store_dir}" --report_store_mount_name="${report_store_mount_name}"
python3 "${script_path}"/track_path/make_report_track_path.py "${report_dir_name}" "${report_store_dir}" --relpath_from_report_store_dir="${relpath_from_report_store_dir}"

# Index page
python3 "${script_path}"/report_validation/make_report_validation.py "${trace_data}" "${report_dir_name}" --component_list_json="${component_list_json}" --note_text_top="${note_text_top}" --note_text_bottom="${note_text_bottom}"
# Top page
python3 "${script_path}"/report_validation/make_report_validation.py "${trace_data}" "${report_dir_name}" --component_list_json="${component_list_json}" --note_text_top="${note_text_top}" --note_text_bottom="${note_text_bottom}" --num_back=3

echo "<<< OK. All report pages are created >>>"
8 changes: 5 additions & 3 deletions report/report_validation/make_report_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
app.jinja_env.add_extension('jinja2.ext.loopcontrols')


def make_report(report_dir: str, component_list_json: str, note_text_top, note_text_bottom):
def make_report(report_dir: str, component_list_json: str, note_text_top, note_text_bottom, num_back):
ComponentManager().initialize(component_list_json)

summary_callback_dict = {
Expand Down Expand Up @@ -77,7 +77,8 @@ def make_report(report_dir: str, component_list_json: str, note_text_top, note_t
summary_callback_dict=summary_callback_dict,
summary_topic_dict=summary_topic_dict,
note_text_top=note_text_top,
note_text_bottom=note_text_bottom
note_text_bottom=note_text_bottom,
link_back='../' * num_back + 'index.html' if num_back > 0 else ''
)

with open(destination_path, 'w', encoding='utf-8') as f_html:
Expand All @@ -96,6 +97,7 @@ def parse_arg():
parser.add_argument('--component_list_json', type=str, default='')
parser.add_argument('--note_text_top', type=str, default='')
parser.add_argument('--note_text_bottom', type=str, default='')
parser.add_argument('--num_back', type=int, default=0)
args = parser.parse_args()
return args

Expand All @@ -107,7 +109,7 @@ def main():
trace_data_dir = args.trace_data[0].rstrip('/')
dest_dir = args.dest_dir[0].rstrip('/')
note_text_top, note_text_bottom = read_note_text(trace_data_dir, dest_dir, args.note_text_top, args.note_text_bottom)
make_report(dest_dir, args.component_list_json, note_text_top, note_text_bottom)
make_report(dest_dir, args.component_list_json, note_text_top, note_text_bottom, args.num_back)
print('<<< OK. report page is created >>>')


Expand Down
3 changes: 3 additions & 0 deletions report/report_validation/template_report_validation.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
<body>
<div class="container">
<h1>{{ title }}</h1>
{% if link_back != "" %}
<p><a href={{ link_back }}>Back</a></p>
{% endif %}

<hr />
{% if note_text_top %} {{ note_text_top | safe }} {% endif %}
Expand Down
36 changes: 19 additions & 17 deletions report/track_path/make_report_track_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import os
import sys
import argparse
from distutils.util import strtobool
from pathlib import Path
import glob
import math
Expand Down Expand Up @@ -152,24 +153,25 @@ def make_stats_file_dict(dest_dir: str, report_store_dir: str) -> list[tuple[str
return stats_file_dict


def make_stats(dest_dir: str, report_store_dir: str, report_store_mount_name: str):
def make_stats(dest_dir: str, report_store_dir: str, relpath_from_report_store_dir: bool):
"""Make stats"""
stats_file_dict = make_stats_file_dict(dest_dir, report_store_dir)

reportpath_version_dict = {} # key: version, value: path to report
for version, stats_file in stats_file_dict.items():
path_report_file = Path(stats_file).parent.joinpath('index.html')
top_report_file = Path(stats_file).parent.parent.joinpath('index.html')
if path_report_file.exists() or True: # Always create link
path_report_file = Path(stats_file).parent.joinpath('index.html').resolve()
top_report_file = Path(stats_file).parent.parent.joinpath('index.html').resolve()
if relpath_from_report_store_dir and report_store_dir in str(top_report_file):
# Create a relpath assuming the current report is created under report_store_dir
path_report_file = os.path.relpath(path_report_file, Path(report_store_dir).resolve())
top_report_file = os.path.relpath(top_report_file, Path(report_store_dir).resolve())
relpath_report_store_dir = Path('../../../../')
path_report_file = relpath_report_store_dir.joinpath(path_report_file)
top_report_file = relpath_report_store_dir.joinpath(top_report_file)
else:
# Create a relpath from dest_dir
path_report_file = os.path.relpath(path_report_file, Path(dest_dir).resolve())
top_report_file = os.path.relpath(top_report_file, Path(dest_dir).resolve())
if report_store_mount_name != '' and report_store_mount_name in top_report_file:
# Create a new relpath assuming the current report is created under report_store_mount_name
path_report_file = '../../../..' + path_report_file.split(report_store_mount_name)[-1]
top_report_file = '../../../..' + top_report_file.split(report_store_mount_name)[-1]
else:
path_report_file = ''
top_report_file = ''
reportpath_version_dict[version] = (path_report_file, top_report_file)

stats_version_dict = {} # key: version, value: stats
Expand Down Expand Up @@ -226,9 +228,9 @@ def make_stats(dest_dir: str, report_store_dir: str, report_store_mount_name: st
return reportpath_version_dict, stats_path_dict, filename_path_dict


def make_report(dest_dir: str, report_store_dir: str, report_store_mount_name: str):
def make_report(dest_dir: str, report_store_dir: str, relpath_from_report_store_dir: bool):
"""Make report page"""
reportpath_version_dict, stats_path_dict, filename_path_dict = make_stats(dest_dir, report_store_dir, report_store_mount_name)
reportpath_version_dict, stats_path_dict, filename_path_dict = make_stats(dest_dir, report_store_dir, relpath_from_report_store_dir)
destination_path = f'{dest_dir}/index.html'
template_path = f'{Path(__file__).resolve().parent}/template_track_path.html'
render_page(reportpath_version_dict, stats_path_dict, filename_path_dict, destination_path, template_path)
Expand All @@ -240,7 +242,7 @@ def parse_arg():
description='Script to make report page')
parser.add_argument('dest_dir', nargs=1, type=str)
parser.add_argument('report_store_dir', nargs=1, type=str)
parser.add_argument('--report_store_mount_name', type=str, default='')
parser.add_argument('--relpath_from_report_store_dir', type=strtobool, default=False)
args = parser.parse_args()
return args

Expand All @@ -251,13 +253,13 @@ def main():

dest_dir = args.dest_dir[0] + '/track_path'
report_store_dir = args.report_store_dir[0]
report_store_mount_name = args.report_store_mount_name
relpath_from_report_store_dir = args.relpath_from_report_store_dir
_logger.info(f'dest_dir: {dest_dir}')
_logger.info(f'report_store_dir: {report_store_dir}')
_logger.info(f'report_store_mount_name: {report_store_mount_name}')
_logger.info(f'relpath_from_report_store_dir: {relpath_from_report_store_dir}')
os.makedirs(dest_dir, exist_ok=True)

make_report(dest_dir, report_store_dir, report_store_mount_name)
make_report(dest_dir, report_store_dir, relpath_from_report_store_dir)
print('<<< OK. report_track_path is created >>>')


Expand Down
4 changes: 2 additions & 2 deletions sample_autoware/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export max_node_depth=20
export timeout=120
export draw_all_message_flow=false
export report_store_dir=./output
# export report_store_mount_name=report_store_dir
export relpath_from_report_store_dir=false
export note_text_top=./note_text_top.txt
export note_text_bottom=./note_text_bottom.txt
export start_strip=0
Expand All @@ -23,7 +23,7 @@ export max_node_depth=20
export timeout=120
export draw_all_message_flow=false
export report_store_dir=./output
# export report_store_mount_name=report_store_dir
export relpath_from_report_store_dir=false
export callback_list_csv=./callback_list.csv
export note_text_top=./note_text_top.txt
export note_text_bottom=./note_text_bottom.txt
Expand Down

0 comments on commit e01b361

Please sign in to comment.