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 call update regularly. An example is provided in examples/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 underlying Rpc object for communication. This can be passed in as an argument, or will be constructed by default. As such certain calls on the Broker are simply transparent calls to the underlying method.

Parameters

rpc (Optional[moolib.Rpc]) – An optional Rpc object to use.

Methods

__init__

Init.

listen

Call listen on the underlying Rpc peer.

set_name

Call set_name on the underlying Rpc peer.

update

Update the state of the Broker.

listen()

Call listen on the underlying Rpc peer.

see Rpc listen

set_name()

Call set_name on the underlying Rpc peer.

see Rpc set_name

update()

Update the state of the Broker.