File size: 1,119 Bytes
c13737d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | import json
from pathlib import Path
failed = []
passed = []
group_info = []
total_num_failed = 0
for log in Path().glob("*.log"):
section_num_failed = 0
with open(log, "r") as f:
for line in f:
line = json.loads(line)
if line.get("nodeid", "") != "":
test = line["nodeid"]
if line.get("duration", None) is not None:
duration = f'{line["duration"]:.4f}'
if line.get("outcome", "") == "failed":
section_num_failed += 1
failed.append([test, duration, log.name.split('_')[0]])
else:
passed.append([test, duration, log.name.split('_')[0]])
group_info.append([str(log), section_num_failed])
if len(failed) > 0:
result = "## Failed Tests:\n"
failed_table = '| Test Location | Test Class | Test Name | PyTorch Version |\n|---|---|---|---|\n| '
for test in failed:
failed_table += ' | '.join(test[0].split("::"))
failed_table += f" | {test[2]} |"
result += failed_table
print(result) |