5.1.1.6. FedEval.role

5.1.1.6.1. Submodules

5.1.1.6.2. Package Contents

5.1.1.6.2.1. Classes

Node

the basic of a node in federated learning network.

ClientContextManager

ClientNodeContextManager

Client

a client node implementation based on FlaskNode.

Server

a central server implementation based on FlaskNode.

5.1.1.6.2.2. Attributes

ContainerId

NodeId

CommunicationId

class FedEval.role.Node

the basic of a node in federated learning network. This class should be inherited instead of directly instantiate.

name

the name of this node instance.

Type:

str

fed_model

federated strategy instance constructed according to the given configurations.

Type:

FedStrategyInterface

_init_logger(logger_name: str, log_dir_name: str)
static config_gpu(container_id=None)
FedEval.role.ContainerId
FedEval.role.NodeId
FedEval.role.CommunicationId
class FedEval.role.ClientContextManager(id: ContainerId | str, tmp_dir_path: str)
property container_id: ContainerId
property client_ids: Iterable[FedEval.config.ClientId]
_allocate_client_ids() Sequence[FedEval.config.ClientId]

allocate cid for the clients hold by this container and initiate round counters.

client_cids allocation examples: # case 0: Given: container_num: 2, client_num: 13 Thus: num_clients_in_each_container -> 6 num_clients % num_containers -> 1 ## container_0 client_cids: [0..=6] ## container_1 client_cids: [7..=12]

# case 1: Given: container_num: 3, client_num: 13 Thus: num_clients_in_each_container -> 4 num_clients % num_containers -> 1 ## container_0 client_cids: [0..=4] ## container_1 client_cids: [5..=8] ## container_2 client_cids: [9..=12]

set_logger(logger)
get(client_id: FedEval.config.ClientId) ClientContext
class FedEval.role.ClientNodeContextManager
property online_client_ids: Iterable[FedEval.config.ClientId]
activate(node_id: NodeId, comm_id: CommunicationId, client_ids: Iterable[FedEval.config.ClientId])
recover_from_deactivation(node_id: NodeId)
deactivate_by_node_id(node_id: NodeId) Iterable[FedEval.config.ClientId]

mark the given node as offline and return the corresponding offline clients.

Parameters:

node_id (NodeId) – the id of the offline node

Returns:

the client on the given offline node.

Return type:

Iterable[ClientId]

deactivate_by_comm(comm_id: CommunicationId) Iterable[FedEval.config.ClientId]
get_by_node(node_id: NodeId) ClientNodeContext
get_by_client(client_id: FedEval.config.ClientId) ClientNodeContext
get_by_comm(comm_id: CommunicationId) ClientNodeContext
cluster_by_node(selected_clients: Iterable[FedEval.config.ClientId]) Mapping[NodeId, Iterable[FedEval.config.ClientId]]
class FedEval.role.Client

Bases: FedEval.role.node.Node

a client node implementation based on FlaskNode.

property log_dir
MAX_DATASET_SIZE_KEPT = 6000
_init_logger(container_id, **kwargs)
_register_handles()
start()
class FedEval.role.Server

Bases: FedEval.role.node.Node

a central server implementation based on FlaskNode.

property log_dir
_construct_fed_model()

Construct a federated model according to self.model_config and bind it to self.fed_model. This method only works after self._bind_configs().

_init_logger()
_init_metric_states()
_init_statistical_states()

initialize statistics.

_init_control_states()

initilize attributes for controlling.

_init_states()
_init_val_and_test_data()
_refresh_update_cache() None
_refresh_evaluation_cache() None
_get_recent_time_records(recent_num: int = 0) List
__get_avg_test_metric_keys() List[str]
__get_avg_val_metric_keys() List[str]
__get_cur_used_time() str
_register_services()
aggregate_train_loss(client_losses, client_sizes, cur_round)
_get_strategy_description()
snapshot_result(cur_time: float) Mapping[str, Any]
_register_handles()
process_update()
server_evaluation()
process_evaluate()
train_next_round()
distribute_evaluate(eval_best_model=False)
start()

start to provide services.