-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup
More file actions
executable file
·227 lines (122 loc) · 4.46 KB
/
setup
File metadata and controls
executable file
·227 lines (122 loc) · 4.46 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#!/usr/bin/env python
import os
import sys
import os.path as path
import shutil
import pathlib
if sys.version < '3.5':
print('run_kernel requires python version >= 3.5')
sys.exit(1)
class kind_run(object):
def __init__(self):
"""
Main driver for run the code
"""
def __input__run__(self):
print("Choose what kind of run you want...")
print("0 - Install")
print("1 - Run Test")
print("2 - Score data basis")
print("3 - Clean test folder")
print("4 - Debug")
gkind = input("What is your election?")
print("Your election was: "+ gkind)
return gkind
def __choose_run__(self):
self.gkind = kind_run().__input__run__()
if (self.gkind == "0"):
print(" Installing... ")
compile_code()
print("Correctly instaled...")
elif (self.gkind == "1"):
print(" Running Test... ")
set_enviroment().__clean_out__()
self.test_path = os.getcwd() + "/test/run_test"
os.mkdir(self.test_path)
run_test().__test_kind__(self.gkind)
elif (self.gkind == "2"):
print(" Scoring data basis...")
run_test().__test_kind__(self.gkind)
#elif (self.gkind == "3"):
# print(" Scoring as BOT...")
# run_test().__test_kind__(self.gkind)
elif (self.gkind == "3"):
set_enviroment().__clean_out__()
elif (self.gkind == "4"):
print(" Debugging: Training Neural Network...")
set_enviroment().__clean_out__()
compile_code()
print("Correctly instaled...")
self.test_path = os.getcwd() + "/test/run_test"
os.mkdir(self.test_path)
run_test().__test_kind__(self.gkind)
class compile_code(object):
"""
Compile code with make
"""
def __init__(self):
self.src = os.getcwd()
self.build = self.src+"/build"
print("Build in:")
print(self.build)
if os.path.exists(self.build):
print("Cleaning Folder /build ")
shutil.rmtree(self.build)
os.mkdir(self.build)
os.chdir(self.build)
print("Running cmake configurations...")
os.system("cmake ..")
print("Running make installation...")
os.system("make")
class run_test(object):
def __init__(self):
"""
Set the kernel code
"""
def __test_kind__(self,kind):
self.kind = kind
self.build_path = os.getcwd()+ "/test/run_test"
print("Run Forest...")
set_enviroment().__get_exe__()
set_enviroment().__get_example__(self.kind)
os.chdir(self.build_path)
print("wut?")
print(self.build_path)
os.system("./OpenMind.exe")
class set_enviroment(object):
"""
class for handling the NN_Kernel
"""
def __init__(self):
"""
Initialize the global set of variables
"""
def __get_exe__(self):
test_path = os.getcwd() + "/test/run_test"
shutil.copy(os.getcwd()+"/build/src/OpenMind.exe", test_path)
def __get_example__(self, kind):
self.kind = kind
test_path = os.getcwd() + "/test/run_test"
example_path = os.getcwd() + "/test/example/"
if (self.kind == "1"):
shutil.copy(example_path + "Kernel_Train.inp", test_path+"/Kernel.inp")
shutil.copy(example_path + "iris.csv", test_path)
elif (self.kind == "2"):
if os.path.exists(test_path+"\iris_scored.csv"):
os.remove(test_path+"\iris_scored.csv")
shutil.copy(example_path + "Kernel_Basis.inp", test_path+"/Kernel.inp")
shutil.copy(example_path + "iris.csv", test_path)
elif (self.kind == "4"):
if os.path.exists(test_path+"\iris_scored.csv"):
os.remove(test_path+"\iris_scored.csv")
shutil.copy(example_path + "Kernel_Train_debug.inp", test_path+"/Kernel.inp")
shutil.copy(example_path + "iris.csv", test_path)
def __clean_out__(self):
print("Cleaning test...")
self.test_path = os.getcwd() + "/test/run_test"
print(self.test_path)
if os.path.exists(self.test_path):
print("Cleaning Folder /test/run_test ")
shutil.rmtree(self.test_path)
print("done!")
kind_run().__choose_run__()