nvflare.app_common.workflows.broadcast_and_process module

class BroadcastAndProcess(processor: str | ResponseProcessor, task_name: str, min_responses_required: int = 0, wait_time_after_min_received: int = 10, timeout: int = 0, clients=None)[source]

Bases: Controller

This controller broadcast a task to specified clients to collect responses, and uses the ResponseProcessor object to process the client responses.

Parameters:
  • processor – the processor that implements logic for client responses and final check.

  • id (It must be a component)

  • task_name – name of the task to be sent to client to collect responses

  • min_responses_required – min number responses required from clients. 0 means all.

  • wait_time_after_min_received – how long to wait after min responses are received from clients

  • timeout – timeout of the task. 0 means never time out

  • clients – list of clients to send the task to. None means all clients.

control_flow(abort_signal: Signal, fl_ctx: FLContext) None[source]

This is the control logic for the RUN.

NOTE: this is running in a separate thread, and its life is the duration of the RUN.

Parameters:
  • fl_ctx – the FL context

  • abort_signal – the abort signal. If triggered, this method stops waiting and returns to the caller.

process_result_of_unknown_task(client: Client, task_name: str, client_task_id: str, result: Shareable, fl_ctx: FLContext)[source]

Process result when no task is found for it.

This is called when a result submission is received from a client, but no standing task can be found for it (from the task queue)

This could happen when: - the client’s submission is too late - the task is already completed - the Controller lost the task, e.g. the Server is restarted

Parameters:
  • client – the client that the result comes from

  • task_name – the name of the task

  • client_task_id – ID of the task

  • result – the result from the client

  • fl_ctx – the FL context that comes with the client’s submission

start_controller(fl_ctx: FLContext) None[source]

Starts the controller.

This method is called at the beginning of the RUN.

Parameters:
  • fl_ctx – the FL context. You can use this context to access services provided by the

  • example (framework. For)

  • your (you can get Command Register from it and register)

  • modules. (admin command)

stop_controller(fl_ctx: FLContext)[source]

Stops the controller.

This method is called right before the RUN is ended.

Parameters:
  • fl_ctx – the FL context. You can use this context to access services provided by the

  • example (framework. For)

  • your (you can get Command Register from it and unregister)

  • modules. (admin command)