openfl.transport.grpc.director_client.ShardDirectorClient#

class openfl.transport.grpc.director_client.ShardDirectorClient(*, director_host, director_port, shard_name, tls=True, root_certificate=None, private_key=None, certificate=None)[source]#

Bases: object

The internal director client class.

This class communicates with the director to manage the shard’s participation in the federation.

shard_name#

The name of the shard.

Type:

str

stub#

The gRPC stub for communication with the director.

Type:

director_pb2_grpc.DirectorStub

__init__(*, director_host, director_port, shard_name, tls=True, root_certificate=None, private_key=None, certificate=None)[source]#

Initialize a shard director client object.

Parameters:
  • director_host (str) – The host of the director.

  • director_port (int) – The port of the director.

  • shard_name (str) – The name of the shard.

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

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

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

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

Return type:

None

Methods

__init__(*, director_host, director_port, ...)

Initialize a shard director client object.

get_experiment_data(experiment_name)

Get an experiment data from the director.

report_shard_info(shard_descriptor, cuda_devices)

Report shard info to the director.

send_health_check(*, envoy_name, ...[, ...])

Send envoy health check.

set_experiment_failed(experiment_name[, ...])

Set the experiment failed.

wait_experiment()

Wait an experiment data from the director.

get_experiment_data(experiment_name)[source]#

Get an experiment data from the director.

Parameters:

experiment_name (str) – The name of the experiment.

Returns:

The data

stream of the experiment data.

Return type:

data_stream (grpc._channel._MultiThreadedRendezvous)

report_shard_info(shard_descriptor, cuda_devices)[source]#

Report shard info to the director.

Parameters:
  • shard_descriptor (Type[ShardDescriptor]) – The descriptor of the shard.

  • cuda_devices (tuple) – The CUDA devices available on the shard.

Returns:

Whether the report was accepted by the

director.

Return type:

acknowledgement (bool)

send_health_check(*, envoy_name, is_experiment_running, cuda_devices_info=None)[source]#

Send envoy health check.

Parameters:
  • envoy_name (str) – The name of the envoy.

  • is_experiment_running (bool) – Whether an experiment is currently running.

  • cuda_devices_info (List[dict], optional) – Information about the CUDA devices. Defaults to None.

Returns:

The period for health checks.

Return type:

health_check_period (int)

set_experiment_failed(experiment_name, error_code=1, error_description='')[source]#

Set the experiment failed.

Parameters:
  • experiment_name (str) – The name of the experiment.

  • error_code (int, optional) – The error code. Defaults to 1.

  • error_description (str, optional) – The description of the error. Defaults to ‘’.

wait_experiment()[source]#

Wait an experiment data from the director.

Returns:

The name of the experiment.

Return type:

experiment_name (str)