openfl.transport.grpc.director_client.DirectorClient#

class openfl.transport.grpc.director_client.DirectorClient(*, client_id, director_host, director_port, tls, root_certificate, private_key, certificate)[source]#

Bases: object

Director client class for users.

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

Parameters:
  • client_id (str)

  • director_host (str)

  • director_port (int)

  • tls (bool)

  • root_certificate (str)

  • private_key (str)

  • certificate (str)

stub#

The gRPC stub for communication with the director.

Type:

director_pb2_grpc.DirectorStub

__init__(*, client_id, director_host, director_port, tls, root_certificate, private_key, certificate)[source]#

Initialize director client object.

Parameters:
  • client_id (str) – The ID of the client.

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

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

  • 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__(*, client_id, director_host, ...)

Initialize director client object.

get_best_model(experiment_name)

Get best model method.

get_dataset_info()

Request the dataset info from the director.

get_envoys([raw_result])

Get envoys info.

get_experiment_description(name)

Get experiment info.

get_experiment_status(experiment_name)

Check if the experiment was accepted by the director.

get_experiments_list()

Get experiments list.

get_last_model(experiment_name)

Get last model method.

remove_experiment_data(name)

Remove experiment data RPC.

set_new_experiment(name, col_names, arch_path)

Send the new experiment to director to launch.

stream_metrics(experiment_name)

Stream metrics RPC.

get_best_model(experiment_name)[source]#

Get best model method.

Parameters:

experiment_name (str) – The name of the experiment.

Returns:

The best model.

Return type:

Dict[str, numpy.ndarray]

get_dataset_info()[source]#

Request the dataset info from the director.

Returns:

The sample shape and target shape of

the dataset.

Return type:

Tuple[List[int], List[int]]

get_envoys(raw_result=False)[source]#

Get envoys info.

Parameters:

raw_result (bool, optional) – Whether to return the raw result. Defaults to False.

Returns:

result (Union[director_pb2.GetEnvoysResponse,

Dict[str, Dict[str, Any]]]): The envoys info.

get_experiment_description(name)[source]#

Get experiment info.

Parameters:

name (str) – The name of the experiment.

Returns:

The description of the

experiment.

Return type:

director_pb2.ExperimentDescription

get_experiment_status(experiment_name)[source]#

Check if the experiment was accepted by the director.

Parameters:

experiment_name (str) – The name of the experiment.

Returns:

The response from

the director.

Return type:

resp (director_pb2.GetExperimentStatusResponse)

get_experiments_list()[source]#

Get experiments list.

Returns:

The list of experiments.

Return type:

List[str]

get_last_model(experiment_name)[source]#

Get last model method.

Parameters:

experiment_name (str) – The name of the experiment.

Returns:

The last model.

Return type:

Dict[str, numpy.ndarray]

remove_experiment_data(name)[source]#

Remove experiment data RPC.

Parameters:

name (str) – The name of the experiment.

Returns:

Whether the removal was acknowledged.

Return type:

bool

set_new_experiment(name, col_names, arch_path, initial_tensor_dict=None)[source]#

Send the new experiment to director to launch.

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

  • col_names (List[str]) – The names of the collaborators.

  • arch_path (str) – The path to the architecture.

  • initial_tensor_dict (dict, optional) – The initial tensor dictionary. Defaults to None.

Returns:

The response from

the director.

Return type:

resp (director_pb2.SetNewExperimentResponse)

stream_metrics(experiment_name)[source]#

Stream metrics RPC.

Parameters:

experiment_name (str) – The name of the experiment.

Yields:

Dict[str, Any] – The metrics.