fl_sim.messages

fl_sim.messages#

Typed messages exchanged between the Server and Client nodes.

The legacy protocol manipulates the (private) _received_messages containers directly with magic string keys, e.g.

# server -> client (legacy)
target._received_messages = {"parameters": params, "alpha": 0.01}
# client -> server (legacy)
target._received_messages.append(
    ClientMessage(client_id=..., train_samples=..., metrics=...)
)

The typed messages below are the recommended replacement: the message fields are explicit (hence IDE-discoverable and validated by construction), and the (private) legacy containers are populated automatically by Client.receive() and Server.receive_one(), so that the legacy consumption code (e.g. Client.accept_parameters()) keeps working unchanged during the transition.

# server -> client (typed)
target.receive(ServerToClient(parameters=params, extras={"alpha": 0.01}))
# client -> server (typed)
target.receive_one(ClientToServer(client_id=..., train_samples=..., metrics=...))