nvflare.apis.responder module

class Responder[source]

Bases: FLComponent, ABC

Init the Responder.

Base class for responding to clients. Controller is a subclass of Responder.

abstract control_flow(abort_signal: Signal, fl_ctx: FLContext)[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.

finalize_run(fl_ctx: FLContext)[source]

Called when a new RUN is finished.

Parameters

fl_ctx – the FL context

abstract handle_exception(task_id: str, fl_ctx: FLContext)[source]

Called after process_task_request returns, but exception occurs before task is sent out.

initialize_run(fl_ctx: FLContext)[source]

Called when a new RUN is about to start.

Parameters

fl_ctx – FL context. It must contain ‘job_id’ that is to be initialized

abstract process_submission(client: Client, task_name: str, task_id: str, result: Shareable, fl_ctx: FLContext)[source]

Called by the Engine to process the submitted result from a client.

Parameters
  • client – the Client that the submitted result is from

  • task_name – the name of the task

  • task_id – the id of the task

  • result – the Shareable result from the Client

  • fl_ctx – the FLContext

abstract process_task_request(client: Client, fl_ctx: FLContext) Tuple[str, str, Shareable][source]

Called by the Engine when a task request is received from a client.

Parameters
  • client – the Client that the task request is from

  • fl_ctx – the FLContext

Returns: task name, task id, and task data