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
Rpc
class to do its communication and this can either be passed in or created on construction.The broker’s listening address is the address your
Accumulator
should connect to, and the broker should callupdate
regularly. An example is provided inexamples/impala/broker.py
and 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
Broker
uses an underlyingRpc
object for communication. This can be passed in as an argument, or will be constructed by default. As such certain calls on theBroker
are simply transparent calls to the underlying method.- Parameters
rpc (Optional[moolib.Rpc]) – An optional
Rpc
object to use.
Methods
Init.
Call listen on the underlying
Rpc
peer.Call set_name on the underlying
Rpc
peer.Update the state of the Broker.
- update()¶
Update the state of the Broker.