-
Notifications
You must be signed in to change notification settings - Fork 5
/
batchExecution.py
85 lines (73 loc) · 2.93 KB
/
batchExecution.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
import ujson, os
def getList(filePath):
res = []
try:
lineTmp = ""
splitTmp = None
for line in open(filePath,"r").readlines():
if line[-1] == "\n":
lineTmp = line[:-1]
else:
lineTmp = line
splitTmp = line.split("@_@")
if len(splitTmp) == 1:
res.append(line)
else:
for i in range(int(splitTmp[1])):
res.append(splitTmp[0])
except FileNotFoundError:
return None
return res
def getList_json(filePath):
res = []
try:
lineTmp = ""
splitTmp = None
for line in open(filePath,"r").readlines():
lineTmp = line if line[-1] != '\n' else line[:-1]
splitTmp = lineTmp.split("@_@")
if len(splitTmp) == 1:
res.append(ujson.loads(line))
else:
for i in range(int(splitTmp[-1])):
res.append(ujson.loads(splitTmp[0]))
except FileNotFoundError:
return None
return res
if __name__ == "__main__":
### config ###
TASK_NUM = 66
configItem_normal = ["keywordsList", "tokenizer","outputFile"]
configItem_json = ["inputProject", "languageExtensionName"]
configItem_dict = {}
for item in configItem_normal:
configItem_dict[item] = getList("./batchExecutionConfig/" + item)
for item in configItem_json:
configItem_dict[item] = getList_json("./batchExecutionConfig/" + item)
### check ###
checkRes = True
for item in configItem_dict:
if len(configItem_dict[item]) != TASK_NUM:
checkRes = False
print("Provided batch execution configurations are not matched in TASK_NUM = " + str(TASK_NUM))
break
if checkRes:
configObj = ujson.loads("".join(open("./config.json","r").readlines()))
taskId = int(open("./tasks/tNum.sta","r").readlines()[0][:-1]) + 1
#
for taskIndex in range(0, TASK_NUM):
for configuredItem in configItem_json + configItem_normal:
configObj[configuredItem] = configItem_dict[configuredItem][taskIndex]
# save configFile
with open("./config.json","w") as f:
f.write(ujson.dumps(configObj, indent=4))
# execute MSCCD
os.system("python3 controller.py")
# detectionId = open("./tasks/task" +str(taskId) + "/d_Num.str","r").readlines()[0][:-1]
# pairFileOutput
os.system("python3 ./scripts/blockPairOutput.py " + str(taskId) + " 1 " + configItem_dict['outputFile'][taskIndex])
# os.system("python3 ./scripts/blockPairOutput.py " + str(taskId) + " " + str(detectionId) + " ./" + str(taskId) + "_"+ str(detectionId) + ".csv")
#
taskId += 1
print("over")
open("./over","w").write("over")