5.1.1.2. FedEval.communicaiton

5.1.1.2.1. Submodules

5.1.1.2.2. Package Contents

5.1.1.2.2.1. Classes

ConfigurationManager

the base class of singletons.

ClientCommunicator

Helper class that provides a standard way to create an ABC using

ServerCommunicator

Helper class that provides a standard way to create an ABC using

ClientEvent

client-side SocketIO event handles' name.

ConnectionEvent

basic SocketIO life-cycle event names.

ServerEvent

server-side SocketIO event handles' name.

ClientFlaskCommunicator

Helper class that provides a standard way to create an ABC using

ServerFlaskCommunicator

Helper class that provides a standard way to create an ABC using

ClientGrpcCommunicator

Helper class that provides a standard way to create an ABC using

ServerGrpcCommunicator

Helper class that provides a standard way to create an ABC using

ModelWeightsHandler

ModelWeightsIoInterface

CommunicationMethod

Generic enumeration.

5.1.1.2.2.2. Functions

get_client_communicator(→ communicator.ClientCommunicator)

get_server_communicator(→ communicator.ServerCommunicator)

5.1.1.2.2.3. Attributes

Sid

server_best_weight_filename

weights_filename_pattern

class FedEval.communicaiton.ConfigurationManager(data_config: RawConfigurationDict = _DEFAULT_D_CFG, model_config: RawConfigurationDict = _DEFAULT_MDL_CFG, runtime_config: RawConfigurationDict = _DEFAULT_RT_CFG, thread_safe: bool = False)

Bases: FedEval.config.singleton.Singleton, ConfigurationManagerInterface, ClientConfigurationManagerInterface, ServerConfigurationManagerInterface, _CfgYamlInterface, _CfgJsonInterface, _CfgFileInterface, _RoledConfigurationInterface

the base class of singletons. Each cls on the inheritance tree can own only one instance.

property data_unique_id
property config_unique_id
property data_dir_name: str

The output directory of the clients’ data.

Returns:

the name of the data directory.

Return type:

str

property log_dir_path: str

the path of the base of log directory.

property history_record_path: str

the path of the history record.

property job_id: str
property encoding: str

the encoding scheme during (de)serialization.

property data_config_filename: str
property model_config_filename: str
property runtime_config_filename: str
property data_config: _DataConfig
property model_config: _ModelConfig
property runtime_config: _RuntimeConfig
property num_of_train_clients_contacted_per_round: int

the number of clients selected to participate the main federated process in each round.

property num_of_eval_clients_contacted_per_round: int

the number of clients selected to participate the main federated process in each round.

property role: FedEval.config.role.Role

return the role of this runtime entity.

Raises:

AttributeError – called without role configured.

Returns:

the role of this runtime entity.

Return type:

Role

__init_once_lock
__initiated = False
_init_file_names(data_config_filename: str = DEFAULT_D_CFG_FILENAME_YAML, model_config_filename: str = DEFAULT_MDL_CFG_FILENAME_YAML, runtime_config_filename: str = DEFAULT_RT_CFG_FILENAME_YAML) None
classmethod generate_unique_id(data_config: dict, model_config: dict, runtime_config: dict)
static _get_md5(config_string)
static load_configs(src_path, serializer: str | _CfgSerializer = _CfgSerializer.YAML, data_config_filename: str = DEFAULT_D_CFG_FILENAME_YAML, model_config_filename: str = DEFAULT_MDL_CFG_FILENAME_YAML, runtime_config_filename: str = DEFAULT_RT_CFG_FILENAME_YAML, encoding=_DEFAULT_ENCODING) Tuple[RawConfigurationDict, RawConfigurationDict, RawConfigurationDict]
static save_configs(data_cfg: RawConfigurationDict, model_cfg: RawConfigurationDict, runtime_cfg: RawConfigurationDict, dst_path, data_config_filename: str = DEFAULT_D_CFG_FILENAME_YAML, model_config_filename: str = DEFAULT_MDL_CFG_FILENAME_YAML, runtime_config_filename: str = DEFAULT_RT_CFG_FILENAME_YAML, encoding=_DEFAULT_ENCODING, serializer: str | _CfgSerializer = _CfgSerializer.YAML)
static from_files(src_path: str, data_config_filename: str = DEFAULT_D_CFG_FILENAME_YAML, model_config_filename: str = DEFAULT_MDL_CFG_FILENAME_YAML, runtime_config_filename: str = DEFAULT_RT_CFG_FILENAME_YAML, serializer: str | _CfgSerializer = _CfgSerializer.YAML, encoding=_DEFAULT_ENCODING)
to_files(dst_dir_path: str, serializer: str | _CfgSerializer = _CfgSerializer.YAML, encoding: str | None = None) None
__init_role() None
class FedEval.communicaiton.ClientCommunicator

Bases: Communicatior

Helper class that provides a standard way to create an ABC using inheritance.

abstract on(event: FedEval.communicaiton.events.ClientEvent, *on_args, **on_kwargs)
abstract invoke(event: FedEval.communicaiton.events.ServerEvent, *args, **kwargs)
abstract wait(**kw) None
class FedEval.communicaiton.ServerCommunicator

Bases: Communicatior

Helper class that provides a standard way to create an ABC using inheritance.

property ready_client_ids: Iterable[FedEval.config.role.ClientId]
abstract handle_disconnection() Iterable[FedEval.config.role.ClientId]
_handle_disconnection(comm_id: FedEval.role.container.CommunicationId) Iterable[FedEval.config.role.ClientId]
abstract handle_reconnection() Iterable[FedEval.config.role.ClientId]
_handle_reconnection(comm_id: FedEval.role.container.CommunicationId) Iterable[FedEval.config.role.ClientId]
abstract activate(node_id: FedEval.role.container.NodeId, client_ids: Iterable[FedEval.config.role.ClientId]) None
_activate(node_id: FedEval.role.container.NodeId, comm_id: FedEval.role.container.CommunicationId, client_ids: Iterable[FedEval.config.role.ClientId]) None
abstract invoke(event: FedEval.communicaiton.events.ClientEvent, *args, callee: FedEval.config.role.ClientId | None = None, **kwargs)
abstract invoke_all(event: FedEval.communicaiton.events.ClientEvent, payload: Dict[str, Any] | None = None, *args, callees: Iterable[FedEval.config.role.ClientId] | None = None, **kwargs)
abstract on(event: FedEval.communicaiton.events.ClientEvent) Callable[[Callable], Any]
abstract route(rule: str, **options: Any)
abstract run_server() None
class FedEval.communicaiton.ClientEvent

Bases: enum.Enum

client-side SocketIO event handles’ name.

Init = 'init'
RequestUpdate = 'request_update'
RequestEvaluate = 'request_evaluate'
Stop = 'stop'
class FedEval.communicaiton.ConnectionEvent

Bases: enum.Enum

basic SocketIO life-cycle event names.

Connect = 'connect'
Disconnect = 'disconnect'
Reconnect = 'reconnect'
class FedEval.communicaiton.ServerEvent

Bases: enum.Enum

server-side SocketIO event handles’ name.

WakeUp = 'client_wake_up'
Ready = 'client_ready'
ResponseUpdate = 'client_update'
ResponseEvaluate = 'client_evaluate'
class FedEval.communicaiton.ClientFlaskCommunicator

Bases: FedEval.communicaiton.communicator.ClientCommunicator

Helper class that provides a standard way to create an ABC using inheritance.

on(event: FedEval.communicaiton.events.ClientEvent, *on_args, **on_kwargs)
invoke(event: FedEval.communicaiton.events.ServerEvent, *args, **kwargs)
wait(**kw) None
class FedEval.communicaiton.ServerFlaskCommunicator

Bases: FedEval.communicaiton.communicator.ServerCommunicator

Helper class that provides a standard way to create an ABC using inheritance.

on(event: FedEval.communicaiton.events.ClientEvent) Callable[[Callable], Any]
route(rule: str, **options: Any)
invoke(event: FedEval.communicaiton.events.ClientEvent, *args, callee: FedEval.config.ClientId | None = None, **kwargs)
invoke_all(event: FedEval.communicaiton.events.ClientEvent, payload: Dict[str, Any] | None = None, *args, callees: Iterable[FedEval.config.ClientId] | None = None, **kwargs)
run_server() None
handle_disconnection() Iterable[FedEval.config.ClientId]
handle_reconnection() Iterable[FedEval.config.ClientId]
activate(node_id: FedEval.role.container.NodeId, client_ids: Iterable[FedEval.config.ClientId]) None
FedEval.communicaiton.Sid
class FedEval.communicaiton.ClientGrpcCommunicator

Bases: FedEval.communicaiton.communicator.ClientCommunicator

Helper class that provides a standard way to create an ABC using inheritance.

_on(event: FedEval.communicaiton.events.ClientEvent, handler: Callable) None
_has_handler(event: FedEval.communicaiton.events.ClientEvent) bool
_check_handler_registration(event: FedEval.communicaiton.events.ClientEvent) None
on(event: FedEval.communicaiton.events.ClientEvent, *on_args, **on_kwargs)
invoke(event: FedEval.communicaiton.events.ServerEvent, *args, **kwargs)
_invokation_generator()
wait(**kw) None
class FedEval.communicaiton.ServerGrpcCommunicator

Bases: FedEval.communicaiton.communicator.ServerCommunicator

Helper class that provides a standard way to create an ABC using inheritance.

handle_disconnection() Iterable[FedEval.config.role.ClientId]
handle_reconnection() Iterable[FedEval.config.role.ClientId]
activate(node_id: FedEval.role.container.NodeId, client_ids: Iterable[FedEval.config.role.ClientId]) None
invoke(event: FedEval.communicaiton.events.ClientEvent, *args, callee: FedEval.config.role.ClientId | None = None, **kwargs)
invoke_all(event: FedEval.communicaiton.events.ClientEvent, payload: Dict[str, Any] | None = None, *args, callees: Iterable[FedEval.config.role.ClientId] | None = None, **kwargs)
on(event: FedEval.communicaiton.events.ClientEvent) Callable[[Callable], Any]
route(rule: str, **options: Any)
run_server() None
class FedEval.communicaiton.ModelWeightsHandler(download_url_pattern: str)

Bases: ModelWeightsIoInterface

fetch_params(file_location: str)
class FedEval.communicaiton.ModelWeightsIoInterface
abstract fetch_params(filename: str)
FedEval.communicaiton.server_best_weight_filename = 'best_model.pkl'
FedEval.communicaiton.weights_filename_pattern = 'model_{}.pkl'
class FedEval.communicaiton.CommunicationMethod

Bases: enum.Enum

Generic enumeration.

Derive from this class to define new enumerations.

gRPC = 'gRPC'
SocketIO = 'SocketIO'
FedEval.communicaiton.get_client_communicator() communicator.ClientCommunicator
FedEval.communicaiton.get_server_communicator() communicator.ServerCommunicator