nvflare.edge.executors.hug module

class HierarchicalUpdateGatherer(learner_id: str, updater_id: str, update_timeout)[source]

Bases: Executor

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.

accept_update(task_id: str, update: Shareable, fl_ctx: FLContext) bool[source]

This is to be called by subclass to accept a specified update

Parameters:
  • task_id – ID of the task

  • update – the update to be accepted.

  • fl_ctx – FLContext object

Returns: whether the update is accepted

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

Execute the assigned task. If we are a leaf node in client hierarchy, we’ll execute the task by using the configured executor for the task name “exec_<task_name>”. This way different tasks can be handled by different executors.

If we are not leaf node, we’ll wait for results from child clients and then aggregate their results using the configured aggregator.

Parameters:
  • task_name – name of the assigned task

  • shareable – task data

  • fl_ctx – FLContext object

  • abort_signal – signal to notify abort

Returns: task result

get_current_task(fl_ctx: FLContext) TaskInfo | None[source]

Get the info of current task

Returns: TaskInfo of current task or None if no current task

Note: During the life of the task processing, the “task” data of the TaskInfo could be updated many times.

get_updater(fl_ctx: FLContext) Updater | None[source]
set_task_done(task_id: str, fl_ctx: FLContext) bool[source]

This method is to be called by subclass to forcefully end the specified task

Parameters:
  • task_id – ID of the task to be ended

  • fl_ctx – FLContext object

Returns: whether this request is accepted

task_ended(task: TaskInfo, fl_ctx: FLContext)[source]

This method is called when the current task is ended. Subclass can implement this method to finish task processing.

Parameters:
  • task – info of the task that is ended

  • fl_ctx – FLContext object

Returns: None

task_started(task: TaskInfo, fl_ctx: FLContext)[source]

This method is called when a task assignment is received from the controller. Subclass can implement this method to prepare for task processing.

Parameters:
  • task – info of the received task

  • fl_ctx – FLContext object

Returns: None

class TaskInfo(task: Shareable)[source]

Bases: object