Skip to content

Commit

Permalink
Fix incorrect docstring for 'certificates' in 'start_driver' API (#2607)
Browse files Browse the repository at this point in the history
  • Loading branch information
panh99 authored Nov 15, 2023
1 parent eead07f commit 760a456
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/py/flwr/driver/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
import threading
import time
from logging import INFO
from typing import Dict, Optional
from pathlib import Path
from typing import Dict, Optional, Union

from flwr.common import EventType, event
from flwr.common.address import parse_address
Expand Down Expand Up @@ -51,7 +52,7 @@ def start_driver( # pylint: disable=too-many-arguments, too-many-locals
config: Optional[ServerConfig] = None,
strategy: Optional[Strategy] = None,
client_manager: Optional[ClientManager] = None,
certificates: Optional[bytes] = None,
root_certificates: Optional[Union[bytes, str]] = None,
) -> History:
"""Start a Flower Driver API server.
Expand All @@ -76,14 +77,10 @@ def start_driver( # pylint: disable=too-many-arguments, too-many-locals
`flwr.driver.driver_client_manager.DriverClientManager`. If no
implementation is provided, then `start_driver` will use
`flwr.driver.driver_client_manager.DriverClientManager`.
certificates : bytes (default: None)
Tuple containing root certificate, server certificate, and private key
to start a secure SSL-enabled server. The tuple is expected to have
three bytes elements in the following order:
* CA certificate.
* server certificate.
* server private key.
root_certificates : Optional[Union[bytes, str]] (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.
Returns
-------
Expand All @@ -99,7 +96,7 @@ def start_driver( # pylint: disable=too-many-arguments, too-many-locals
Starting a driver that connects to an SSL-enabled server:
>>> start_driver(
>>> certificates=Path("/crts/root.pem").read_bytes()
>>> root_certificates=Path("/crts/root.pem").read_bytes()
>>> )
"""
event(EventType.START_DRIVER_ENTER)
Expand All @@ -112,7 +109,9 @@ def start_driver( # pylint: disable=too-many-arguments, too-many-locals
address = f"[{host}]:{port}" if is_v6 else f"{host}:{port}"

# Create the Driver
driver = GrpcDriver(driver_service_address=address, certificates=certificates)
if isinstance(root_certificates, str):
root_certificates = Path(root_certificates).read_bytes()
driver = GrpcDriver(driver_service_address=address, certificates=root_certificates)
driver.connect()
lock = threading.Lock()

Expand Down

0 comments on commit 760a456

Please sign in to comment.