Skip to content

Commit

Permalink
Add docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
YuanTingHsieh committed Jul 23, 2024
1 parent f6a502d commit c51c4af
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ Experiment tracking for the FLARE-MONAI integration now uses `NVFlareStatsHandle

In this example, the `spleen_ct_segmentation_local` job is configured to automatically log metrics to MLflow through the FL server.

- The `config_fed_client.conf` contains the `NVFlareStatsHandler`, `ConvertToFedEvent` to send the metrics to the server side as federated events.
- The `config_fed_client.conf` contains the `NVFlareStatsHandler`, `MetricsSender`, and `MetricRelay` (with their respective pipes) to send the metrics to the server side as federated events.
- Then in `config_fed_server.conf`, the `MLflowReceiver` is configured for the server to write the results to the MLflow tracking server URI "http://127.0.0.1:5000".

We need to start MLflow tracking server before running this job:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,40 @@
{
"id": "log_writer",
"path": "monai_nvflare.nvflare_stats_handler.NVFlareStatsHandler",
"args": {}
"args": {
"metrics_sender_id": "metrics_sender"
}
},
{
"id": "metrics_sender",
"path": "nvflare.app_common.metrics_exchange.metrics_sender.MetricsSender",
"args": {
"pipe_id": "metrics_sender_pipe"
}
},
{
"id": "metrics_sender_pipe",
"path": "nvflare.fuel.utils.pipe.memory_pipe.MemoryPipe",
"args": {
"mode": "ACTIVE",
"token": "{JOB_ID}"
}
},
{
"id": "metric_relay",
"path": "nvflare.app_common.widgets.metric_relay.MetricRelay",
"args": {
"pipe_id": "metrics_relay_pipe",
"fed_event": false
}
},
{
"id": "metrics_relay_pipe",
"path": "nvflare.fuel.utils.pipe.memory_pipe.MemoryPipe",
"args": {
"mode": "PASSIVE",
"token": "{JOB_ID}"
}
},
{
"id": "event_to_fed",
Expand Down
14 changes: 14 additions & 0 deletions nvflare/app_common/metrics_exchange/metrics_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ def __init__(
topic: str = "metrics",
pipe_channel_name=PipeChannelName.METRIC,
):
"""MetricsSender is a special type of AnalyticsSender that uses `Pipe` to communicate.
Args:
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.
"""
super().__init__()
self._pipe_id = pipe_id
self._read_interval = read_interval
Expand Down

0 comments on commit c51c4af

Please sign in to comment.