start_numpy_client#

start_numpy_client(*, server_address: str, client: NumPyClient, grpc_max_message_length: int = 536870912, root_certificates: bytes | None = None, insecure: bool | None = None, transport: str | None = None) None[source]#

Start a Flower NumPyClient which connects to a gRPC server.

Warning

This function is deprecated since 1.7.0. Use flwr.client.start_client instead and first convert your NumPyClient to type flwr.client.Client by executing its to_client() method.

Parameters:
  • server_address (str) – The IPv4 or IPv6 address of the server. If the Flower server runs on the same machine on port 8080, then server_address would be “[::]:8080”.

  • client (flwr.client.NumPyClient) – An implementation of the abstract base class flwr.client.NumPyClient.

  • grpc_max_message_length (int (default: 536_870_912, this equals 512MB)) – The maximum length of gRPC messages that can be exchanged with the Flower server. The default should be sufficient for most models. Users who train very large models might need to increase this value. Note that the Flower server needs to be started with the same value (see flwr.server.start_server), otherwise it will not know about the increased limit and block larger messages.

  • root_certificates (bytes (default: None)) – The PEM-encoded root certificates as a byte string or a path string. If provided, a secure connection using the certificates will be established to an SSL-enabled Flower server.

  • insecure (Optional[bool] (default: None)) – Starts an insecure gRPC connection when True. Enables HTTPS connection when False, using system certificates if root_certificates is None.

  • transport (Optional[str] (default: None)) – Configure the transport layer. Allowed values: - ‘grpc-bidi’: gRPC, bidirectional streaming - ‘grpc-rere’: gRPC, request-response (experimental) - ‘rest’: HTTP (experimental)

Examples

Starting a gRPC client with an insecure server connection:

>>> start_numpy_client(
>>>     server_address=localhost:8080,
>>>     client=FlowerClient(),
>>> )

Starting an SSL-enabled gRPC client using system certificates:

>>> start_numpy_client(
>>>     server_address=localhost:8080,
>>>     client=FlowerClient(),
>>>     insecure=False,
>>> )

Starting an SSL-enabled gRPC client using provided certificates:

>>> from pathlib import Path
>>>
>>> start_numpy_client(
>>>     server_address=localhost:8080,
>>>     client=FlowerClient(),
>>>     root_certificates=Path("/crts/root.pem").read_bytes(),
>>> )