nvflare.app_common.abstract.task_handler module

class TaskHandler(local_comp_id: str, local_comp_type: type)[source]

Bases: InitFinalComponent, ABC

TaskHandler focuses on computing and returning results only for given task.

Init FLComponent.

The FLComponent is the base class of all FL Components. (executors, controllers, responders, filters, aggregators, and widgets are all FLComponents)

FLComponents have the capability to handle and fire events and contain various methods for logging.

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

Executes a task.

Parameters:
  • task_name – task name

  • shareable – input data

  • fl_ctx – FLContext

  • abort_signal (Signal) – signal to check during execution to determine whether this task is aborted.

Returns:

Output data

finalize(fl_ctx: FLContext)[source]
initialize(fl_ctx: FLContext)[source]

This is called when client is start Run. At this point the server hasn’t communicated to the local component yet. :param fl_ctx: fl_ctx: FLContext of the running environment

load_and_init_local_comp(fl_ctx)[source]