nvflare.app_common.app_defined.aggregator module

class AppDefinedAggregator[source]

Bases: Aggregator, ComponentBase, ABC

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(shareable: Shareable, fl_ctx: FLContext) bool[source]

Accept the shareable submitted by the client.

Parameters:
  • shareable – submitted Shareable object

  • fl_ctx – FLContext

Returns:

first boolean to indicate if the contribution has been accepted.

aggregate(fl_ctx: FLContext) Shareable[source]

Perform the aggregation for all the received Shareable from the clients.

Parameters:

fl_ctx – FLContext

Returns:

shareable

abstract aggregate_training_result() -> (typing.Any, <class 'dict'>)[source]
handle_event(event_type, fl_ctx: FLContext)[source]

Handles events.

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

  • fl_ctx (FLContext) – FLContext information.

abstract processing_training_result(client_name: str, trained_weights: Any, trained_meta: dict) bool[source]
abstract reset()[source]

Reset the internal state of the aggregator.

Parameters:

fl_ctx – FLContext

Returns: