Aggregator Connectors Factory#
The base factory class that allows for creation of the aggregator connector.
- class fma_core.workflows.aggregator_connectors_factory.BaseAggConnector(settings: Dict)#
Bases:
ABC
The factory class to create the aggregator connectors.
Initialization function for the aggregation connector.
- Parameters:
settings (Dict) – The settings that will be used to initialize the aggregation connector
- Raises:
ValueError – metadata_connector not specified in settings
Exception – model_data_connector not specified in settings
- 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_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_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
- 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
- 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]
- pull_model_updates_data(model_updates: List[Any]) Any #
Pull Model weights that have been pushed by the clients as model updates.
- Parameters:
model_updates (List[Any]) – A list of model updates
- Returns:
A list of data used to represent the models associated with 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:
Any
- post_new_model_aggregate(model: Any, parent_agg: Any, results: List[Any]) Any #
Creates an entry in a DB of a new ModelAggregate.
- Parameters:
model (Any) – FederatedModel object
parent_agg (Any) – The aggregate that the ModelUpdates included were based on
results (Any) – The data associated with the ModelAggregate being stored
- Returns:
Object containing metadata on newly added ModelAggregate
- 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]
- 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_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.