openfl.transport.grpc.aggregator_server.AggregatorGRPCServer

class openfl.transport.grpc.aggregator_server.AggregatorGRPCServer(aggregator, agg_port, tls=True, disable_client_auth=False, root_certificate=None, certificate=None, private_key=None, **kwargs)

Bases: AggregatorServicer

GRPC server class for the Aggregator.

This class implements a gRPC server for the Aggregator, allowing it to communicate with collaborators.

Class Attributes:
  • aggregator (Aggregator) – The aggregator that this server is serving.

  • uri (str) – The URI that the server is serving on.

  • tls (bool) – Whether to use TLS for the connection.

  • disable_client_auth (bool) – Whether to disable client-side authentication.

  • root_certificate (str) – The path to the root certificate for the TLS connection.

  • certificate (str) – The path to the server’s certificate for the TLS connection.

  • private_key (str) – The path to the server’s private key for the TLS connection.

  • server (grpc.Server) – The gRPC server.

  • server_credentials (grpc.ServerCredentials) – The server’s credentials.

Methods

GetAggregatedTensor

Request a job from aggregator.

GetExperimentDescription

Missing associated documentation comment in .proto file.

GetMetricStream

Missing associated documentation comment in .proto file.

GetTasks

Request a job from aggregator.

GetTrainedModel

Missing associated documentation comment in .proto file.

SendLocalTaskResults

Request a model download from aggregator.

check_request

Validate request header matches expected values.

get_header

Compose and return MessageHeader.

get_server

Return gRPC server.

serve

Start an aggregator gRPC service.

validate_collaborator

Validate the collaborator.

GetAggregatedTensor(request, context)

Request a job from aggregator.

This method handles a request from a collaborator for an aggregated tensor.

Parameters:
Returns:

aggregator_pb2.GetAggregatedTensorResponse – The response to the request.

GetExperimentDescription(request, context)

Missing associated documentation comment in .proto file.

GetMetricStream(request, context)

Missing associated documentation comment in .proto file.

GetTasks(request, context)

Request a job from aggregator.

This method handles a request from a collaborator for a job.

Parameters:
Returns:

aggregator_pb2.GetTasksResponse – The response to the request.

GetTrainedModel(request, context)

Missing associated documentation comment in .proto file.

SendLocalTaskResults(request, context)

Request a model download from aggregator.

This method handles a request from a collaborator to send the results of a local task.

Parameters:
  • request (aggregator_pb2.SendLocalTaskResultsRequest) – The request from the collaborator.

  • context (grpc.ServicerContext) – The context of the request.

Returns:

aggregator_pb2.SendLocalTaskResultsResponse – The response to the request.

check_request(request)

Validate request header matches expected values.

This method checks that the request is valid and was sent by an

authorized collaborator.

Parameters:

request (aggregator_pb2.MessageHeader) – Request sent from a collaborator that requires validation.

Raises:

ValueError – If the request is not valid.

get_header(collaborator_name)

Compose and return MessageHeader.

This method creates a MessageHeader for a message to the specified collaborator.

Parameters:

collaborator_name (str) – The name of the collaborator to send the message to.

Returns:

aggregator_pb2.MessageHeader – The header for the message.

get_server()

Return gRPC server.

This method creates a gRPC server if it does not already exist and returns it.

Returns:

grpc.Server – The gRPC server.

serve()

Start an aggregator gRPC service.

This method starts the gRPC server and handles requests until all quit jobs havebeen sent.

validate_collaborator(request, context)

Validate the collaborator.

This method checks that the collaborator who sent the request is authorized to do so.

Parameters:
  • request (aggregator_pb2.MessageHeader) – The request from the collaborator.

  • context (grpc.ServicerContext) – The context of the request.

Raises:

grpc.RpcError – If the collaborator or collaborator certificate is not authorized.