openfl.transport.grpc.director_server.DirectorGRPCServer

class openfl.transport.grpc.director_server.DirectorGRPCServer(*, director_cls, tls: bool = True, root_certificate: Path | str | None = None, private_key: Path | str | None = None, certificate: Path | str | None = None, review_plan_callback: None | Callable = None, listen_host: str = '[::]', listen_port: int = 50051, envoy_health_check_period: int = 0, **kwargs)

Bases: DirectorServicer

Director transport class.

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

Class Attributes:
  • director (Director) – The director that this server is serving.

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

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

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

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

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

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

Methods

GetDatasetInfo

Request the info about target and sample shapes in the dataset.

GetEnvoys

Get a status information about envoys.

GetExperimentData

Receive experiment data.

GetExperimentDescription

Get an experiment description.

GetExperimentStatus

Get experiment status and update if experiment was approved.

GetExperimentsList

Get list of experiments description.

GetMetricStream

Request to stream metrics from the aggregator to frontend.

GetTrainedModel

RPC for retrieving trained models.

RemoveExperimentData

Remove experiment data RPC.

SetExperimentFailed

Set the experiment failed.

SetNewExperiment

Request to set new experiment.

UpdateEnvoyStatus

Accept health check from envoy.

UpdateShardInfo

Receive acknowledge shard info.

WaitExperiment

Request for wait an experiment.

get_caller

Get caller name from context.

start

Launch the director GRPC server.

async GetDatasetInfo(request, context)

Request the info about target and sample shapes in the dataset.

Parameters:
Returns:

director_pb2.GetDatasetInfoResponse – The response to the request.

async GetEnvoys(request, context)

Get a status information about envoys.

Parameters:
Returns:

director_pb2.GetEnvoysResponse – The response to the request.

async GetExperimentData(request, context)

Receive experiment data.

Parameters:
Yields:

director_pb2.ExperimentData – The experiment data.

async GetExperimentDescription(request, context)

Get an experiment description.

Parameters:
Returns:

director_pb2.GetExperimentDescriptionResponse – The response to the request.

async GetExperimentStatus(request, context)

Get experiment status and update if experiment was approved.

Parameters:
Returns:

director_pb2.GetExperimentStatusResponse – The response to the request.

async GetExperimentsList(request, context)

Get list of experiments description.

Parameters:
Returns:

director_pb2.GetExperimentsListResponse – The response to the request.

async GetMetricStream(request, context)

Request to stream metrics from the aggregator to frontend.

Parameters:
Yields:

director_pb2.GetMetricStreamResponse – The metrics.

async GetTrainedModel(request, context)

RPC for retrieving trained models.

Parameters:
Returns:

director_pb2.TrainedModelResponse – The response to the request.

async RemoveExperimentData(request, context)

Remove experiment data RPC.

Parameters:
Returns:

response (director_pb2.RemoveExperimentResponse) – The response to the request.

async SetExperimentFailed(request, context)

Set the experiment failed.

Parameters:
Returns:

response (director_pb2.SetExperimentFailedResponse) – The response to the request.

async SetNewExperiment(stream, context)

Request to set new experiment.

Parameters:
  • stream (grpc.aio._MultiThreadedRendezvous) – The stream of experiment data.

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

Returns:

director_pb2.SetNewExperimentResponse – The response to the request.

async UpdateEnvoyStatus(request, context)

Accept health check from envoy.

Parameters:
Returns:

resp (director_pb2.UpdateEnvoyStatusResponse) – The response to the request.

async UpdateShardInfo(request, context)

Receive acknowledge shard info.

Parameters:
Returns:

reply (director_pb2.UpdateShardInfoResponse) – The response to the request.

async WaitExperiment(request, context)

Request for wait an experiment.

Parameters:
Returns:

director_pb2.WaitExperimentResponse – The response to the request.

get_caller(context)

Get caller name from context.

if tls == True: get caller name from auth_context if tls == False: get caller name from context header ‘client_id’

Parameters:

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

Returns:

str – The name of the caller.

start()

Launch the director GRPC server.