Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add driver_service_address and certificates args to Driver class constructor #2535

Merged
merged 8 commits into from
Oct 26, 2023
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/py/flwr/driver/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from typing import Iterable, List, Optional, Tuple

from flwr.driver.grpc_driver import GrpcDriver
from flwr.driver.grpc_driver import DEFAULT_SERVER_ADDRESS_DRIVER, GrpcDriver
from flwr.proto.driver_pb2 import (
CreateWorkloadRequest,
GetNodesRequest,
Expand All @@ -31,7 +31,13 @@
class Driver:
"""`Driver` class provides an interface to the Driver API."""

def __init__(self) -> None:
def __init__(
self,
driver_service_address: str = DEFAULT_SERVER_ADDRESS_DRIVER,
certificates: Optional[bytes] = None,
danieljanes marked this conversation as resolved.
Show resolved Hide resolved
) -> None:
self.addr = driver_service_address
self.certificates = certificates
self.grpc_driver: Optional[GrpcDriver] = None
self.workload_id: Optional[int] = None
self.node = Node(node_id=0, anonymous=True)
Expand All @@ -40,7 +46,9 @@ def _get_grpc_driver_and_workload_id(self) -> Tuple[GrpcDriver, int]:
# Check if the GrpcDriver is initialized
if self.grpc_driver is None or self.workload_id is None:
# Connect and create workload
self.grpc_driver = GrpcDriver()
self.grpc_driver = GrpcDriver(
driver_service_address=self.addr, certificates=self.certificates
)
self.grpc_driver.connect()
res = self.grpc_driver.create_workload(CreateWorkloadRequest())
self.workload_id = res.workload_id
Expand Down