nvflare.app_common.executors.launcher_executor module

class LauncherExecutor(pipe_id: str, launcher_id: str | None = None, launch_timeout: float | None = None, task_wait_timeout: float | None = None, last_result_transfer_timeout: float = 300.0, external_pre_init_timeout: float = 60.0, peer_read_timeout: float | None = 60.0, monitor_interval: float = 0.1, read_interval: float = 0.5, heartbeat_interval: float = 5.0, heartbeat_timeout: float = 60.0, workers: int = 4, train_with_evaluation: bool = True, train_task_name: str = 'train', evaluate_task_name: str = 'evaluate', submit_model_task_name: str = 'submit_model', from_nvflare_converter_id: str | None = None, to_nvflare_converter_id: str | None = None)[source]

Bases: TaskExchanger

Initializes the LauncherExecutor.

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

  • launcher_id (Optional[str]) – Identifier for obtaining the Launcher from NVFlare components.

  • launch_timeout (Optional[float]) – Timeout for the Launcher’s “launch_task” method to complete (None for no timeout).

  • task_wait_timeout (Optional[float]) – Timeout for retrieving the task result (None for no timeout).

  • last_result_transfer_timeout (float) – Timeout for transmitting the last result from an external process. This value should be greater than the time needed for sending the whole result.

  • external_pre_init_timeout (float) – Time to wait for external process before it calls flare.init().

  • peer_read_timeout (float, optional) – time to wait for peer to accept sent message.

  • monitor_interval (float) – Interval for monitoring the launcher.

  • 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.

  • workers (int) – Number of worker threads needed.

  • train_with_evaluation (bool) – Whether to run training with global model evaluation.

  • train_task_name (str) – Task name of train mode.

  • evaluate_task_name (str) – Task name of evaluate mode.

  • submit_model_task_name (str) – Task name of submit_model mode.

  • from_nvflare_converter_id (Optional[str]) – Identifier used to get the ParamsConverter from NVFlare components. This ParamsConverter will be called when model is sent from nvflare controller side to executor side.

  • to_nvflare_converter_id (Optional[str]) – Identifier used to get the ParamsConverter from NVFlare components. This ParamsConverter will be called when model is sent from nvflare executor side to controller side.

check_input_shareable(task_name: str, shareable: Shareable, fl_ctx: FLContext) bool[source]

Checks input shareable before execute.

Returns:

True, if input shareable looks good; False, otherwise.

check_output_shareable(task_name: str, shareable: Shareable, fl_ctx: FLContext) bool[source]

Checks output shareable after execute.

Returns:

True, if output shareable looks good; False, otherwise.

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).

finalize(fl_ctx: FLContext) None[source]
handle_event(event_type: str, fl_ctx: FLContext) None[source]

Handles events.

Parameters:
  • event_type (str) – event type fired by workflow.

  • fl_ctx (FLContext) – FLContext information.

initialize(fl_ctx: FLContext) None[source]