nvflare.private.fed.client.fed_client_base module
- class FederatedClientBase(client_name, client_args, secure_train, server_args=None, retry_timeout=30, client_state_processors: List[Filter] | None = None, handlers: List[FLComponent] | None = None, compression=None, args=None, components=None, cell: Cell | None = None)[source]
Bases:
objectThe client-side base implementation of federated learning.
This class provide the tools function which will be used in both FedClient and FedClientLite.
To init FederatedClientBase.
- Parameters:
client_name – client name
client_args – client config args
secure_train – True/False to indicate secure train
server_args – server config args
retry_timeout – retry timeout
client_state_processors – client state processor filters
handlers – handlers
compression – communication compression algorithm
cell – CellNet communicator
- client_register(project_name, fl_ctx: FLContext)[source]
Register the client to the FL server.
- Parameters:
project_name – FL study project name.
fl_ctx – FLContext
- connect_to_server(project_name, target, scheme='grpc')[source]
Establish the connection to the FL Server using the configured target.
- Parameters:
project_name – the project name (key into self.servers)
target – the host:port of the server
scheme – communication scheme (grpc, tcp, etc.)
- fetch_execute_task(project_name, fl_ctx: FLContext, timeout=None)[source]
Fetch a task from the server.
- Parameters:
project_name – FL study project name
fl_ctx – FLContext
timeout – timeout for the getTask message sent tp server
- Returns:
A CurrentTask message from server
- logout_client(fl_ctx: FLContext)[source]
Logout the client from the server.
- Parameters:
fl_ctx – FLContext
Returns: N/A
- pull_task(fl_ctx: FLContext, timeout=None)[source]
Fetch remote models and update the local client’s session.
- push_execute_result(project_name, shareable: Shareable, fl_ctx: FLContext, timeout=None)[source]
Submit execution results of a task to server.
- Parameters:
project_name – FL study project name
shareable – Shareable object
fl_ctx – FLContext
timeout – how long to wait for reply from server
- Returns:
A FederatedSummary message from the server.
- push_results(shareable: Shareable, fl_ctx: FLContext, timeout=None)[source]
Push the local model to multiple servers.