-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.py
56 lines (48 loc) · 1.7 KB
/
main.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
# call the analysis_main.py
import sys
import os
import time
from parse.specified_ranges import SpecifiedRanges
path = "/tmp"
try:
assert len(sys.argv) == 2
path = sys.argv[1]
except:
print(
"Please run 'python main.py PATH_TO_DATASETS'.\nAborted...")
exit(1)
unbounded_weight = False
unbounded_input = False
interpreter_path = sys.executable
print("Running at: ", interpreter_path)
result_filename = "results.txt"
open(result_filename, 'w').close()
times = {}
for model in SpecifiedRanges.models:
t0 = time.time()
print("Running %s" % model)
if not unbounded_weight and not unbounded_input:
os.system(
"(%s ./analysis_main.py %s/%s.pbtxt) >> %s 2>&1" % (interpreter_path, path, model, result_filename))
elif unbounded_weight:
os.system("(%s ./analysis_main.py %s/%s.pbtxt unbounded_weight) >> %s 2>&1" % (
interpreter_path, path, model, result_filename))
elif unbounded_input:
os.system("(%s ./analysis_main.py %s/%s.pbtxt unbounded_input) >> %s 2>&1" % (
interpreter_path, path, model, result_filename))
times[model] = time.time() - t0
lines = open(result_filename).readlines()
f = open(result_filename, 'a')
info = {}
for line in lines:
if line.find("warnings") != -1 and len(line) > 10:
splits = line.split()
model_name = splits[0]
info[model_name] = line.strip()
for model in SpecifiedRanges.models:
if model in info:
print(info[model] + "\t in time: %.2f" % times[model])
f.write(info[model] + "\t in time: %.2f" % times[model] + "\n")
else:
print("Runtime error when running %s." % model)
f.write("Runtime error when running %s." % model + "\n")