nvflare.app_common.hub.hub_executor module

class HubExecutor(pipe_id: str, task_wait_time=None, result_poll_interval: float = 0.1, task_read_wait_time: float = 10.0, read_interval: float = 2.0, heartbeat_interval: float = 5.0, heartbeat_timeout: float = 30.0, resend_interval: float = 2.0, max_resends=None)[source]

Bases: TaskExchanger

This executor is to be used by Tier-1 (T1) clients. It exchanges task data/result with the Hub Controller of Tier-2 (T2) Server

Constructor of HubExecutor.

Parameters:
  • pipe_id (str) – component id of pipe

  • task_wait_time – how long to wait for result from T2. None means waits forever.

  • result_poll_interval – polling interval for T2 result

  • task_read_wait_time – how long to wait for T2 to read a task assignment

  • read_interval – how often to read from pipe

  • heartbeat_interval – how often to send heartbeat to peer

  • heartbeat_timeout – max amount of time to allow missing heartbeats before treating peer as dead

  • resend_interval – how often to resend a message when failing to send

  • max_resends – max number of resends. None means no limit

execute(task_name: str, shareable: Shareable, fl_ctx: FLContext, abort_signal: Signal) Shareable[source]

The TaskExchanger always sends the Shareable to the peer, and expects to receive a Shareable object from the peer. The peer can convert the Shareable object to whatever format that is best for its applications (e.g. DXO or FLModel object). Similarly, when submitting result, the peer must convert its result object to a Shareable object before sending it back to the TaskExchanger.

This “late-binding” (binding of the Shareable object to an application-friendly object) strategy makes the TaskExchanger generic and can be reused for any applications (e.g. Shareable based, DXO based, or any custom data based).