nvflare.client.ipc.ipc_agent module

class IPCAgent(flare_site_url: str, flare_site_name: str, agent_id: str, workspace_dir: str, secure_mode=False, submit_result_timeout=30.0, flare_site_connection_timeout=60.0, flare_site_heartbeat_timeout=None, resend_result_interval=2.0, decomposer_module=None)[source]

Bases: object

Constructor of Flare Agent. The agent is responsible for communicating with the Flare Client Job cell (CJ) to get task and to submit task result.

  • flare_site_url – the URL to the client parent cell (CP)

  • flare_site_name – the CJ’s site name (client name)

  • agent_id – the unique ID of the agent

  • workspace_dir – directory that contains startup folder and comm_config.json

  • secure_mode – whether the connection is in secure mode or not

  • submit_result_timeout – when submitting task result, how long to wait for response from the CJ

  • flare_site_heartbeat_timeout – time for missing heartbeats from CJ before considering it dead

  • flare_site_connection_timeout – time for missing heartbeats from CJ before considering it disconnected


Get a task from FLARE. This is a blocking call.

If timeout is specified, this call is blocked only for the specified amount of time. If timeout is not specified, this call is blocked forever until a task is received or agent is closed.


timeout – amount of time to block

Returns: None if no task is available during before timeout; or a Task object if task is available. :raises AgentClosed exception if the agent is closed before timeout.: :raises CallStateError exception if the call is not made properly.:

Note: the application must make the call only when it is just started or after a previous task’s result has been submitted.


Start the agent. This method must be called to enable CJ/Agent communication.

Returns: None


Stop the agent. After this is called, there will be no more communications between CJ and agent.

Returns: None

submit_result(result: TaskResult) bool[source]

Submit the result of the current task. This is a blocking call. The agent will try to send the result to flare site until it is successfully sent or the task is aborted or the agent is closed.


result – result to be submitted

Returns: whether the result is submitted successfully Raises: the CallStateError exception if the submit_result call is not made properly.

Notes: the application must only make this call after the received task is processed. The call can only be made a single time regardless whether the submission is successful.