prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Improve docstring for `start_keras_client`
  
  
  </issue>
  <code>
  [start of src/py/flwr/common/__init__.py]
  1 # Copyright 2020 Adap GmbH. All Rights Reserved.
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #     http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 # ==============================================================================
  15 """Flower utilities shared between server and client."""
  16 
  17 
  18 from .parameter import bytes_to_ndarray as bytes_to_ndarray
  19 from .parameter import ndarray_to_bytes as ndarray_to_bytes
  20 from .parameter import parameters_to_weights as parameters_to_weights
  21 from .parameter import weights_to_parameters as weights_to_parameters
  22 from .typing import Disconnect as Disconnect
  23 from .typing import EvaluateIns as EvaluateIns
  24 from .typing import EvaluateRes as EvaluateRes
  25 from .typing import FitIns as FitIns
  26 from .typing import FitRes as FitRes
  27 from .typing import Parameters as Parameters
  28 from .typing import ParametersRes as ParametersRes
  29 from .typing import Reconnect as Reconnect
  30 from .typing import Weights as Weights
  31 
  32 GRPC_MAX_MESSAGE_LENGTH: int = 536870912  # == 512 * 1024 * 1024
  33 
  34 __all__ = [
  35     "bytes_to_ndarray",
  36     "Disconnect",
  37     "EvaluateIns",
  38     "EvaluateRes",
  39     "FitIns",
  40     "FitRes",
  41     "GRPC_MAX_MESSAGE_LENGTH",
  42     "ndarray_to_bytes",
  43     "Parameters",
  44     "parameters_to_weights",
  45     "ParametersRes",
  46     "Reconnect",
  47     "Weights",
  48     "weights_to_parameters",
  49 ]
  50
  [end of src/py/flwr/common/__init__.py]
  [start of src/py/flwr/client/app.py]
  1 # Copyright 2020 Adap GmbH. All Rights Reserved.
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #     http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 # ==============================================================================
  15 """Flower client app."""
  16 
  17 
  18 import time
  19 from logging import INFO
  20 
  21 from flwr.common import GRPC_MAX_MESSAGE_LENGTH
  22 from flwr.common.logger import log
  23 
  24 from .client import Client
  25 from .grpc_client.connection import insecure_grpc_connection
  26 from .grpc_client.message_handler import handle
  27 from .keras_client import KerasClient, KerasClientWrapper
  28 
  29 
  30 def start_client(
  31     server_address: str,
  32     client: Client,
  33     grpc_max_message_length: int = GRPC_MAX_MESSAGE_LENGTH,
  34 ) -> None:
  35     """Start a Flower Client which connects to a gRPC server."""
  36     while True:
  37         sleep_duration: int = 0
  38         with insecure_grpc_connection(
  39             server_address, max_message_length=grpc_max_message_length
  40         ) as conn:
  41             receive, send = conn
  42             log(INFO, "Opened (insecure) gRPC connection")
  43 
  44             while True:
  45                 server_message = receive()
  46                 client_message, sleep_duration, keep_going = handle(
  47                     client, server_message
  48                 )
  49                 send(client_message)
  50                 if not keep_going:
  51                     break
  52         if sleep_duration == 0:
  53             log(INFO, "Disconnect and shut down")
  54             break
  55         # Sleep and reconnect afterwards
  56         log(
  57             INFO,
  58             "Disconnect, then re-establish connection after %s second(s)",
  59             sleep_duration,
  60         )
  61         time.sleep(sleep_duration)
  62 
  63 
  64 def start_keras_client(server_address: str, client: KerasClient) -> None:
  65     """Start a Flower KerasClient which connects to a gRPC server."""
  66 
  67     # Wrap the Keras client
  68     flower_client = KerasClientWrapper(client)
  69 
  70     # Start
  71     start_client(server_address, flower_client)
  72
  [end of src/py/flwr/client/app.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/src/py/flwr/client/app.py b/src/py/flwr/client/app.py
  --- a/src/py/flwr/client/app.py
  +++ b/src/py/flwr/client/app.py
  @@ -32,7 +32,25 @@
       client: Client,
       grpc_max_message_length: int = GRPC_MAX_MESSAGE_LENGTH,
   ) -> None:
  -    """Start a Flower Client which connects to a gRPC server."""
  +    """Start a Flower Client which connects to a gRPC server.
  +
  +    Arguments:
  +        server_address: str. The 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.Client. An implementation of the abstract base
  +            class `flwr.client.Client`.
  +        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 started with the same
  +            value (see `flwr.server.start_server`), otherwise it will not know
  +            about the increased limit and block larger messages.
  +
  +    Returns:
  +        None.
  +    """
       while True:
           sleep_duration: int = 0
           with insecure_grpc_connection(
  @@ -61,11 +79,37 @@
           time.sleep(sleep_duration)
   
   
  -def start_keras_client(server_address: str, client: KerasClient) -> None:
  -    """Start a Flower KerasClient which connects to a gRPC server."""
  +def start_keras_client(
  +    server_address: str,
  +    client: KerasClient,
  +    grpc_max_message_length: int = GRPC_MAX_MESSAGE_LENGTH,
  +) -> None:
  +    """Start a Flower KerasClient which connects to a gRPC server.
  +
  +    Arguments:
  +        server_address: str. The 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.KerasClient. An implementation of the abstract base
  +            class `flwr.client.KerasClient`.
  +        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 started with the same
  +            value (see `flwr.server.start_server`), otherwise it will not know
  +            about the increased limit and block larger messages.
  +
  +    Returns:
  +        None.
  +    """
   
       # Wrap the Keras client
       flower_client = KerasClientWrapper(client)
   
       # Start
  -    start_client(server_address, flower_client)
  +    start_client(
  +        server_address=server_address,
  +        client=flower_client,
  +        grpc_max_message_length=grpc_max_message_length,
  +    )
  diff --git a/src/py/flwr/common/__init__.py b/src/py/flwr/common/__init__.py
  --- a/src/py/flwr/common/__init__.py
  +++ b/src/py/flwr/common/__init__.py
  @@ -29,7 +29,7 @@
   from .typing import Reconnect as Reconnect
   from .typing import Weights as Weights
   
  -GRPC_MAX_MESSAGE_LENGTH: int = 536870912  # == 512 * 1024 * 1024
  +GRPC_MAX_MESSAGE_LENGTH: int = 536_870_912  # == 512 * 1024 * 1024
   
   __all__ = [
       "bytes_to_ndarray",
  
verification_info: {"golden_diff": "diff --git a/src/py/flwr/client/app.py b/src/py/flwr/client/app.py\n--- a/src/py/flwr/client/app.py\n+++ b/src/py/flwr/client/app.py\n@@ -32,7 +32,25 @@\n     client: Client,\n     grpc_max_message_length: int = GRPC_MAX_MESSAGE_LENGTH,\n ) -> None:\n-    \"\"\"Start a Flower Client which connects to a gRPC server.\"\"\"\n+    \"\"\"Start a Flower Client which connects to a gRPC server.\n+\n+    Arguments:\n+        server_address: str. The IPv6 address of the server. If the Flower\n+            server runs on the same machine on port 8080, then `server_address`\n+            would be `\"[::]:8080\"`.\n+        client: flwr.client.Client. An implementation of the abstract base\n+            class `flwr.client.Client`.\n+        grpc_max_message_length: int (default: 536_870_912, this equals 512MB).\n+            The maximum length of gRPC messages that can be exchanged with the\n+            Flower server. The default should be sufficient for most models.\n+            Users who train very large models might need to increase this\n+            value. Note that the Flower server needs to started with the same\n+            value (see `flwr.server.start_server`), otherwise it will not know\n+            about the increased limit and block larger messages.\n+\n+    Returns:\n+        None.\n+    \"\"\"\n     while True:\n         sleep_duration: int = 0\n         with insecure_grpc_connection(\n@@ -61,11 +79,37 @@\n         time.sleep(sleep_duration)\n \n \n-def start_keras_client(server_address: str, client: KerasClient) -> None:\n-    \"\"\"Start a Flower KerasClient which connects to a gRPC server.\"\"\"\n+def start_keras_client(\n+    server_address: str,\n+    client: KerasClient,\n+    grpc_max_message_length: int = GRPC_MAX_MESSAGE_LENGTH,\n+) -> None:\n+    \"\"\"Start a Flower KerasClient which connects to a gRPC server.\n+\n+    Arguments:\n+        server_address: str. The IPv6 address of the server. If the Flower\n+            server runs on the same machine on port 8080, then `server_address`\n+            would be `\"[::]:8080\"`.\n+        client: flwr.client.KerasClient. An implementation of the abstract base\n+            class `flwr.client.KerasClient`.\n+        grpc_max_message_length: int (default: 536_870_912, this equals 512MB).\n+            The maximum length of gRPC messages that can be exchanged with the\n+            Flower server. The default should be sufficient for most models.\n+            Users who train very large models might need to increase this\n+            value. Note that the Flower server needs to started with the same\n+            value (see `flwr.server.start_server`), otherwise it will not know\n+            about the increased limit and block larger messages.\n+\n+    Returns:\n+        None.\n+    \"\"\"\n \n     # Wrap the Keras client\n     flower_client = KerasClientWrapper(client)\n \n     # Start\n-    start_client(server_address, flower_client)\n+    start_client(\n+        server_address=server_address,\n+        client=flower_client,\n+        grpc_max_message_length=grpc_max_message_length,\n+    )\ndiff --git a/src/py/flwr/common/__init__.py b/src/py/flwr/common/__init__.py\n--- a/src/py/flwr/common/__init__.py\n+++ b/src/py/flwr/common/__init__.py\n@@ -29,7 +29,7 @@\n from .typing import Reconnect as Reconnect\n from .typing import Weights as Weights\n \n-GRPC_MAX_MESSAGE_LENGTH: int = 536870912  # == 512 * 1024 * 1024\n+GRPC_MAX_MESSAGE_LENGTH: int = 536_870_912  # == 512 * 1024 * 1024\n \n __all__ = [\n     \"bytes_to_ndarray\",\n", "issue": "Improve docstring for `start_keras_client`\n\n", "before_files": [{"content": "# Copyright 2020 Adap GmbH. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n# ==============================================================================\n\"\"\"Flower utilities shared between server and client.\"\"\"\n\n\nfrom .parameter import bytes_to_ndarray as bytes_to_ndarray\nfrom .parameter import ndarray_to_bytes as ndarray_to_bytes\nfrom .parameter import parameters_to_weights as parameters_to_weights\nfrom .parameter import weights_to_parameters as weights_to_parameters\nfrom .typing import Disconnect as Disconnect\nfrom .typing import EvaluateIns as EvaluateIns\nfrom .typing import EvaluateRes as EvaluateRes\nfrom .typing import FitIns as FitIns\nfrom .typing import FitRes as FitRes\nfrom .typing import Parameters as Parameters\nfrom .typing import ParametersRes as ParametersRes\nfrom .typing import Reconnect as Reconnect\nfrom .typing import Weights as Weights\n\nGRPC_MAX_MESSAGE_LENGTH: int = 536870912  # == 512 * 1024 * 1024\n\n__all__ = [\n    \"bytes_to_ndarray\",\n    \"Disconnect\",\n    \"EvaluateIns\",\n    \"EvaluateRes\",\n    \"FitIns\",\n    \"FitRes\",\n    \"GRPC_MAX_MESSAGE_LENGTH\",\n    \"ndarray_to_bytes\",\n    \"Parameters\",\n    \"parameters_to_weights\",\n    \"ParametersRes\",\n    \"Reconnect\",\n    \"Weights\",\n    \"weights_to_parameters\",\n]\n", "path": "src/py/flwr/common/__init__.py"}, {"content": "# Copyright 2020 Adap GmbH. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n# ==============================================================================\n\"\"\"Flower client app.\"\"\"\n\n\nimport time\nfrom logging import INFO\n\nfrom flwr.common import GRPC_MAX_MESSAGE_LENGTH\nfrom flwr.common.logger import log\n\nfrom .client import Client\nfrom .grpc_client.connection import insecure_grpc_connection\nfrom .grpc_client.message_handler import handle\nfrom .keras_client import KerasClient, KerasClientWrapper\n\n\ndef start_client(\n    server_address: str,\n    client: Client,\n    grpc_max_message_length: int = GRPC_MAX_MESSAGE_LENGTH,\n) -> None:\n    \"\"\"Start a Flower Client which connects to a gRPC server.\"\"\"\n    while True:\n        sleep_duration: int = 0\n        with insecure_grpc_connection(\n            server_address, max_message_length=grpc_max_message_length\n        ) as conn:\n            receive, send = conn\n            log(INFO, \"Opened (insecure) gRPC connection\")\n\n            while True:\n                server_message = receive()\n                client_message, sleep_duration, keep_going = handle(\n                    client, server_message\n                )\n                send(client_message)\n                if not keep_going:\n                    break\n        if sleep_duration == 0:\n            log(INFO, \"Disconnect and shut down\")\n            break\n        # Sleep and reconnect afterwards\n        log(\n            INFO,\n            \"Disconnect, then re-establish connection after %s second(s)\",\n            sleep_duration,\n        )\n        time.sleep(sleep_duration)\n\n\ndef start_keras_client(server_address: str, client: KerasClient) -> None:\n    \"\"\"Start a Flower KerasClient which connects to a gRPC server.\"\"\"\n\n    # Wrap the Keras client\n    flower_client = KerasClientWrapper(client)\n\n    # Start\n    start_client(server_address, flower_client)\n", "path": "src/py/flwr/client/app.py"}]}