AILab-FOI/APi

Implement containerized agents

Opened this issue · 0 comments

Only local UNIX agents are implemented for now. See TODO below:

APi/holon.py

Lines 62 to 75 in e1208c0

def setup_agent( self, agent ):
'''TODO: This method should create and start an agent
depending on type (local Unix, Docker, other
container ...). If it is a container type
there should be a possibility to schedule it
directly on some orchestration platform (i.e.
Kubernetes, Docker Swarm or similar). This should
be specified in the agent definition file (.ag).'''
self.say( 'Registering agent', agent[ 'name' ] )
address, password = self.registrar.register( agent[ 'name' ] )
agent[ 'cmd' ] = 'python3 ../agent.py "%s" "%s" "%s" "%s" "%s" "%s" "%s"' % ( agent[ 'name' ], address, password, self.address, self.token, json.dumps( agent[ 'args' ] ).replace('"','\\"'), json.dumps( agent[ 'flows' ] ).replace('"','\\"') )
agent[ 'address' ] = address
agent[ 'status' ] = 'setup'
self.agents[ agent[ 'name' ] ] = agent

Also for agents:

APi/holon.py

Lines 77 to 86 in e1208c0

def setup_channel( self, channel ):
''' TODO: Same as above, it should be possible to
create channels in an orchestration platform
if specified in the channel definition file.'''
address, password = self.registrar.register( channel[ 'name' ] )
self.say( 'Registering channel', channel[ 'name' ] )
channel[ 'cmd' ] = 'python3 ../channel.py "%s" "%s" "%s" "%s" "%s" "%s" "%s" "%s" "%s"' % ( channel[ 'name' ], address, password, self.address, self.token, json.dumps( ( self.registrar.min_port, self.registrar.max_port ) ), json.dumps( channel[ 'input' ] ).replace('"','\\"'), json.dumps( channel[ 'output' ] ).replace('"','\\"'), json.dumps( channel[ 'transformer' ] ).replace('"','\\"') )
channel[ 'address' ] = address
channel[ 'status' ] = 'setup'
self.channels[ channel[ 'name' ] ] = channel