-
Notifications
You must be signed in to change notification settings - Fork 0
/
alice.py
86 lines (57 loc) · 1.96 KB
/
alice.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 time
from osbrain import run_nameserver
from osbrain import run_agent
from osbrain.proxy import NSProxy
from osbrain import run_nameserver
from osbrain import Agent
import tensorflow as tf
bufferFrames = []
class Model(Agent):
# Inicializa a conexão que vai pedir o buffer de frames
def on_init(self):
self.bind('PUSH', alias='getFrames')
self.bind('PUSH', alias='getModel')
oi = "kkk"
def getModel(self):
# Pega um modelo que cabe na memória
self.send('getModel', 'get_the_model')
def getFrames(self):
# Pega os frames
self.send('getFrames', 'get_the_frames')
self.set_attr(model="kkkk")
class Greeter(Agent):
def on_init(self):
self.bind('PUSH', alias='main')
def hello(self, name):
self.send('main', 'Hello, %s!' % name)
class Bob(Agent):
def custom_log(self, message):
self.log_info('Received: %s' % message)
if __name__ == '__main__':
# System deployment
print("Alice")
# Conecta no name server remoto
ns = run_nameserver()
#print(ns)
# Cria um agent local
alice = run_agent('Alice', nsaddr = "127.0.0.1:15793", base=Greeter)
model = run_agent('Model', base=Model, attributes=dict(model = None, bufferFrames = None))
model.getFrames()
print("Enviando mensagem")
alice.hello('Bob')
print("testando a variavel definida o init")
print(model.get_attr(""))
print(model.get_attr("model"))
print(model.get_attr("model"))
# Registra esse agent no nameserver
#alice = ns.proxy('Alice0')
#print(ns.agents())
#for alias in ns.agents():
# print(alias)
# Criando um proxy para esse agente
# alice = ns.proxy('Alice123')
#ns = NSProxy(nsaddr='127.0.0.1:10357')
#alice = run_agent('Alice')
# System configuration
#addr = alice.bind('PUSH', alias='main')
#addr = alice.bind('PUSH', transport='tcp', addr='127.0.0.1:1234')