-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjoin_results.py
51 lines (38 loc) · 1.35 KB
/
join_results.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
import glob
import gzip
import json
import uuid
import argparse
from autoax import Config
import os
import pandas as pd
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)')
args = p.parse_args()
c = Config(args.config)
res_dir = os.path.join(c.cwd, "synth")
os.path.exists(res_dir) or os.makedirs(res_dir)
fn = c.result_path(args.dataset + ".json.gz")
print(f"# Reading {fn}")
data = json.load(gzip.open(fn))
print(c.result_path(args.dataset + ".hw*.json.gz"))
files_hw = glob.glob(c.result_path(args.dataset + ".hw*.json.gz"))
files_qor = glob.glob(c.result_path(args.dataset + ".qor*.json.gz"))
print("# Readning files: \n", "\n".join(files_hw+files_qor))
if not c.confirm_yes("Do you want to join the results?"):
return
for fn in files_hw + files_qor:
print(f"# Reading {fn}")
input_data = json.load(gzip.open(fn, "rt"))
for d in input_data:
data[d].update(input_data[d])
index = data[d].keys()
print("# features")
for k in index:
print(f" - {k}")
o = c.block_on_result(args.dataset + ".eval.json.gz")
json.dump(data, gzip.open(o, "wt"), indent=2)
if __name__ == "__main__":
main()