nvflare.apis.utils.reliable_message module
- class ReliableMessage[source]
Bases:
object- classmethod enable(fl_ctx: FLContext)[source]
Enable ReliableMessage. This method can be called multiple times, but only the 1st call has effect.
- Parameters:
fl_ctx – FL Context
Returns:
- classmethod is_available()[source]
Return whether the ReliableMessage service is available
Returns:
- classmethod register_request_handler(topic: str, handler_f, fl_ctx: FLContext)[source]
Register a handler for the reliable message with this topic
- Parameters:
topic – The topic of the reliable message
handler_f – The callback function to handle the request in the form of handler_f(topic, request, fl_ctx)
fl_ctx – FL Context
- classmethod release_request_receiver(receiver: _RequestReceiver, fl_ctx: FLContext)[source]
Release the specified _RequestReceiver from the receiver table. This is to be called after the received request is finished.
- Parameters:
receiver – the _RequestReceiver to be released
fl_ctx – the FL Context
Returns: None
- classmethod send_request(target: str, topic: str, request: Shareable, per_msg_timeout: float, tx_timeout: float, abort_signal: Signal, fl_ctx: FLContext) Shareable[source]
Send a request reliably.
- Parameters:
target – The target cell of this request.
topic – The topic of the request.
request – The request to be sent.
per_msg_timeout (float) – Number of seconds to wait for each message before timing out.
tx_timeout (float) – Timeout for the entire transaction.
abort_signal (Signal) – Signal to abort the request.
fl_ctx (FLContext) – Context for federated learning.
- Returns:
The reply from the peer.
Note
If tx_timeout is not specified or is less than or equal to per_msg_timeout, the request will be sent only once without retrying.