Aggregator Connector#

Objects used to connect the aggregator components.

class fma_django_connectors.aggregator_connector.DjangoAggConnector(settings: Dict)#

Bases: BaseAggConnector

Dajngo version of the aggregator conenctor class.

Initialization function for the DajngoAggConnector class.

Parameters:

settings (Dict) – The settings that will be used to initialize the aggregation connector

Raises:

ValueError – metadata_connector not specified in settings

post_new_model_aggregate(model: FederatedModel, parent_agg: ModelAggregate, results: List[Any]) Any#

Creates an entry in a DB of a new ModelAggregate.

Parameters:
  • model (task_queue_base.models.FederatedModel) – FederatedModel object

  • parent_agg (task_queue_base.models.ModelAggregate) – The aggregate that the ModelUpdates included were based on

  • results (List[Any]) – The data associated with the ModelAggregate being stored

Returns:

Object containing metadata on newly added ModelAggregate

Return type:

Any

pull_model_updates_data(model_updates: List[ModelUpdate]) Any#

Pull Model weights that have been pushed by the clients as model updates.

Parameters:

model_updates (List[task_queue_base.models.ModelUpdate]) – A list of model updates

Returns:

A list of Model data associated with the models in a list of Model Updates

Return type:

Any

prep_model_data_for_storage(data: List[Any]) Any#

Preps model data to be stored as a file object.

Parameters:

data (List[Any]) – The model data to be stored in file form

Returns:

The data object stored in UploadedFile format

Return type:

django.core.files.uploadedfile.UploadedFile

classmethod create(agg_connector_type: str, agg_connector_settings: Optional[Dict] = None) ClassVar#

Creates subclass of aggregation connector.

Parameters:
  • agg_connector_type (str) – The subclass of aggregation connector to be created

  • agg_connector_settings (Dict) – The settings to initialize the connector

Raises:

ValueError – ValueError raised

Returns:

A valid subclass object of BaseAggConnector

Return type:

ClassVar

pull_federated_model_w_id(fed_model_id: int) Any#

Pulls a FederatedModel using its id.

Parameters:

fed_model_id (int) – The id of the FederatedModel targeted for pull

Returns:

A FederatedModel object

Return type:

Any

pull_latest_model_aggregate(model: Any) Any#

Pulls the latest ModelAggregate in a FederatedModel.

Parameters:

model (Any) – FederatedModel object

Returns:

A ModelAggregate object

Return type:

Any

pull_model_requirements(model: Any) Any#

Pulls FederatedModel aggregation requirements and their args.

Parameters:

model (Any) – FederatedModel object

Returns:

Requirements for the aggregation process

Return type:

Any

pull_model_updates_pending_aggregation(model: Any) List[Any]#

Pulls all ModelUpdates pending inclusion to an aggregation task.

Parameters:

model (Any) – FederatedModel object

Returns:

List of ModelUpdates pulled/filtered

Return type:

List[Any]

pull_model_updates_ready_for_aggregation(model: Any, parent_agg: Any) List[Any]#

Pulls all ModelUpdates ready to be included in an aggregation.

Parameters:
  • model (Any) – FederatedModel object

  • parent_agg (Any) – The parent aggregate of the ModelUpdates used

Returns:

A List of ModelUpdates

Return type:

List[Any]

pull_model_updates_registered_for_aggregation(model: Any) List[Any]#

Pulls all ModelUpdates registered to be included in an aggregation.

Parameters:

model (Any) – FederatedModel object

Returns:

A list of ModelUpdates ready for aggregation

Return type:

List[Any]

register_model_update_used_in_aggregate(model_updates: List[Any], aggregate: Any)#

Registers that a list of ModelUpdates were used in an aggregate.

Parameters:
  • model_updates (List[Any]) – List of model updates

  • aggregate (Any) – ModelAggregate object

register_model_updates_for_aggregation(model_updates: List[Any])#

Updates status of a list of ModelUpdates to register for aggregation.

Parameters:

model_updates (List[Any]) – A list of model updates

register_model_updates_use_in_aggregation_complete(model_updates: List[Any], is_successful: bool)#

Updates status of a list of ModelUpdates to “completed” on an aggregation.

Parameters:
  • model_updates (List[Any]) – A list of model updates

  • is_successful (bool) – Value for if the aggregation task was completed successfully

register_model_updates_use_in_aggregation_failed(model_updates: Any)#

Updates status of a list of ModelUpdates to “completed” on an aggregation.

Parameters:

model_updates (Any) – A list of model updates

update_metadata_database_arch()#

Used to update the architecture of the metadata database.