-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathcombine.py
45 lines (41 loc) · 1.34 KB
/
combine.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
import argparse
import json
import os
from pathlib import Path
parser = argparse.ArgumentParser(
description="Combine A/B test fails into groups per test type"
)
parser.add_argument(
"path",
help="Path to the directory with failed A/B runs",
type=Path,
)
args = parser.parse_args()
BLOCK = "test_block_performance"
NET_THROUGHPUT = "test_network_throughput"
NET_LATENCY = "test_network_latency"
block_data = []
net_data = []
net_lat_data = []
for d in os.walk(args.path):
if "ab.json" in d[-1]:
path = d[0] + "/ab.json"
print(path)
with open(path, "r+") as f:
lines = f.read()
j = '{"data":' + lines + "}"
data = json.loads(j)
for e in data["data"]:
match e["performance_test"]:
case BLOCk:
block_data.append(e)
case NET_THROUGHPUT:
net_data.append(e)
case NET_LATENCY:
net_lat_data.append(e)
with open(f"{NET_LATENCY}.json", "w") as f:
json.dump({"results": net_lat_data}, f, indent=2, sort_keys=True)
with open(f"{NET_THROUGHPUT}.json", "w") as f:
json.dump({"results": net_data}, f, indent=2, sort_keys=True)
with open(f"{BLOCK}.json", "w") as f:
json.dump({"fails": block_data}, f, indent=2, sort_keys=True)