p2pfl.communication.protocols.protobuff.gossiper moduleΒΆ
Protocol agnostic gossiper.
- class p2pfl.communication.protocols.protobuff.gossiper.Gossiper(neighbors, build_msg, period=None, messages_per_period=None)[source]ΒΆ
Bases:
Thread,NodeComponentGossiper for agnostic communication protocol.
- Parameters:
neighbors (
Neighbors)build_msg (
Callable[...,RootMessage])period (
float|None)messages_per_period (
int|None)
- add_message(msg)[source]ΒΆ
Add message to pending.
- Parameters:
msg (
RootMessage) β Message to send.pending_neis β Neighbors to send the message.
- Return type:
None
- check_and_set_processed(msg)[source]ΒΆ
Check if message was already processed and set it as processed.
- Parameters:
msg (
RootMessage) β Message to check.- Return type:
bool
- gossip_weights(early_stopping_fn, get_candidates_fn, status_fn, model_fn, period, temporal_connection)[source]ΒΆ
Gossip model weights. This is a synchronous gossip. End when there are no more neighbors to gossip.
- Parameters:
early_stopping_fn (
Callable[[],bool]) β Function to check if the gossip should stop.get_candidates_fn (
Callable[[],list[str]]) β Function to get the neighbors to gossip.status_fn (
Callable[[],Any]) β Function to get the status of the node.model_fn (
Callable[[str],tuple[Any,str,int,list[str]]]) β Function to get the model of a neighbor.period (
float) β Period of gossip.temporal_connection (
bool) β Flag to create a connection if neis not connected directly.
- Return type:
None