nvflare.client.flare_agent_with_fl_model module¶
- class FlareAgentWithFLModel(pipe: Pipe | None = None, read_interval=0.1, heartbeat_interval=5.0, heartbeat_timeout=60.0, resend_interval=2.0, max_resends=None, submit_result_timeout=60.0, metric_pipe: Pipe | None = None, task_channel_name: str = 'task', metric_channel_name: str = 'metric', close_pipe: bool = True, close_metric_pipe: bool = True, decomposer_module: str | None = None)[source]¶
Bases:
FlareAgentConstructor of Flare Agent.
The agent is responsible for communicating with the Flare Client Job cell (CJ) to get task and to submit task result.
- Parameters:
pipe (Pipe) – pipe for task communication.
read_interval (float) – how often to read from the pipe. Defaults to 0.1.
heartbeat_interval (float) – how often to send a heartbeat to the peer. Defaults to 5.0.
heartbeat_timeout (float) – how long to wait for a heartbeat from the peer before treating the peer as dead, 0 means DO NOT check for heartbeat. Defaults to 30.0.
resend_interval (float) – how often to resend a message if failing to send. None means no resend. Note that if the pipe does not support resending, then no resend. Defaults to 2.0.
max_resends (int, optional) – max number of resend. None means no limit. Defaults to None.
submit_result_timeout (float) – when submitting task result, how long to wait for response from the CJ. Defaults to 30.0.
metric_pipe (Pipe, optional) – pipe for metric communication. Defaults to None.
task_channel_name (str) – channel name for task. Defaults to
task.metric_channel_name (str) – channel name for metric. Defaults to
metric.close_pipe (bool) – whether to close the task pipe when stopped. Defaults to True. Usually for
FilePipewe set to False, forCellPipewe set to True.close_metric_pipe (bool) – whether to close the metric pipe when stopped. Defaults to True. Usually for
FilePipewe set to False, forCellPipewe set to True.decomposer_module (str) – the module name which contains the external decomposers.
Convert the Shareable object received from the TaskExchanger to an app-friendly format.
Subclass can override this method to convert to its own app-friendly task data. By default, we convert to DXO object.
- Parameters:
shareable – the Shareable object received from the TaskExchanger.
- Returns:
task data.
Convert the result object to Shareable object before sending back to the TaskExchanger.
Subclass can override this method to convert its app-friendly result type to Shareable. By default, we expect the result to be DXO object.
- Parameters:
result – the result object to be converted to Shareable. If None, an empty Shareable object will be created with the rc only.
rc – the return code.
- Returns:
A Shareable object