-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvis.py
More file actions
52 lines (42 loc) · 1.21 KB
/
vis.py
File metadata and controls
52 lines (42 loc) · 1.21 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
PORT_NUM = ':50051'
CN = servaiman_pb2.TwoDMatrix()
AB = servaiman_pb2.TwoDMatrix()
CF = servaiman_pb2.TwoDMatrix()
DIMS = []
GNB = 2
def matrix(rows, data):
return np.array(data).reshape(rows, len(data)//rows)
def streamToNp(responses, field):
first = True
for response in responses:
if first: field.rows = response.rows
field.data.extend(response.data)
mat = matrix(field.rows, field.data)
print(str(field.rows))
print(mat[0][0])
print(mat.shape)
def getMeta(stub):
response = stub.GetMeta(servaiman_pb2.Request(size=10))
DIMS = response.dims
GNB = response.gnb
def getCN(stub):
global CN
responses = stub.GetCn(servaiman_pb2.Request(size=10))
streamToNp(responses, CN)
def getAB(stub):
global AB
responses = stub.GetAb(servaiman_pb2.Request(size=10))
streamToNp(responses, AB)
def getCF(stub):
global CF
responses = stub.GetCf(servaiman_pb2.Request(size=10))
streamToNp(responses, CF)
def run():
channel = grpc.insecure_channel('localhost'+PORT_NUM)
stub = servaiman_pb2_grpc.ServaimanStub(channel)
getMeta(stub)
getCN(stub)
getAB(stub)
getCF(stub)
if __name__ == '__main__':
run()