openfl.transport.grpc.aggregator_server.AggregatorGRPCServer#

class openfl.transport.grpc.aggregator_server.AggregatorGRPCServer(aggregator, agg_port, use_tls=True, require_client_auth=True, root_certificate=None, certificate=None, private_key=None, **kwargs)[source]#

Bases: AggregatorServicer

GRPC server class for the Aggregator.

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

aggregator#

The aggregator that this server is serving.

Type:

Aggregator

uri#

The URI that the server is serving on.

Type:

str

use_tls#

Whether to use TLS for the connection.

Type:

bool

require_client_auth#

Whether to enable client-side authentication, i.e. mTLS. Ignored if use_tls=False.

Type:

bool

root_certificate#

The path to the root certificate for the TLS connection, ignored if use_tls=False.

Type:

str

certificate#

The path to the client’s certificate for the TLS connection, ignored if use_tls=False.

Type:

str

private_key#

The path to the client’s private key for the TLS connection, ignored if use_tls=False.

Type:

str

server#

The gRPC server.

Type:

grpc.Server

server_credentials#

The server’s credentials.

Type:

grpc.ServerCredentials

__init__(aggregator, agg_port, use_tls=True, require_client_auth=True, root_certificate=None, certificate=None, private_key=None, **kwargs)[source]#

Initialize the AggregatorGRPCServer.

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

  • agg_port (int) – The port that the server is serving on.

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

  • require_client_auth (bool) – Whether to enable client-side authentication, i.e. mTLS. Ignored if use_tls=False.

  • 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.

  • **kwargs – Additional keyword arguments.

Methods

GetAggregatedTensor(request, context)

Request a job from aggregator.

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.

GetTrainedModel(request, context)

Missing associated documentation comment in .proto file.

SendLocalTaskResults(request, context)

Request a model download from aggregator.

__init__(aggregator, agg_port[, use_tls, ...])

Initialize the AggregatorGRPCServer.

check_request(request)

Validate request header matches expected values.

get_header(collaborator_name)

Compose and return MessageHeader.

get_server()

Return gRPC server.

serve()

Start an aggregator gRPC service.

validate_collaborator(request, context)

Validate the collaborator.

GetAggregatedTensor(request, context)[source]#

Request a job from aggregator.

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

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

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

Returns:

The response to the

request.

Return type:

aggregator_pb2.GetAggregatedTensorResponse

GetExperimentDescription(request, context)[source]#

Missing associated documentation comment in .proto file.

GetMetricStream(request, context)[source]#

Missing associated documentation comment in .proto file.

GetTasks(request, context)[source]#

Request a job from aggregator.

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

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

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

Returns:

The response to the request.

Return type:

aggregator_pb2.GetTasksResponse

GetTrainedModel(request, context)[source]#

Missing associated documentation comment in .proto file.

SendLocalTaskResults(request, context)[source]#

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:

The response to the

request.

Return type:

aggregator_pb2.SendLocalTaskResultsResponse

check_request(request)[source]#

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)[source]#

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:

The header for the message.

Return type:

aggregator_pb2.MessageHeader

get_server()[source]#

Return gRPC server.

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

Returns:

The gRPC server.

Return type:

grpc.Server

serve()[source]#

Start an aggregator gRPC service.

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

validate_collaborator(request, context)[source]#

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.