nvflare.app_common.widgets.streaming module¶
- class AnalyticsReceiver(events: Optional[List[str]] = None)[source]¶
Bases:
Widget
,ABC
Receives analytic data.
- Parameters
events (optional, List[str]) – A list of event that this receiver will handle.
- abstract finalize(fl_ctx: FLContext)[source]¶
Finalizes the receiver.
- Parameters
fl_ctx (FLContext) – fl context.
- handle_event(event_type: str, fl_ctx: FLContext)[source]¶
Handles events.
- Parameters
event_type (str) – event type fired by workflow.
fl_ctx (FLContext) – FLContext information.
- class AnalyticsSender(event_type='analytix_log_stats')[source]¶
Bases:
Widget
Sends analytics data.
- Note::
This class implements some common methods follows signatures from PyTorch SummaryWriter. It provides a convenient way for Learner to use.
- Parameters
event_type (str) – event type to fire.
- add_image(tag: str, image, global_step: Optional[int] = None, **kwargs)[source]¶
Sends an image.
- Parameters
tag (str) – Data identifier.
image – Image to send.
global_step (optional, int) – Global step value.
**kwargs – Additional arguments to pass to the receiver side.
- add_scalar(tag: str, scalar: float, global_step: Optional[int] = None, **kwargs)[source]¶
Sends a scalar.
- Parameters
tag (str) – Data identifier.
scalar (float) – Value to send.
global_step (optional, int) – Global step value.
**kwargs – Additional arguments to pass to the receiver side.
- add_scalars(tag: str, scalars: dict, global_step: Optional[int] = None, **kwargs)[source]¶
Sends scalars.
- Parameters
tag (str) – The parent name for the tags.
scalars (dict) – Key-value pair storing the tag and corresponding values.
global_step (optional, int) – Global step value.
**kwargs – Additional arguments to pass to the receiver side.
- add_text(tag: str, text: str, global_step: Optional[int] = None, **kwargs)[source]¶
Sends a text.
- Parameters
tag (str) – Data identifier.
text (str) – String to send.
global_step (optional, int) – Global step value.
**kwargs – Additional arguments to pass to the receiver side.
- create_analytic_dxo(tag: str, value, data_type: AnalyticsDataType, **kwargs) DXO [source]¶
Creates the analytic DXO.
- Parameters
tag (str) – the tag associated with this value.
value – the analytic data.
data_type (AnalyticsDataType) – analytic data type.
kwargs – additional arguments to be passed into the receiver side’s function.
- Returns
A DXO object that contains the analytic data.
- send_analytic_dxo(comp: FLComponent, dxo: DXO, fl_ctx: FLContext, event_type: str = 'analytix_log_stats')[source]¶
Sends analytic dxo.
- Parameters
comp (FLComponent) – An FLComponent.
dxo (DXO) – analytic data in dxo.
fl_ctx (FLContext) – fl context info.
event_type (str) – Event type.