-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.py
119 lines (98 loc) · 4.39 KB
/
common.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
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
#!usr/bin/env python
import os
class requests(object):
def __init__(self, gpuid, topologies, iterations, batch_size):
self.gpuid = gpuid
self.topologies = topologies
self.iterations = iterations
self.batch_size = batch_size
self.iterations = iterations
self.batch_size = batch_size
class TaskInfo():
def __init__(self, task, state):
self.task = task
self.state = state
class BinaryInfo(object):
def __init__(self, binary_name, size, date):
self.binary_name = binary_name
self.size = size
self.date = date
class ResultObject(object):
def __init__(self, request_id, docker_id, gpu_model,\
email, framework, topology, batch_size, \
source, iteration, score, images_pre_sec):
self.request_id = request_id
self.docker_id = docker_id
self.gpu_model = gpu_model
self.email = email
self.framework = framework
self.topology = topology
self.batch_size = batch_size
self.source = source
self.iteration = iteration
self.score = score
self.images_pre_sec = images_pre_sec
class RequestObject(object):
def __init__(self, request_id, docker_id, gpu_model,\
mail_addr, framework, topology, batch_size, \
iteration, request_time):
self.request_id = request_id
self.docker_id = docker_id
self.gpu_model = gpu_model
self.mail_addr = mail_addr
self.framework = framework
self.topology = topology
self.batch_size = batch_size
self.iteration = iteration
self.request_time = request_time
def exist_log(self):
return os.path.isfile("log/%s.zip" % self.request_id)
@property
def profile_file(self):
return "%s.zip" % self.request_id
class DataMediator():
def __init__(self, header):
self.header = header
self.dataList = []
def append(self, row):
self.dataList.append(row)
def __len__(self):
return len(self.dataList)
def pop(self):
return self.dataList.pop()
def to_data_frame(self):
result = {}
for index, entry in enumerate(self.header):
result[entry] = []
for item in self.dataList:
for index, entry in enumerate(self.header):
result[entry].append(item[index])
return result
def to_result_objects(self):
result = []
for item in self.dataList:
result.append(ResultObject(item[self.header.index("REQUEST_ID")], \
item[self.header.index("DOCKER_ID")], \
item[self.header.index("GPU_MODEL")], \
item[self.header.index("MAIL_ADDRESS")], \
item[self.header.index("FRAMEWORK")], \
item[self.header.index("TOPOLOGY")], \
item[self.header.index("BATCH_SIZE")], \
item[self.header.index("SOURCE")], \
item[self.header.index("ITERATION")], \
item[self.header.index("SCORE")], \
item[self.header.index("IMAGES_PRE_SEC")]))
return result
def to_request_objects(self):
result = []
for item in self.dataList:
result.append(RequestObject(item[self.header.index("REQUEST_ID")], \
item[self.header.index("DOCKER_ID")], \
item[self.header.index("GPU_MODEL")], \
item[self.header.index("MAIL_ADDRESS")],\
item[self.header.index("FRAMEWORK")], \
item[self.header.index("TOPOLOGY")], \
item[self.header.index("BATCH_SIZE")], \
item[self.header.index("ITERATION")], \
item[self.header.index("REQUEST_TIME")]))
return result