profit.run.zeromq

zeromq Interface

Ideas & Help from the 0MQ Guide (zguide.zeromq.org, examples are licensed with MIT)

Module Contents

Classes

ZeroMQRunnerInterface

Runner-Worker Interface using the lightweight message queue ZeroMQ

ZeroMQWorkerInterface

Runner-Worker Interface using the lightweight message queue ZeroMQ

class profit.run.zeromq.ZeroMQRunnerInterface(size, input_config, output_config, *, transport='tcp', address=None, port=9000, connection=None, bind=None, timeout=4, retries=3, retry_sleep=1, logger_parent: logging.Logger = None)[source]

Bases: profit.run.interface.RunnerInterface

Runner-Worker Interface using the lightweight message queue ZeroMQ

  • can use different transport systems, most commonly tcp

  • can be used efficiently on a cluster (tested)

  • expected to be inefficient for a large number of small, locally run simulations where communication overhead is a concern (unverified, could be mitigated by using a different transport system)

  • known issue: some workers were unable to establish a connection with three tries, reason unknown

Parameters:
  • transport – ZeroMQ transport protocol

  • address – override ip address or hostname of the Runner Interface (default: localhost, automatic with Slurm)

  • port – port of the Runner Interface

  • connection – override for the ZeroMQ connection spec (Worker side)

  • bind – override for the ZeroMQ bind spec (Runner side)

  • timeout – connection timeout when waiting for an answer in seconds (Worker)

  • retries – number of tries to establish a connection (Worker)

  • retry_sleep – sleep time in seconds between each retry (Worker)

socket

ZeroMQ backend

Type:

zmq.Socket

logger

Logger

Type:

logging.Logger

property bind
property config
poll()[source]
handle_msg(address: bytes, msg: list)[source]
clean()[source]
__del__()[source]
class profit.run.zeromq.ZeroMQWorkerInterface(run_id: int, *, transport='tcp', address=None, port=9000, connection=None, bind=None, timeout=4, retries=3, retry_sleep=1, logger_parent: logging.Logger = None)[source]

Bases: profit.run.interface.WorkerInterface

Runner-Worker Interface using the lightweight message queue ZeroMQ

counterpart to ZeroMQRunnerInterface

property connection
property config
retrieve()[source]

retrieve the input

  1. connect to the Runner-Interface

  2. retrieve the input data and store it in .input

transmit()[source]

transmit the output

  1. transmit the output and time data (.output and .time)

  2. signal the Worker has finished

  3. close the connection to the Runner-Interface

clean()[source]
connect()[source]
disconnect()[source]
__del__()[source]
request(request)[source]

0MQ - Lazy Pirate Pattern