forked from aas-integration/integration-test2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
experiment.py
executable file
·89 lines (66 loc) · 2.77 KB
/
experiment.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#/usr/bin/env python
import argparse, os, shutil
import frontend, backend, common, sanity
def move(src, dst):
if os.path.exists(src):
shutil.move(src, dst)
def copytree(src, dst):
if os.path.exists(src):
shutil.copytree(src, dst)
def collect_stray_output(project_list, out_dir):
dljc_out_dir = os.path.join(out_dir, common.DLJC_OUTPUT_DIR)
common.mkdir(dljc_out_dir)
jaif_out_dir = os.path.join(out_dir, "jaif")
common.mkdir(jaif_out_dir)
move(os.path.join(common.WORKING_DIR, 'class_info.json'),
os.path.join(out_dir, 'class_info.json'))
for project in project_list:
collect_jars(project, out_dir)
dljc_in_dir = common.get_dljc_dir(project)
copytree(dljc_in_dir, os.path.join(dljc_out_dir, project))
move(os.path.join(common.get_project_dir(project), 'default.jaif'),
os.path.join(jaif_out_dir, "{}.jaif".format(project)))
move(os.path.join(common.CORPUS_DIR, 'corpus.jaif'),
os.path.join(jaif_out_dir, 'corpus.jaif'))
def collect_jars(project_name, out_dir):
jars_dir = os.path.join(out_dir, "jars", project_name)
common.mkdir(jars_dir)
project_dir = common.get_project_dir(project_name)
for path, _, files in os.walk(project_dir):
if ".mvn" in path:
continue
for file in files:
if file.endswith('.jar'):
move(os.path.join(path, file),
os.path.join(jars_dir))
def rotate_log_dir(d):
i = 1
dirformat = "{}.{}"
while os.path.exists(dirformat.format(d, i)):
i += 1
move(d, dirformat.format(d, i))
def main():
project_list = common.get_project_list()
parser = argparse.ArgumentParser()
parser.add_argument("-rc", "--recompute_clusters", action="store_true", help="recompute clustering for selected projects")
parser.add_argument("-c", "--cluster", type=str, help="path to the json file that contains clustering information")
parser.add_argument("-g", "--graph", action="store_true", help="set to regenerate graphs from the programs")
parser.add_argument("-d", "--dir", type=str, required=True, help="The output directory")
parser.add_argument("-p", "--projectset", type=str, help="A project set name to work on")
args = parser.parse_args()
if args.projectset:
project_list = common.get_corpus_set(args.projectset)
args.dir = os.path.abspath(os.path.join(common.WORKING_DIR, 'results', args.dir))
if os.path.exists(args.dir):
rotate_log_dir(args.dir)
common.mkdir(args.dir)
common.set_output_dir(args.dir)
kernel_dir = os.path.join(args.dir, "kernel_directory")
common.mkdir(kernel_dir)
backend.run(project_list, args, kernel_dir)
print("\n********* END OF BACKEND **********\n")
frontend.run(project_list, args, kernel_dir)
collect_stray_output(project_list, args.dir)
sanity.check_run(project_list, args.dir)
if __name__ == '__main__':
main()