Metadata Connector#

Objects used to connect to metadata components.

class fma_django_connectors.metadata_connector.DjangoMetadataConnector(settings)#

Bases: BaseMetadataConnector

The metadata connector object used for connection to Django FMA setup.

Initialization of the DjangoMetadataConnector class.

Parameters:

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

pull_federated_model_w_id(fed_model_id: int) FederatedModel#

Pulls a FederatedModel using its id.

Parameters:

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

Returns:

The FederatedModel object pulled from DB

Return type:

task_queue_base.models.FederatedModel

pull_latest_model_aggregate(model: FederatedModel) ModelAggregate#

Pulls the latest ModelAggregate in a FederatedModel.

Parameters:

model (task_queue_base.models.FederatedModel) – FederatedModel object

Returns:

The ModelAggregate registered with the FederatedModel most recently

Return type:

task_queue_base.models.ModelAggregate

pull_model_updates_ready_for_aggregation(model: FederatedModel, parent_agg: ModelAggregate) List[ModelUpdate]#

Pulls all ModelUpdates ready to be included in an aggregation.

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

  • parent_agg – The parent aggregate of the ModelUpdates used

Type:

task_queue_base.models.ModelAggregate

Returns:

List of ModelUpdates pulled/filtered

Return type:

List[task_queue_base.models.ModelUpdates]

pull_model_requirements(model: FederatedModel) List#

Pulls FederatedModel aggregation requirements and their args.

Parameters:

model (task_queue_base.models.FederatedModel) – FederatedModel object

Returns:

The requirements set for aggregation to occur

Return type:

List[Union[str, int, float, bool, None, List, Dict]]

register_model_updates_for_aggregation(model_updates: ModelUpdate)#

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

Parameters:

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

pull_model_updates_registered_for_aggregation(model: FederatedModel) List[ModelUpdate]#

Pulls all ModelUpdates registered to be included in an aggregation.

Parameters:

model (task_queue_base.models.FederatedModel) – FederatedModel object

Returns:

List of ModelUpdates pulled/filtered

Return type:

List[task_queue_base.models.ModelUpdate]

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

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:

task_queue_base.models.ModelAggregate

pull_model_updates_pending_aggregation(model: FederatedModel) List[ModelUpdate]#

Pulls all ModelUpdates pending inclusion to an aggregation task.

Parameters:

model (task_queue_base.models.FederatedModel) – FederatedModel object

Returns:

List of ModelUpdates pulled/filtered

Return type:

List[task_queue_base.models.ModelUpdates]

register_model_update_used_in_aggregate(model_updates: List[ModelUpdate], aggregate: ModelAggregate)#

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

Parameters:
  • model_updates – List of model updates

  • aggregate – ModelAggregate object

Type:

List[task_queue_base.models.ModelUpdate]

Type:

task_queue_base.models.ModelAggregate

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) – Boolean value for if the aggregation task was completed successfully

update_database()#

Migrate django database.

classmethod create(meta_connector_type: str, meta_connector_settings: Optional[Dict] = None) ClassVar#

Creates subclass of metadata connector.

Parameters:
  • meta_connector_type (str) – The subclass of metadata connector to be created

  • meta_connector_settings (Dict, optional) – The settings to initialize the connector, defaults to None

Raises:

ValueError – meta_connector_type not in BaseMetadataConnector subclass

Returns:

A valid subclass object of BaseMetadataConnector

Return type:

ClassVar