Skip to content

Commit

Permalink
feat: add evaluator info (#154)
Browse files Browse the repository at this point in the history
* fix: modify page title

Signed-off-by: takeshi.iwanari <take.iwiw2222@gmail.com>

* feat: display information from evaluator

Signed-off-by: takeshi.iwanari <take.iwiw2222@gmail.com>

* chore(find_valid_duration): use default value

Signed-off-by: takeshi.iwanari <take.iwiw2222@gmail.com>

---------

Signed-off-by: takeshi.iwanari <take.iwiw2222@gmail.com>
  • Loading branch information
iwatake2222 authored Jan 19, 2024
1 parent 8c3db82 commit 0562cfa
Show file tree
Hide file tree
Showing 15 changed files with 88 additions and 64 deletions.
21 changes: 12 additions & 9 deletions report/analyze_node/make_report_analyze_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,32 @@
app = flask.Flask(__name__)


def render_index_page(stats, report_name, component_name, destination_path, template_path):
def render_index_page(stats, title, sub_title, destination_path, template_path):
"""Render html page"""
with app.app_context():
with open(template_path, 'r', encoding='utf-8') as f_html:
template_string = f_html.read()
rendered = flask.render_template_string(
template_string,
title=f'{component_name}: {report_name}',
title=title,
sub_title=sub_title,
stats=stats,
)

with open(destination_path, 'w', encoding='utf-8') as f_html:
f_html.write(rendered)


def render_detail_page(node_info, report_name, node_name, destination_path, template_path):
def render_detail_page(node_info, title, sub_title, destination_path, template_path):
"""Render html page"""
with app.app_context():
with open(template_path, 'r', encoding='utf-8') as f_html:
template_string = f_html.read()
rendered = flask.render_template_string(
template_string,
title=f'Node detail: {report_name}',
title=title,
sub_title=sub_title,
node_info=node_info,
node_name=node_name,
metrics_list=['Frequency', 'Period', 'Latency'],
metrics_unit=['[Hz]', '[ms]', '[ms]']
)
Expand All @@ -64,19 +65,21 @@ def make_report(stats_path: str):
stats = yaml.safe_load(f_yaml)

stats_dir = Path(stats_path).resolve().parent
report_name = stats_path.split('/')[-4]
component_name = stats_path.split('/')[-2]
destination_path = f'{stats_dir}/index.html'
template_path = f'{Path(__file__).resolve().parent}/template_node_index.html'
render_index_page(stats, report_name, component_name, destination_path, template_path)
title = f"Component: {stats_path.split('/')[-2]}"
sub_title = stats_path.split('/')[-4]
render_index_page(stats, title, sub_title, destination_path, template_path)

for node_name, node_info in stats.items():
if node_info is None:
continue
filename = node_name.replace('/', '_')[1:]
destination_path = f'{stats_dir}/index_{filename}.html'
template_path = f'{Path(__file__).resolve().parent}/template_node_detail.html'
render_detail_page(node_info, report_name, node_name, destination_path, template_path)
title = f'Node: {node_name}'
sub_title = stats_path.split('/')[-4]
render_detail_page(node_info, title, sub_title, destination_path, template_path)



Expand Down
6 changes: 2 additions & 4 deletions report/analyze_node/template_node_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,17 @@
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
crossorigin="anonymous"
/>
<title>{{ title }}</title>
<title>{{ title }}, {{ sub_title }}</title>
</head>

<body>
<div class="container">
<h1>{{ title }}</h1>
<h2>{{ sub_title }}</h2>

<p><a href="../../index.html">Back to Top</a>, <a href="./index.html">Back to Node List</a></p>
<hr />

<h2 id="{{ node_name }}">Node Name: {{ node_name }}</h2>
<hr />

{% for metrics in metrics_list %}
<h3>{{ metrics }}</h3>

Expand Down
3 changes: 2 additions & 1 deletion report/analyze_node/template_node_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
crossorigin="anonymous"
/>
<title>{{ title }}</title>
<title>{{ title }}, {{ sub_title }}</title>
</head>

<body>
<div class="container">
<h1>{{ title }}</h1>
<h2>{{ sub_title }}</h2>

<p><a href="../../index.html">Back to Top </a></p>
<hr />
Expand Down
15 changes: 9 additions & 6 deletions report/analyze_path/make_report_analyze_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@
app = flask.Flask(__name__)


def render_page(stats, report_name, destination_path, template_path):
def render_page(stats, title, sub_title, destination_path, template_path):
"""Render html page"""
with app.app_context():
with open(template_path, 'r', encoding='utf-8') as f_html:
template_string = f_html.read()
rendered = flask.render_template_string(
template_string,
title=f'Path Analysis: {report_name}',
title=title,
sub_title=sub_title,
stats=stats,
)

Expand All @@ -46,17 +47,19 @@ def make_report(stats_path: str):
stats = yaml.safe_load(f_yaml)

stats_dir = Path(stats_path).resolve().parent
report_name = stats_path.split('/')[-3]

destination_path = f'{stats_dir}/index.html'
template_path = f'{Path(__file__).resolve().parent}/template_path_index.html'
render_page(stats, report_name, destination_path, template_path)
title = 'Path List'
sub_title = stats_path.split('/')[-3]
render_page(stats, title, sub_title, destination_path, template_path)

for path_info in stats:
target_path_name = path_info['target_path_name']
destination_path = f'{stats_dir}/{target_path_name}.html'
template_path = f'{Path(__file__).resolve().parent}/template_path_detail.html'
render_page(path_info, target_path_name, destination_path, template_path)
title = f'Path: {target_path_name}'
sub_title = stats_path.split('/')[-3]
render_page(path_info, title, sub_title, destination_path, template_path)


def parse_arg():
Expand Down
3 changes: 2 additions & 1 deletion report/analyze_path/template_path_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
crossorigin="anonymous"
/>
<title>{{ title }}</title>
<title>{{ title }}, {{ sub_title }}</title>
</head>

<body>
<div class="container">
<h1>{{ title }}</h1>
<h2>{{ sub_title }}</h2>
<p><a href="../index.html">Back to Top </a>, <a href="./index.html">Back to Path List</a></p>
<hr />

Expand Down
3 changes: 2 additions & 1 deletion report/analyze_path/template_path_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
crossorigin="anonymous"
/>
<title>{{ title }}</title>
<title>{{ title }}, {{ sub_title }}</title>
</head>

<body>
<div class="container">
<h1>{{ title }}</h1>
<h2>{{ sub_title }}</h2>
<p><a href="../index.html">Back to Top </a></p>
<hr />

Expand Down
31 changes: 17 additions & 14 deletions report/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ def read_note_text(trace_data_dir, dest_dir, note_text_top_path, note_text_botto
trace_datetime = datetime.datetime.strptime(trace_datetime.group(), '%Y%m%d-%H%M%S')
else:
trace_datetime = 'unknown'
note_text_top += f'<li>trace_data: {trace_data_name}</li>\n'
note_text_top += f'<li>trace_start_datetime: {trace_datetime}</li>\n'

# version info
Expand All @@ -294,35 +293,39 @@ def read_note_text(trace_data_dir, dest_dir, note_text_top_path, note_text_botto
note_text_top += f'<li>caret_analysis_version: {caret_analysis_version}</li>\n'

try:
repo_url_lines = subprocess.run(['git', 'remote', '-v'], text=True, stdout=subprocess.PIPE).stdout
repo_url_line = repo_url_lines.split('\n')[0]
repo_name = 'unknown'
for repo_url in repo_url_line.split():
if ('https://' in repo_url or 'git@' in repo_url) and '.git' in repo_url:
repo_url = repo_url.split('/')[-1]
repo_name = repo_url.split('.git')[0]
repo_url_lines = subprocess.run(['git', 'config', '--get', 'remote.origin.url'], text=True, stdout=subprocess.PIPE).stdout
repo_url = repo_url_lines.split('\n')[0]
report_setting_version = subprocess.run(['git', 'log', '-n 1', '--format=%H'], text=True, stdout=subprocess.PIPE).stdout
except:
repo_name = 'unknown'
report_setting_version = 'unknown'
note_text_top += f'<li>report_setting_repo: {repo_name}</li>\n'
note_text_top += f'<li>report_setting_repo: {repo_url}</li>\n'
note_text_top += f'<li>report_setting_version: {report_setting_version}</li>\n'
note_text_top += '</ul>\n'

# overwrite note_text_top if caret_record_info.yaml exists
# for info from evaluator, display only limited info
caret_record_info_path = f'{dest_dir}/caret_record_info.yaml'
if os.path.exists(caret_record_info_path):
with open(caret_record_info_path, encoding='UTF-8') as f_yaml:
caret_record_info = yaml.safe_load(f_yaml)
note_text_top = '<ul>\n'
note_text_top += f'<li>trace_data: {trace_data_name}</li>\n'
note_text_top += f'<li>trace_start_datetime: {trace_datetime}</li>\n'
caret_record_info = yaml.safe_load(f_yaml)
new_caret_record_info = {}
if 'caret_version' in caret_record_info:
caret_record_info['caret_version'] = caret_record_info.pop('caret_version')
caret_record_info['caret_version'] = caret_record_info.pop('caret_version') # move to the last
for key, value in caret_record_info.items():
note_text_top += f'<li>{key}: {value}</li>\n'
if 'evaluator_' in key:
display_key_list = ['evaluator_job_description', 'evaluator_git_commit_url', 'evaluator_report_url', 'evaluator_scenario_display_name']
if not any(display_key in key for display_key in display_key_list):
continue
key = key.replace('evaluator_', '')
if 'http' in value:
note_text_top += f'<li>{key}: <a href={value}>{value}</a></li>\n'
else:
note_text_top += f'<li>{key}: {value}</li>\n'
note_text_top += f'<li>caret_analysis_version: {caret_analysis_version}</li>\n'
note_text_top += f'<li>report_setting_repo: {repo_name}</li>\n'
note_text_top += f'<li>report_setting_repo: {repo_url}</li>\n'
note_text_top += f'<li>report_setting_version: {report_setting_version}</li>\n'
note_text_top += '</ul>\n'

Expand Down
2 changes: 1 addition & 1 deletion report/find_valid_duration/find_valid_duration.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def parse_arg():
description='Script to analyze path')
parser.add_argument('trace_data', nargs=1, type=str)
parser.add_argument('--architecture_file_path', type=str, default='architecture_path.yaml')
parser.add_argument('--duration', type=float, default=60.0,
parser.add_argument('--duration', type=float, default=1800.0,
help='Duration [sec] to load trace data')
parser.add_argument('--load_duration', type=float, default=120.0,
help='Duration [sec] to load trace data to find valid duration')
Expand Down
2 changes: 1 addition & 1 deletion report/find_valid_duration/find_valid_duration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ trace_data_name=$(basename "${trace_data}")

# 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}"/find_valid_duration/find_valid_duration.py "${trace_data}" --architecture_file_path=architecture_path.yaml --duration "${duration}" -v
python3 "${script_path}"/find_valid_duration/find_valid_duration.py "${trace_data}" --architecture_file_path=architecture_path.yaml -v
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 @@ -29,16 +29,16 @@
app = flask.Flask(__name__)


def render_page(destination_path, template_path, component_list, stats_node_dict,
def render_page(title, sub_title, destination_path, template_path, component_list, stats_node_dict,
stats_path, note_text_top, note_text_bottom, num_back):
"""Render html page"""
title = f'Analysis report'
with app.app_context():
with open(template_path, 'r', encoding='utf-8') as f_html:
template_string = f_html.read()
rendered = flask.render_template_string(
template_string,
title=title,
sub_title=sub_title,
component_list=component_list,
stats_node_dict=stats_node_dict,
stats_path=stats_path,
Expand Down Expand Up @@ -120,7 +120,9 @@ 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,
title = 'Analysis report'
sub_title = dest_dir.split('/')[-1]
render_page(title, sub_title, destination_path, template_path, component_list, stats_node_dict,
stats_path, note_text_top, note_text_bottom, args.num_back)


Expand Down
3 changes: 2 additions & 1 deletion report/report_analysis/template_report_analysis.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
crossorigin="anonymous"
/>
<title>{{ title }}</title>
<title>{{ title }}, {{ sub_title }}</title>
</head>

<body>
<div class="container">
<!-- <div> -->
<h1>{{ title }}</h1>
<h2>{{ sub_title }}</h2>
{% if link_back != "" %}
<p><a href={{ link_back }}>Back</a></p>
{% endif %}
Expand Down
5 changes: 3 additions & 2 deletions report/report_validation/make_report_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,17 @@ def make_report(report_dir: str, component_list_json: str, note_text_top, note_t
summary_topic_dict['cnt_pass'] += summary[Metrics.FREQUENCY.name]['cnt_pass']
summary_topic_dict['cnt_failed'] += summary[Metrics.FREQUENCY.name]['cnt_failed']

title = f'Validation report'
destination_path = f'{report_dir}/index.html'
template_path = f'{Path(__file__).resolve().parent}/template_report_validation.html'

title = 'Validation report'
sub_title = report_dir.split('/')[-1]
with app.app_context():
with open(template_path, 'r', encoding='utf-8') as f_html:
template_string = f_html.read()
rendered = flask.render_template_string(
template_string,
title=title,
sub_title=sub_title,
summary_callback_dict_component_metrics=summary_callback_dict_component_metrics,
summary_topic_dict_component_pair_metrics=summary_topic_dict_component_pair_metrics,
summary_callback_dict=summary_callback_dict,
Expand Down
4 changes: 3 additions & 1 deletion report/report_validation/template_report_validation.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.0/font/bootstrap-icons.css"
/>
<title>{{ title }}</title>
<title>{{ title }}, {{ sub_title }}</title>
</head>

<body>
<div class="container">
<h1>{{ title }}</h1>
<h2>{{ sub_title }}</h2>
{% if link_back != "" %}
<p><a href={{ link_back }}>Back</a></p>
{% endif %}

<hr />
{% if note_text_top %} {{ note_text_top | safe }} {% endif %}
<hr />

<ul>
<li>Validation Result</li>
Expand Down
45 changes: 27 additions & 18 deletions report/track_path/make_report_track_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,35 @@ def get_datetime_from_report_name(report_dir: str):
return str(trace_datetime)


def get_trace_data_info_from_yaml(yaml_dir: str):
caret_record_info_path = Path(yaml_dir).joinpath('caret_record_info.yaml')
autoware_version, env, route = '', '', ''
def get_version_str_from_yaml(report_dir: str):
caret_record_info = {}
caret_record_info_path = Path(report_dir).joinpath('caret_record_info.yaml')
if os.path.exists(caret_record_info_path):
with open(caret_record_info_path, encoding='UTF-8') as f_yaml:
caret_record_info = yaml.safe_load(f_yaml)
if 'autoware_version' in caret_record_info:
autoware_version = str(caret_record_info['autoware_version']).split('/')[-1]
if 'env' in caret_record_info:
env = caret_record_info['env']
elif 'map' in caret_record_info:
env = caret_record_info['map']
if 'route' in caret_record_info:
route = caret_record_info['route']
return autoware_version, env, route
autoware_version = caret_record_info.get('autoware_version', '')
pilot_auto_version = caret_record_info.get('pilot_auto_version', '')
env = caret_record_info.get('env', '')
env = caret_record_info.get('map', '') if env == '' else env
route = caret_record_info.get('route', '')
job_description = caret_record_info.get('evaluator_job_description', '') # info from evaluator

datetime = get_datetime_from_report_name(report_dir)
version = datetime
if autoware_version and pilot_auto_version:
version = version + ', ' + f'{pilot_auto_version}({autoware_version})'
elif autoware_version and pilot_auto_version == '':
version = version + ', ' + autoware_version
elif autoware_version == '' and pilot_auto_version:
version = version + ', ' + pilot_auto_version
if job_description:
version = version + ', ' + job_description
if env:
version = version + ', ' + env
if route:
version = version + ', ' + route

return version


def make_stats_file_dict(dest_dir: str, report_store_dir: str) -> list[tuple[str,str]]:
Expand All @@ -126,12 +140,7 @@ def make_stats_file_dict(dest_dir: str, report_store_dir: str) -> list[tuple[str

for report_dir in report_list:
report_dir = report_dir.rstrip('/')
datetime = get_datetime_from_report_name(report_dir)
autoware_version, env, route = get_trace_data_info_from_yaml(report_dir)
if autoware_version != '':
version = datetime + ', ' + autoware_version + ', ' + env + ',' + route
else:
version = datetime
version = get_version_str_from_yaml(report_dir)
stats_path = f'{report_dir}/analyze_path/stats_path.yaml'
if os.path.isfile(stats_path):
if version in stats_file_dict:
Expand Down
Loading

0 comments on commit 0562cfa

Please sign in to comment.