nvflare.private.fed.server.fed_server module

class BaseServer(project_name=None, min_num_clients=2, max_num_clients=10, heart_beat_timeout=600, handlers: List[FLComponent] | None = None, shutdown_period=30.0)[source]

Bases: ABC

Base server that provides the clients management and server deployment.

client_cleanup()[source]
close()[source]

Shutdown the server.

deploy(args, grpc_args=None, secure_train=False)[source]

Start a grpc server and listening the designated port.

fl_shutdown()[source]
get_all_clients() Dict[str, Client][source]

Get the list of registered clients.

Returns:

client}

Return type:

A dict of {client_token

get_cell()[source]
logout_client(token)[source]
notify_dead_client(client)[source]

Called to do further processing of the dead client

Parameters:

client – the dead client

Returns:

abstract remove_client_data(token)[source]
remove_dead_clients()[source]
set_admin_server(admin_server)[source]
class FederatedServer(project_name=None, min_num_clients=2, max_num_clients=10, cmd_modules=None, heart_beat_timeout=600, handlers: List[FLComponent] | None = None, args=None, secure_train=False, snapshot_persistor=None, overseer_agent=None, shutdown_period=30.0, check_engine_frequency=3.0)[source]

Bases: BaseServer

Federated server services.

Parameters:
  • project_name – server project name.

  • min_num_clients – minimum number of contributors at each round.

  • max_num_clients – maximum number of contributors at each round.

  • cmd_modules – command modules.

  • heart_beat_timeout – heartbeat timeout

  • handlers – A list of handler

  • args – arguments

  • secure_train – whether to use secure communication

abort_run()[source]
authentication_check(request: Message, state_check)[source]
client_challenge(request: Message) Message[source]
client_heartbeat(request: Message) Message[source]
close()[source]

Shutdown the server.

create_job_cell(job_id, root_url, parent_url, secure_train, server_config) Cell[source]
create_run_manager(workspace, job_id)[source]
deploy(args, grpc_args=None, secure_train=False)[source]

Start a grpc server and listening the designated port.

fl_shutdown()[source]
notify_dead_client(client)[source]

Called to do further processing of the dead client

Parameters:

client – the dead client

Returns:

overseer_callback(overseer_agent)[source]
process_job_failure(request: Message)[source]
quit_client(request: Message) Message[source]

Existing client quits the federated training process.

Server will stop sharing the global model with the client, further contribution will be rejected.

This function does not change min_num_clients and max_num_clients.

register_client(request: Message) Message[source]

Register a new client. Each client must be registered before being able to run jobs.

remove_client_data(token)[source]
reset_tokens()[source]

Reset the token set.

After resetting, each client can take a token and start fetching the current global model. This function is not thread-safe.

run_engine()[source]
sign_auth_token(client_name: str, token: str)[source]
start_run(job_id, run_root, conf, args, snapshot)[source]
stop_run_engine_cell()[source]
stop_training()[source]
task_meta_info(client_name)[source]

Task meta information.

The model_meta_info uniquely defines the current model, it is used to reject outdated client’s update.

verify_auth_token(client_name: str, token: str, signature)[source]