Skip to content

Commit

Permalink
--proxy flag added
Browse files Browse the repository at this point in the history
  • Loading branch information
sowmyasris committed Aug 12, 2024
1 parent ad005ee commit f75159c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
6 changes: 5 additions & 1 deletion fedn/cli/run_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ def build_cmd(ctx, path):
@click.option("-s", "--secure", required=False, default=False)
@click.option("-pc", "--preshared-cert", required=False, default=False)
@click.option("-v", "--verify", is_flag=True, help="Verify SSL/TLS for REST service")
@click.option("-c", "--combiner", required=False,type=str, default="combiner",help="name of the preferred combiner")
@click.option("-g", "--grpc-proxy", required=False, type=str,default=None,help="url to the combiner")
@click.option("-c", "--combiner", required=False,type=str, default="combiner",help="url to the combiner or name of the preferred combiner")
@click.option("-va", "--validator", required=False, default=True)
@click.option("-tr", "--trainer", required=False, default=True)
@click.option("-in", "--init", required=False, default=None, help="Set to a filename to (re)init client from file state.")
Expand All @@ -204,6 +205,7 @@ def client_cmd(
secure,
preshared_cert,
verify,
grpc_proxy,
combiner,
validator,
trainer,
Expand All @@ -224,6 +226,7 @@ def client_cmd(
:param secure:
:param preshared_cert:
:param verify_cert:
:param grpc_proxy:
:param combiner:
:param init:
:param logfile:
Expand All @@ -245,6 +248,7 @@ def client_cmd(
"secure": secure,
"preshared_cert": preshared_cert,
"verify": verify,
"grpc_proxy":grpc_proxy,
"preferred_combiner": combiner,
"validator": validator,
"trainer": trainer,
Expand Down
20 changes: 13 additions & 7 deletions fedn/network/clients/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def __init__(self, config):
set_log_stream(config.get("logfile", None))

self.id = config["client_id"] or str(uuid.uuid4())

self.connector = ConnectorClient(
host=config["discover_host"],
port=config["discover_port"],
Expand All @@ -73,10 +72,11 @@ def __init__(self, config):
remote_package=config["remote_compute_context"],
force_ssl=config["force_ssl"],
verify=config["verify"],
grpc_proxy=config["grpc_proxy"],
combiner=config["preferred_combiner"],
id=self.id,
)

print(self.connector)
# Validate client name
match = re.search(VALID_NAME_REGEX, config["name"])
if not match:
Expand Down Expand Up @@ -181,14 +181,20 @@ def connect(self, combiner_config):
:param combiner_config: connection information for the combiner.
:type combiner_config: dict
"""
print("cobinerrrr config",combiner_config)
if self._connected:
logger.info("Client is already attached. ")
return

# TODO use the combiner_config['certificate'] for setting up secure comms'
host = combiner_config["host"]
# Add host to gRPC metadata
self._add_grpc_metadata("grpc-server", host)
if combiner_config["grpc_proxy"] is not None:
# TODO use the combiner_config['certificate'] for setting up secure comms'
host = combiner_config["grpc_proxy"]
# Add host to gRPC metadata
self._add_grpc_metadata("grpc-server", combiner_config["combiner"])
else:
# TODO use the combiner_config['certificate'] for setting up secure comms'
host = combiner_config["combiner"]
# Add host to gRPC metadata
self._add_grpc_metadata("grpc-server", combiner_config["combiner"])
logger.debug("Client using metadata: {}.".format(self.metadata))
port = combiner_config["port"]
secure = False
Expand Down
4 changes: 2 additions & 2 deletions fedn/network/clients/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ class ConnectorClient:
:param id: id of client
"""

def __init__(self, host, port, token, name, remote_package, force_ssl=False, verify=False, combiner=None, id=None):
def __init__(self, host, port, token, name, remote_package, force_ssl=False, verify=False, grpc_proxy=None,combiner=None, id=None):
self.host = host
self.port = port
self.token = token
self.name = name
self.verify = verify
self.grpc_proxy=grpc_proxy
self.preferred_combiner = combiner
self.id = id
self.package = "remote" if remote_package else "local"

# for https we assume a an ingress handles permanent redirect (308)
if force_ssl:
self.prefix = "https://"
Expand Down

0 comments on commit f75159c

Please sign in to comment.