-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathparse_qor.py
65 lines (42 loc) · 1.34 KB
/
parse_qor.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
# This script is used to generate the lib_tuples.cpp file
import gzip
import json
import uuid
import argparse
from autoax import Config
import os
def main():
p = argparse.ArgumentParser()
p.add_argument('config', help='Config file (yaml)')
p.add_argument('dataset', help='Dataset file form results (e.g. random)')
p.add_argument('results', help='Result file')
args = p.parse_args()
c = Config(args.config)
fn = c.result_path(args.dataset + ".json.gz")
run_list = c.block_on_result(args.dataset + ".qor.json.gz")
print(f"# Reading {fn}")
data = json.load(gzip.open(fn))
res = {}
with open(args.results) as f:
for line in f:
row = line.split(";")
if len(row) < 2:
continue
if row[0] not in data:
print("skipping", row[0])
continue
r = {}
for l in row[1:]:
l = l.strip()
if not l:
continue
k, v = l.split("=")
r[k] = v
res[row[0]] = r
for d in data:
if d not in res:
print("!!! missing evaluation of config", d)
print("# Creating " , run_list )
json.dump(res, gzip.open(run_list, "wt"), indent=2)
if __name__ == "__main__":
main()