openfl.transport.grpc.director_server.DirectorGRPCServer#
- class openfl.transport.grpc.director_server.DirectorGRPCServer(*, director_cls, tls=True, root_certificate=None, private_key=None, certificate=None, review_plan_callback=None, listen_host='[::]', listen_port=50051, envoy_health_check_period=0, **kwargs)[source]#
Bases:
DirectorServicerDirector transport class.
This class implements a gRPC server for the Director, allowing it to communicate with collaborators.
- Parameters:
tls (bool)
root_certificate (Path | str | None)
private_key (Path | str | None)
certificate (Path | str | None)
review_plan_callback (None | Callable)
listen_host (str)
listen_port (int)
envoy_health_check_period (int)
- listen_uri#
The URI that the server is serving on.
- Type:
str
- tls#
Whether to use TLS for the connection.
- Type:
bool
- root_certificate#
The path to the root certificate for the TLS connection.
- Type:
Path
- private_key#
The path to the server’s private key for the TLS connection.
- Type:
Path
- certificate#
The path to the server’s certificate for the TLS connection.
- Type:
Path
- server#
The gRPC server.
- Type:
grpc.Server
- __init__(*, director_cls, tls=True, root_certificate=None, private_key=None, certificate=None, review_plan_callback=None, listen_host='[::]', listen_port=50051, envoy_health_check_period=0, **kwargs)[source]#
Initialize a director object.
- Parameters:
director_cls (Type[Director]) – The class of the director.
tls (bool, optional) – Whether to use TLS for the connection. Defaults to True.
root_certificate (Optional[Union[Path, str]], optional) – The path to the root certificate for the TLS connection. Defaults to None.
private_key (Optional[Union[Path, str]], optional) – The path to the server’s private key for the TLS connection. Defaults to None.
certificate (Optional[Union[Path, str]], optional) – The path to the server’s certificate for the TLS connection. Defaults to None.
review_plan_callback (Union[None, Callable], optional) – The callback for reviewing the plan. Defaults to None.
listen_host (str, optional) – The host to listen on. Defaults to ‘[::]’.
listen_port (int, optional) – The port to listen on. Defaults to 50051.
envoy_health_check_period (int, optional) – The period for health checks. Defaults to 0.
**kwargs – Additional keyword arguments.
- Return type:
None
Methods
GetDatasetInfo(request, context)Request the info about target and sample shapes in the dataset.
GetEnvoys(request, context)Get a status information about envoys.
GetExperimentData(request, context)Receive experiment data.
GetExperimentDescription(request, context)Get an experiment description.
GetExperimentStatus(request, context)Get experiment status and update if experiment was approved.
GetExperimentsList(request, context)Get list of experiments description.
GetMetricStream(request, context)Request to stream metrics from the aggregator to frontend.
GetTrainedModel(request, context)RPC for retrieving trained models.
RemoveExperimentData(request, context)Remove experiment data RPC.
SetExperimentFailed(request, context)Set the experiment failed.
SetNewExperiment(stream, context)Request to set new experiment.
UpdateEnvoyStatus(request, context)Accept health check from envoy.
UpdateShardInfo(request, context)Receive acknowledge shard info.
WaitExperiment(request, context)Request for wait an experiment.
__init__(*, director_cls[, tls, ...])Initialize a director object.
get_caller(context)Get caller name from context.
start()Launch the director GRPC server.
- async GetDatasetInfo(request, context)[source]#
Request the info about target and sample shapes in the dataset.
- Parameters:
request (director_pb2.GetDatasetInfoRequest) – The request from the collaborator.
context (grpc.ServicerContext) – The context of the request.
- Returns:
The response to the request.
- Return type:
director_pb2.GetDatasetInfoResponse
- async GetEnvoys(request, context)[source]#
Get a status information about envoys.
- Parameters:
request (director_pb2.GetEnvoysRequest) – The request from the collaborator.
context (grpc.ServicerContext) – The context of the request.
- Returns:
The response to the request.
- Return type:
director_pb2.GetEnvoysResponse
- async GetExperimentData(request, context)[source]#
Receive experiment data.
- Parameters:
request (director_pb2.GetExperimentDataRequest) – The request from the collaborator.
context (grpc.ServicerContext) – The context of the request.
- Yields:
director_pb2.ExperimentData – The experiment data.
- async GetExperimentDescription(request, context)[source]#
Get an experiment description.
- Parameters:
request (director_pb2.GetExperimentDescriptionRequest) – The request from the collaborator.
context (grpc.ServicerContext) – The context of the request.
- Returns:
- The response to the
request.
- Return type:
director_pb2.GetExperimentDescriptionResponse
- async GetExperimentStatus(request, context)[source]#
Get experiment status and update if experiment was approved.
- Parameters:
request (director_pb2.GetExperimentStatusRequest) – The request from the collaborator.
context (grpc.ServicerContext) – The context of the request.
- Returns:
- The response to the
request.
- Return type:
director_pb2.GetExperimentStatusResponse
- async GetExperimentsList(request, context)[source]#
Get list of experiments description.
- Parameters:
request (director_pb2.GetExperimentsListRequest) – The request from the collaborator.
context (grpc.ServicerContext) – The context of the request.
- Returns:
- The response to the
request.
- Return type:
director_pb2.GetExperimentsListResponse
- async GetMetricStream(request, context)[source]#
Request to stream metrics from the aggregator to frontend.
- Parameters:
request (director_pb2.GetMetricStreamRequest) – The request from the collaborator.
context (grpc.ServicerContext) – The context of the request.
- Yields:
director_pb2.GetMetricStreamResponse – The metrics.
- async GetTrainedModel(request, context)[source]#
RPC for retrieving trained models.
- Parameters:
request (director_pb2.GetTrainedModelRequest) – The request from the collaborator.
context (grpc.ServicerContext) – The context of the request.
- Returns:
The response to the request.
- Return type:
director_pb2.TrainedModelResponse
- async RemoveExperimentData(request, context)[source]#
Remove experiment data RPC.
- Parameters:
request (director_pb2.RemoveExperimentRequest) – The request from the collaborator.
context (grpc.ServicerContext) – The context of the request.
- Returns:
- The response to
the request.
- Return type:
response (director_pb2.RemoveExperimentResponse)
- async SetExperimentFailed(request, context)[source]#
Set the experiment failed.
- Parameters:
request (director_pb2.SetExperimentFailedRequest) – The request from the collaborator.
context (grpc.ServicerContext) – The context of the request.
- Returns:
- The response
to the request.
- Return type:
response (director_pb2.SetExperimentFailedResponse)
- async SetNewExperiment(stream, context)[source]#
Request to set new experiment.
- Parameters:
stream (grpc.aio._MultiThreadedRendezvous) – The stream of experiment data.
context (grpc.ServicerContext) – The context of the request.
- Returns:
The response to the request.
- Return type:
director_pb2.SetNewExperimentResponse
- async UpdateEnvoyStatus(request, context)[source]#
Accept health check from envoy.
- Parameters:
request (director_pb2.UpdateEnvoyStatusRequest) – The request from the envoy.
context (grpc.ServicerContext) – The context of the request.
- Returns:
- The response to the
request.
- Return type:
resp (director_pb2.UpdateEnvoyStatusResponse)
- async UpdateShardInfo(request, context)[source]#
Receive acknowledge shard info.
- Parameters:
request (director_pb2.UpdateShardInfoRequest) – The request from the shard.
context (grpc.ServicerContext) – The context of the request.
- Returns:
- The response to the
request.
- Return type:
reply (director_pb2.UpdateShardInfoResponse)
- async WaitExperiment(request, context)[source]#
Request for wait an experiment.
- Parameters:
request (director_pb2.WaitExperimentRequest) – The request from the collaborator.
context (grpc.ServicerContext) – The context of the request.
- Returns:
The response to the request.
- Return type:
director_pb2.WaitExperimentResponse