nvflare.app_common.streamers.container_streamer module¶
- class ContainerStreamer[source]¶
Bases:
StreamerBase
- static get_result(stream_ctx: dict) Any [source]¶
Get the received container This method is intended to be used by the stream_done_cb() function of the receiving side.
- Parameters:
stream_ctx – the stream context
Returns: The received container
- static register_stream_processing(fl_ctx: FLContext, channel: str, topic: str, stream_done_cb=None, **cb_kwargs)[source]¶
Register for stream processing on the receiving side.
- Parameters:
fl_ctx – the FLContext object
channel – the app channel
topic – the app topic
stream_done_cb – if specified, the callback to be called when the file is completely received
**cb_kwargs – the kwargs for the stream_done_cb
Returns: None
Notes: the stream_done_cb must follow stream_done_cb_signature as defined in apis.streaming.
- static stream_container(channel: str, topic: str, stream_ctx: dict, targets: List[str], container: Any, fl_ctx: FLContext, entry_timeout=None, optional=False, secure=False) bool [source]¶
Stream a file to one or more targets.
- Parameters:
channel – the app channel
topic – the app topic
stream_ctx – context data of the stream
targets – targets that the file will be sent to
container – container to be streamed
fl_ctx – a FLContext object
entry_timeout – timeout for each entry sent to targets.
optional – whether the file is optional
secure – whether P2P security is required
Returns: whether the streaming completed successfully
Notes: this is a blocking call - only returns after the streaming is done.