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, pipe_channel_name='metric')[source]

Bases: AnalyticsSender

MetricsSender is a special type of AnalyticsSender that uses Pipe to communicate.

Parameters:
  • pipe_id (str) – Identifier for obtaining the Pipe from NVFlare components.

  • read_interval (float) – Interval for reading from the pipe.

  • heartbeat_interval (float) – Interval for sending heartbeat to the peer.

  • heartbeat_timeout (float) – Timeout for waiting for a heartbeat from the peer.

  • pipe_channel_name – the channel name for sending task requests.

Note

Users can use MetricsSender with FilePipe, CellPipe, or any other customize Pipe class.

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.