p2pfl.communication.protocols.client moduleΒΆ

Protocol agnostic client.

class p2pfl.communication.protocols.client.Client[source]ΒΆ

Bases: ABC

Client interface.

It is used as a interface to help to decoulple communication protocols based on clien-server architecutes.

Todo

Encapsulate msg.

abstract broadcast(msg, node_list=None)[source]ΒΆ

Broadcast a message.

Return type:

None

abstract build_message(cmd, args=None, round=None)[source]ΒΆ

Build a message to send to the neighbors.

Parameters:
  • cmd (str) – Command of the message.

  • args (Optional[List[str]]) – Arguments of the message.

  • round (Optional[int]) – Round of the message.

Return type:

Any

Returns:

Message to send.

abstract build_weights(cmd, round, serialized_model, contributors=None, weight=1)[source]ΒΆ

Build a weight message to send to the neighbors.

Parameters:
  • cmd (str) – Command of the message.

  • round (int) – Round of the message.

  • serialized_model (bytes) – Serialized model to send.

  • contributors (Optional[List[str]]) – List of contributors.

  • weight (int) – Weight of the message.

Return type:

Any

abstract send(nei, msg, create_connection=False)[source]ΒΆ

Send a message to a neighbor.

Return type:

None