moolib.Broker¶
- class moolib.Broker¶
A class to coordinate a cohort during training.
A broker is a class that should run permanently during your training, and it’s primary function is to do simple administration for the group. It maintains a list of the peers and their addresses, and sends updates when new peers join or disconnect. It uses an underlying
Rpcclass to do its communication and this can either be passed in or created on construction.The broker’s listening address is the address your
Accumulatorshould connect to, and the broker should callupdateregularly. An example is provided inexamples/impala/broker.pyand below.Example
A simple broker:
# In this case create your own Rpc object broker_rpc = moolib.Rpc() # Pass into broker or construct your own broker = moolib.Broker(broker_rpc) # Call methods on Rpc object or Broker broker_rpc.set_name("broker") broker_rpc.listen(flags.address) while True: broker.update() time.sleep(0.25)
- __init__()¶
Init.
The
Brokeruses an underlyingRpcobject for communication. This can be passed in as an argument, or will be constructed by default. As such certain calls on theBrokerare simply transparent calls to the underlying method.- Parameters
rpc (Optional[moolib.Rpc]) – An optional
Rpcobject to use.
Methods
Init.
Call listen on the underlying
Rpcpeer.Call set_name on the underlying
Rpcpeer.Update the state of the Broker.
- update()¶
Update the state of the Broker.