nvflare.app_common.streamers.container_retriever module¶
- class ContainerRetriever(topic: str | None = None, stream_msg_optional=False, stream_msg_secure=False, entry_timeout=None)[source]¶
Bases:
ObjectRetriever
Init FLComponent.
The FLComponent is the base class of all FL Components. (executors, controllers, responders, filters, aggregators, and widgets are all FLComponents)
FLComponents have the capability to handle and fire events and contain various methods for logging.
- add_container(name: str, container: Any)[source]¶
Add a container to the retriever. This must be called on the sending side
- Parameters:
name – name for the container.
container – The container to be streamed
- do_stream(target: str, request: Shareable, fl_ctx: FLContext, stream_ctx: dict, validated_data: Any)[source]¶
Stream the container to the peer. Called on the stream sending side.
- Parameters:
target – the receiving site
request – data to be sent
fl_ctx – FLContext object
stream_ctx – the stream context
validated_data – the file full path returned from the validate_request method
Returns:
- get_result(stream_ctx: dict) -> (<class 'str'>, typing.Any)[source]¶
Called on the stream receiving side. Get the final result of the streaming. The result is the location of the received file.
- Parameters:
stream_ctx – the StreamContext
Returns:
- register_stream_processing(channel: str, topic: str, fl_ctx: FLContext, stream_done_cb, **cb_kwargs)[source]¶
Called on the stream sending side.
- Parameters:
channel
topic
fl_ctx
stream_done_cb
**cb_kwargs
Returns:
- retrieve_container(from_site: str, fl_ctx: ~nvflare.apis.fl_context.FLContext, timeout: float, name: str) -> (<class 'str'>, typing.Any)[source]¶
Retrieve a container from the specified site. This method is to be called by the app.
- Parameters:
from_site – the site that has the container to be retrieved
fl_ctx – FLContext object
timeout – how long to wait for the file
name – name of the container
Returns: a tuple of (ReturnCode, container)
- validate_request(request: ~nvflare.apis.shareable.Shareable, fl_ctx: ~nvflare.apis.fl_context.FLContext) -> (<class 'str'>, typing.Any)[source]¶
Object sending side. Called to validate the received retrieval request.
- Parameters:
request – the request to be validated
fl_ctx – FLContext object
Returns: tuple of (ReturnCode, Validation Data) This method should do as much as possible so that the do_stream method won’t be called if any error is detected (the do_stream method is called in a separate thread). The validation data produced by this method will be passed to the do_stream method.