nvflare.private.fed.server.admin module¶
- class ClientReply(client_token: str, req: Message, reply: Message)[source]¶
Bases:
object
Client reply.
- Parameters
client_token (str) – client token
req (Message) – request
reply (Message) – reply
- class FedAdminServer(fed_admin_interface, users, cmd_modules, file_upload_dir, file_download_dir, allowed_shell_cmds, host, port, ca_cert_file_name, server_cert_file_name, server_key_file_name, accepted_client_cns=None, app_validator=None, download_job_url=None)[source]¶
Bases:
AdminServer
The FedAdminServer is the framework for developing admin commands.
- Parameters
fed_admin_interface – the server’s federated admin interface
users – a dict of {username: pwd hash}
cmd_modules – a list of CommandModules
file_upload_dir – the directory for uploaded files
file_download_dir – the directory for files to be downloaded
allowed_shell_cmds – list of shell commands allowed. If not specified, all allowed.
host – the IP address of the admin server
port – port number of admin server
ca_cert_file_name – the root CA’s cert file name
server_cert_file_name – server’s cert, signed by the CA
server_key_file_name – server’s private key file
accepted_client_cns – list of accepted Common Names from client, if specified
app_validator – Application folder validator.
- accept_reply(client_token, reply: Message)[source]¶
Accept client reply.
- NOTE::
This method is to be called by the FL Engine after a client’s reply is received. Hence, it is called from the FL Engine’s message processing thread.
- Parameters
client_token – session token of the client
reply – the reply message
- client_heartbeat(token)[source]¶
Receive client heartbeat.
- Parameters
token – the session token of the client
- Returns
Client.
- get_outgoing_requests(client_token, max_reqs=0)[source]¶
Get outgoing request from a client.
- NOTE::
This method is called by FL Engine to get outgoing messages to the client, so it can send them to the client.
- Parameters
client_token – session token of the client
max_reqs – max number of requests. 0 means unlimited.
- Returns
outgoing requests. A list of Message.
- send_request_to_client(req: Message, client_token: str, timeout_secs=2.0) ClientReply [source]¶
- send_request_to_clients(req: ~nvflare.private.admin_defs.Message, client_tokens: [<class 'str'>], timeout_secs=2.0) [<class 'nvflare.private.fed.server.admin.ClientReply'>] [source]¶
- send_requests(requests: dict, timeout_secs=2.0) [<class 'nvflare.private.fed.server.admin.ClientReply'>] [source]¶
Send requests to clients.
NOTE:
This method is to be used by a Command Handler to send requests to Clients. Hence, it is run in the Command Handler's handling thread. This is a blocking call - returned only after all responses are received or timeout.
- Parameters
requests – A dict of requests: {client token: request or list of requests}
timeout_secs – how long to wait for reply before timeout
- Returns
A list of ClientReply
- check_client_replies(replies: List[ClientReply], client_sites: List[str], command: str)[source]¶
- new_message(conn: Connection, topic, body) Message [source]¶