Skip to content

Commit

Permalink
rename cert to root_cert
Browse files Browse the repository at this point in the history
  • Loading branch information
panh99 committed Nov 30, 2023
1 parent 1927495 commit c1390d5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion examples/mt-pytorch/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def weighted_average(metrics: List[Tuple[int, Metrics]]) -> Metrics:


# -------------------------------------------------------------------------- Driver SDK
driver = GrpcDriver(driver_service_address="0.0.0.0:9091", certificates=None)
driver = GrpcDriver(driver_service_address="0.0.0.0:9091", root_certificates=None)
# -------------------------------------------------------------------------- Driver SDK

anonymous_client_nodes = False
Expand Down
2 changes: 1 addition & 1 deletion examples/secaggplus-mt/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def weighted_average(metrics: List[Tuple[int, Metrics]]) -> Metrics:


# -------------------------------------------------------------------------- Driver SDK
driver = GrpcDriver(driver_service_address="0.0.0.0:9091", certificates=None)
driver = GrpcDriver(driver_service_address="0.0.0.0:9091", root_certificates=None)
# -------------------------------------------------------------------------- Driver SDK

anonymous_client_nodes = False
Expand Down
4 changes: 3 additions & 1 deletion src/py/flwr/driver/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ def start_driver( # pylint: disable=too-many-arguments, too-many-locals
# Create the Driver
if isinstance(root_certificates, str):
root_certificates = Path(root_certificates).read_bytes()
driver = GrpcDriver(driver_service_address=address, certificates=root_certificates)
driver = GrpcDriver(
driver_service_address=address, root_certificates=root_certificates
)
driver.connect()
lock = threading.Lock()

Expand Down
19 changes: 8 additions & 11 deletions src/py/flwr/driver/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,10 @@ class Driver:
driver_service_address : Optional[str]
The IPv4 or IPv6 address of the Driver API server.
Defaults to `"[::]:9091"`.
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[bytes] (default: None)
The PEM-encoded root certificates as a byte string. If provided,
a secure connection using the certificates will be established to
an SSL-enabled Flower server.
invoker : Optional[RetryInvoker] (default: None)
A `RetryInvoker` object to control the retry behavior on Driver API failures.
If set to None, a default instance is created with an exponential backoff
Expand All @@ -61,11 +57,11 @@ class Driver:
def __init__(
self,
driver_service_address: str = DEFAULT_SERVER_ADDRESS_DRIVER,
certificates: Optional[bytes] = None,
root_certificates: Optional[bytes] = None,
invoker: Optional[RetryInvoker] = None,
) -> None:
self.addr = driver_service_address
self.certificates = certificates
self.root_certificates = root_certificates
self.grpc_driver: Optional[GrpcDriver] = None
self.workload_id: Optional[int] = None
self.node = Node(node_id=0, anonymous=True)
Expand All @@ -88,7 +84,8 @@ def _get_grpc_driver_and_workload_id(self) -> Tuple[GrpcDriver, int]:
if self.grpc_driver is None or self.workload_id is None:
# Connect and create workload
self.grpc_driver = GrpcDriver(
driver_service_address=self.addr, certificates=self.certificates
driver_service_address=self.addr,
root_certificates=self.root_certificates,
)
self.grpc_driver.connect()
res = self.grpc_driver.create_workload(CreateWorkloadRequest())
Expand Down
8 changes: 4 additions & 4 deletions src/py/flwr/driver/grpc_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ class GrpcDriver:
def __init__(
self,
driver_service_address: str = DEFAULT_SERVER_ADDRESS_DRIVER,
certificates: Optional[bytes] = None,
root_certificates: Optional[bytes] = None,
) -> None:
self.driver_service_address = driver_service_address
self.certificates = certificates
self.root_certificates = root_certificates
self.channel: Optional[grpc.Channel] = None
self.stub: Optional[DriverStub] = None

Expand All @@ -66,8 +66,8 @@ def connect(self) -> None:
return
self.channel = create_channel(
server_address=self.driver_service_address,
insecure=(self.certificates is None),
root_certificates=self.certificates,
insecure=(self.root_certificates is None),
root_certificates=self.root_certificates,
)
self.stub = DriverStub(self.channel)
log(INFO, "[Driver] Connected to %s", self.driver_service_address)
Expand Down

0 comments on commit c1390d5

Please sign in to comment.