-
Notifications
You must be signed in to change notification settings - Fork 0
/
validator_comparison_table_maker.py
70 lines (49 loc) · 1.77 KB
/
validator_comparison_table_maker.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
#! /usr/bin/env python3
import json
import pandas
from glob import glob
from copy import deepcopy
output = []
for i, ds_log_json in enumerate(sorted(glob('*.log.json'))):
ds = ds_log_json.rstrip('.log.json')
for val in ['legacy', 'schema']:
ds_json = ds + '.' + val + '.json'
try:
with open(ds_json, 'r') as f:
j = json.load(f)
except:
continue
out = {}
out['dataset'] = ds
out['validator'] = val
if val == 'legacy':
for key in ['errors', 'warnings']:
out['class'] = key
issues = j['issues'][key]
for issue in issues:
out['severity'] = issue['severity']
out['issue'] = issue['key']
try:
out['evidence'] = issue['files'][0]['evidence']
except:
out['evidence'] = None
try:
out['example_path'] = issue['files'][0]['file']['relativePath']
except:
out['example_path'] = None
output.append(deepcopy(out))
elif val == 'schema':
key = 'issues'
out['class'] = None
issues = j[key]
for issue in issues:
out['severity'] = issue['severity']
out['issue'] = issue['key']
try:
out['evidence'] = issue['files'][0]['evidence']
except:
out['evidence'] = None
out['example_path'] = issue['files'][0]['path']
output.append(deepcopy(out))
df = pandas.DataFrame(output)
df.to_parquet('validator_comparison_table.parquet')