nvflare.app_common.metrics_exchange.metrics_sender module

class MetricsSender(pipe_id: str = '_memory_pipe', read_interval: float = 0.1, heartbeat_interval: float = 5.0, heartbeat_timeout: float = 30.0, topic: str = 'metrics', pipe_channel_name='metric')[source]

Bases: AnalyticsSender

Sender for analytics data.

This class has some legacy methods that implement some common methods following signatures from PyTorch SummaryWriter. New code should use TBWriter instead, which contains an AnalyticsSender.

Parameters:
  • event_type (str) – event type to fire (defaults to “analytix_log_stats”).

  • writer_name – the log writer for syntax information (defaults to LogWriterName.TORCH_TB)

add(tag: str, value: Any, data_type: AnalyticsDataType, **kwargs)[source]

Create and send a DXO by firing an event.

Parameters:
  • tag (str) – Tag name

  • value (_type_) – Value to send

  • data_type (AnalyticsDataType) – Data type of the value being sent

  • global_step (optional, int) – Global step value.

Raises:

TypeError – global_step must be an int

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.