-
Notifications
You must be signed in to change notification settings - Fork 0
/
manual_check.py
executable file
·68 lines (61 loc) · 2.21 KB
/
manual_check.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
#!/usr/bin/env python3
import argparse
import subprocess
import os
def main(args):
hi = []
lo = []
with open(args.results) as f:
_, len1, _ = map(int, f.readline().split())
rest = f.read().splitlines()
hi = [l.split() for l in rest[:len1]]
lo = [l.split() for l in rest[len1:]]
done = {}
if os.path.exists(args.cache):
with open(args.cache) as f:
for line in f.read().splitlines():
x = line.split() # file1 file2 outcome
outcome = " ".join(x[2:])
done[(x[0], x[1])] = outcome
cache = open(args.cache, "a")
output = open("output.tsv", "a")
cheaters = set()
for name, lst in [("HIGH", hi), ("LOW", lo)]:
for _, f1, f2 in lst:
if (f1, f2) in done:
continue
d1 = os.path.dirname(f1)
d2 = os.path.dirname(f2)
if d1 in cheaters and d2 in cheaters:
continue
subprocess.run(["./build/compare", f1, f2, "data/left", "data/right", "data/meta"],
check=True, stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL)
if os.path.exists("data/outcome"):
os.remove("data/outcome")
subprocess.run(["tmux", "-2", "-f", "/dev/null", "start-server", ";", "source-file", "tmux.conf"])
if os.path.exists("data/outcome"):
with open("data/outcome") as f:
outcome = f.read()
else:
outcome = "q"
if outcome == "d":
continue
elif outcome != "q":
cache.write("%s %s %s\n" % (f1, f2, outcome))
cache.flush()
done[(f1, f2)] = outcome
if outcome == "y":
cheaters.add(d1)
cheaters.add(d2)
else:
break
for (f1, f2), outcome in done.items():
if outcome != "n":
output.write("%s\t%s\t%s\n" % (f1, f2, outcome))
output.flush()
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("results")
parser.add_argument("cache")
args = parser.parse_args()
main(args)