-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel_arrival.py
86 lines (77 loc) · 2.26 KB
/
model_arrival.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
import sys
import re
g = open('../VT/VT_2017-11_data.csv', 'r')
f = open('VT_2017-11_data_arrival.csv', 'w')
line = g.readline()
#print line
vars = [x.strip() for x in line.split(',')]
#vars = line.split(",")
header = {}
i = 0
for var in vars:
header[var] = i
i = i + 1
print header
line = g.readline()
lineno = 1
currentTime = ''
count = 1
while line:
vars = line.split(",")
if vars[header['queue']] == '"normal_q"':
lineno = lineno + 1
line = g.readline()
continue
else:
print vars[header['queue']]
#res_list = re.split(":=",vars[header['"Resource_List_nodes"']])
vars5 = vars[5].replace('"','')
resources = vars5.split('+')
total_cores = 0
total_gpus = 0
if len(resources) > 1:
print lineno
for res_lists in resources:
res_list = res_lists.split(':')
gpus = 0;
#print res_list
try:
cores = int(res_list[0])
except ValueError:
cores = 1
if len(res_list) > 1:
ppn = res_list[1].split('=')[1]
cores = cores * int(ppn)
if len(res_list) > 2:
#print str(lineno) + ': ' + str(res_list)
gpu = res_list[2].split('=')
if(len(gpu) == 2):
gpus = int(gpu[1])
else:
gpus = 1
total_cores = total_cores + cores
total_gpus = total_gpus + gpus
val = vars[header['"resources_used_walltime"']].replace('"','').split(':')
if len(val)> 2:
walltime = int(val[0]) * 60 * 60 + int(val[1]) * 60 + int(val[2])
else:
#print 'no walltime'
print val
walltime = 0
if vars[header['qtime']] == currentTime:
count = count + 1;
else:
toWrite = ''
toWrite = vars[header['queue']] + ',' + str(total_cores) + ',' + str(total_gpus) + ',' + str(walltime) + ',' + vars[header['qtime']] \
+ ',' + str(count) + ',\n'
f.write(toWrite)
count = 1
currentTime = vars[header['qtime']]
#print vars[header['"Resource_List_nodes"']]
#print vars[res_dic]
lineno = lineno + 1
line = g.readline()
#count = 0
#break
g.close()
f.close()