forked from Starofall/RTX
-
Notifications
You must be signed in to change notification settings - Fork 2
/
rtx.py
61 lines (54 loc) · 1.86 KB
/
rtx.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
#!/usr/bin/python
import sys
import imp
import rtxlib
from rtxlib import info, error, debug
from rtxlib.workflow import execute_workflow
from rtxlib.report import plot
def loadDefinition(folder):
""" opens the given folder and searches for a definition.py file and checks if it looks valid"""
if len(sys.argv) != 3:
error("missing experiment folder")
exit(1)
try:
wf = imp.load_source('wf', './' + folder + '/definition.py')
print("maybe")
wf.folder = sys.argv[2]
testName = wf.name
return wf
except IOError as e:
print(e.errno)
error("Folder is not a valid experiment folder (does not contain definition.py)")
exit(1)
except AttributeError:
error("Workflow did not had a name attribute")
exit(1)
except ImportError as e:
error("Import failed: " + str(e))
exit(1)
if __name__ == '__main__':
if len(sys.argv) > 2 and sys.argv[1] == "start":
wf = loadDefinition(sys.argv[2])
# setting global variable log_folder for logging and clear log
rtxlib.LOG_FOLDER = wf.folder
rtxlib.clearOldLog()
info("> Starting RTX experiment...")
execute_workflow(wf)
plot(wf)
exit(0)
if len(sys.argv) > 2 and sys.argv[1] == "report":
wf = loadDefinition(sys.argv[2])
info("> Starting RTX reporting...")
plot(wf)
exit(0)
# Help
info("RTX Help Page")
info("COMMANDS:")
info("> python rtx.py help -> shows this page ")
info(" rtx.py start $folder -> runs the experiment in this folder")
info(" rtx.py report $folder -> shows the reports for the experiment in this folder")
info("EXAMPLE:")
info("> python rtx.py start ./examples/http-gauss")
exit(0)
else:
print("Please start this file with > python rtx.py ...")