Skip to content

Commit

Permalink
ci: Summary for physmon (#2125)
Browse files Browse the repository at this point in the history
I find myself clicking through a bunch of physmon htmls lately and thought a summary would be nice to easily spot the reference that actually changed
  • Loading branch information
andiwand committed May 16, 2023
1 parent 7786f8f commit 9293b33
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
1 change: 1 addition & 0 deletions CI/physmon/comment_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
> This is likely a physmon job failure
{% endif %}

[Summary]({{ url }}/summary.html)
[Full report]({{ url }}/)
Seeding: {{ make_url("seeded", "seeding_seeded.html") }}, {{ make_url("truth estimated", "seeding_truth_estimated.html") }}, {{ make_url("orthogonal", "seeding_orthogonal.html") }}
CKF: {{ make_url("seeded", "ckf_seeded.html") }}, {{ make_url("truth smeared", "ckf_truth_smeared.html") }}, {{ make_url("truth estimated", "ckf_truth_estimated.html") }}, {{ make_url("orthogonal", "ckf_orthogonal.html") }}
Expand Down
3 changes: 3 additions & 0 deletions CI/physmon/phys_perf_mon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,7 @@ if [[ "$mode" == "all" || "$mode" == "vertexing" ]]; then
rm $outdir/performance_vertexing_*mu*
fi

CI/physmon/summary.py $outdir/*.html $outdir/summary.html
ec=$(($ec | $?))

exit $ec
62 changes: 62 additions & 0 deletions CI/physmon/summary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import argparse
import re
import functools
import os


parser = argparse.ArgumentParser()
parser.add_argument("html", nargs="+")
parser.add_argument("output")
args = parser.parse_args()

re_title = re.compile(r'<p class="title">\s*(.*)\s*<\/p>', re.RegexFlag.MULTILINE)
re_check = re.compile(r'<a.*title="(.*)">\s*(.)\s*<\/a>', re.RegexFlag.MULTILINE)

summary = {}

for h in args.html:
with open(h, mode="r", encoding="utf-8") as f:
try:
content = f.read()
print(h, re_title.findall(content))
title = re_title.findall(content)[0]
checks = re_check.findall(content)
parsed_checks = list(map(lambda c: c[1] == "✅", checks))
summary[h] = {
"title": title,
"checks": checks,
"parsed_checks": parsed_checks,
"total": functools.reduce(lambda a, b: a and b, parsed_checks),
}
except Exception as e:
print(r"could not parse {h}", e)

with open(args.output, mode="w", encoding="utf-8") as f:
f.write(
"""<!DOCTYPE html>
<html>
<head>
<title>physmon summary</title>
<meta charset="UTF-8">
</head>
<body>
<h1>physmon summary</h1>
<ul>"""
)

for h, s in summary.items():
path = os.path.relpath(h, os.path.dirname(args.output))
f.write(
f"""
<li>{"✅" if s["total"] else "🔴"} <a href="{path}">{s["title"]}</a></li>"""
)

f.write(
"""
</ul>
</body>
</html>"""
)

0 comments on commit 9293b33

Please sign in to comment.