-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_s2s_dashboard.py
158 lines (131 loc) · 7.08 KB
/
update_s2s_dashboard.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import argparse
from collections import defaultdict
import datetime
import os
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="")
parser.add_argument("--backend-compile", default=False, action="store_true", help="")
args = parser.parse_args()
missing_button = f"[![missing](https://img.shields.io/badge/missing-gray)]()"
test_results = defaultdict(lambda: defaultdict(lambda: defaultdict(lambda: {'numpy': missing_button, 'jax': missing_button, 'tensorflow': missing_button})))
color_codes = {
"passed": "green",
"failed": "red",
"skipped": "yellow",
"missing": "gray",
}
passed = 0
failed = 0
test_outcomes = {}
total_tests = {
"jax": 0,
"numpy": 0,
"tensorflow": 0,
}
for subdir, _, files in os.walk("artifacts"):
for file_name in files:
if "_results" in file_name:
file_path = os.path.join(subdir, file_name)
with open(file_path, "r") as file:
for line in file.readlines():
split_line = line.split(",")[:-1]
if len(split_line) != 6:
continue
record = {
"target": split_line[0],
"mode": split_line[1],
"backend_compile": split_line[2],
"function": split_line[3],
"workflow_link": split_line[4],
"outcome": split_line[5],
}
target = record["target"]
mode = record["mode"]
backend_compile = record["backend_compile"]
function = record["function"]
outcome = record['outcome']
workflow_link = record['workflow_link']
backend_compile = "T" in backend_compile.upper() # convert to bool
if backend_compile != args.backend_compile:
# do not consider this test, as it uses the wrong setting of backend_compile
continue
if outcome == "passed":
passed += 1
total_tests[target] += 1
elif outcome == "failed":
failed += 1
total_tests[target] += 1
if function not in test_outcomes:
test_outcomes[function] = {
"jax": False,
"numpy": False,
"tensorflow": False,
}
test_outcomes[function][target if mode in ["transpile", "s2s"] else "trace"] = outcome == "passed"
split_fn = function.split(".")
integration = split_fn[0]
if len(split_fn) > 2:
submodule = split_fn[1] if split_fn[1] != "geometry" else "geometry." + split_fn[2]
else:
submodule = ""
if integration in ["transformers"]:
# remove the subsection name here, as it is not actually the submodule in these cases
function = integration + "." + split_fn[-1]
color = color_codes.get(outcome, 'yellow')
button = f"[![{outcome}](https://img.shields.io/badge/{outcome}-{color})]({workflow_link})"
if workflow_link not in [None, "null"]:
test_results[integration][submodule][function][target if mode in ["transpile", "s2s"] else "trace_graph"] = button
fns_passing_all_targets = 0
fns_passing_jax = 0
fns_passing_numpy = 0
fns_passing_tensorflow = 0
for fn, outcomes in test_outcomes.items():
if all(outcomes.values()): fns_passing_all_targets += 1
if outcomes["jax"]: fns_passing_jax += 1
if outcomes["numpy"]: fns_passing_numpy += 1
if outcomes["tensorflow"]: fns_passing_tensorflow += 1
percent_fns_passing_all_targets = round(100 * fns_passing_all_targets / sum(total_tests.values()), 2)
percent_fns_passing_jax = round(100 * fns_passing_jax / (total_tests["jax"] or 1), 2)
percent_fns_passing_numpy = round(100 * fns_passing_numpy / (total_tests["numpy"] or 1), 2)
percent_fns_passing_tensorflow = round(100 * fns_passing_tensorflow / (total_tests["tensorflow"] or 1), 2)
if passed + failed > 0:
percent_passing = round(100 * passed / (passed + failed), 1)
else:
percent_passing = 0
# sort the paths & functions
sorted_paths = sorted(test_results.keys())
sorted_test_results = {path: dict(sorted(test_results[path].items())) for path in sorted_paths}
now = datetime.datetime.now()
current_date = now.date()
readme_content = "# Ivy Integration Tests Dashboard\n\n"
readme_content += f"### Last updated: {current_date}\n\n"
readme_content += f"- Successfully Transpiling to TensorFlow: {percent_fns_passing_tensorflow}%\n"
readme_content += f"- Successfully Transpiling to JAX: {percent_fns_passing_jax}%\n"
readme_content += f"- Successfully Transpiling to Numpy (functions only): {percent_fns_passing_numpy}%\n"
readme_content += f"- Total Tests Passing: {passed}\n"
readme_content += f"- Total Tests Failing: {failed}\n"
readme_content += f"- Percent Tests Passing: {percent_passing}%\n"
for integration, submodule_functions in sorted_test_results.items():
readme_content += f"<div style='margin-top: 35px; margin-bottom: 20px; margin-left: 25px;'>\n"
readme_content += f"<details>\n<summary style='margin-right: 10px;'><span style='font-size: 1.5em; font-weight: bold'>{integration}</span></summary>\n\n"
for submodule, functions in submodule_functions.items():
readme_content += f"<div style='margin-top: 7px; margin-botton: 1px; margin-left: 25px;'>\n"
readme_content += f"<details>\n<summary><span style=''>{submodule}</span></summary>\n\n"
readme_content += "| Function | numpy | jax | tensorflow |\n"
readme_content += "|----------|-------|-----|------------|\n"
for function, results in functions.items():
readme_content += f"| {function} | {results['numpy']} | {results['jax']} | {results['tensorflow']} |\n"
readme_content += "</details>\n\n"
readme_content += "</div>\n\n"
readme_content += "</details>\n\n"
readme_content += "</div>\n\n"
dashboard_name = "NATIVE_COMPILATION_DASHBOARD.md" if args.backend_compile else "DASHBOARD.md"
with open(dashboard_name, "w") as f:
f.write(readme_content)
with open(dashboard_name, "r") as f:
lines = f.readlines()
for line in lines:
print(line)
print("passed:", passed)
print("failed:", failed)
print(f"{percent_passing}% tests passing")