Skip to content

Commit 75d8d69

Browse files
authored
Merge pull request #39 from DataTools4Heart/cmd_line
node name variable added
2 parents dc7c974 + 71fa9ea commit 75d8d69

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

client_cmd.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
if __name__ == "__main__":
1919

2020
parser = argparse.ArgumentParser(description="Reads parameters from command line.")
21-
2221
parser.add_argument("--client_id", type=int, default="Client Id", help="Number of client")
2322
parser.add_argument("--dataset", type=str, default="dt4h_format", help="Dataloader to use")
2423
parser.add_argument("--metadata_file", type=str, default="metadata.json", help="Json file with metadata")
@@ -38,6 +37,7 @@
3837
parser.add_argument("--data_path", type=str, default=None, help="Data path")
3938
parser.add_argument("--production_mode", type=str, default="True", help="Production mode")
4039
parser.add_argument("--certs_path", type=str, default="./", help="Certificates path")
40+
parser.add_argument("--node_name", type=str, default="./", help="Node name for certificates")
4141

4242
parser.add_argument("--sandbox_path", type=str, default="./", help="Sandbox path to use")
4343
parser.add_argument("--experiment", type=json.loads, default={"name": "experiment_1", "log_path": "logs", "debug": "true"}, help="experiment logs")
@@ -86,19 +86,19 @@
8686
# Path(os.path.join(config["certs_path"],"rootCA_cert.pem")).read_bytes(),
8787
# Path(os.path.join(config["certs_path"],"rootCA_key.pem")).read_bytes() )
8888

89-
# root_cert = Path(os.path.join(config["certs_path"],"rootCA_cert.pem")).read_bytes()
90-
# client_cert = Path(os.path.join(config["certs_path"],"rootCA_cert.pem")).read_bytes()
91-
# client_key = Path(os.path.join(config["certs_path"],"rootCA_key.pem")).read_bytes()
89+
root_cert = Path(os.path.join(config["certs_path"],"rootCA_cert.pem")).read_bytes()
90+
client_cert = Path(os.path.join(config["certs_path"],config["node_name"]+"_client_cert.pem")).read_bytes()
91+
client_key = Path(os.path.join(config["certs_path"],config["node_name"]+"_client_key.pem")).read_bytes()
9292

93-
# ssl_credentials = grpc.ssl_channel_credentials(
94-
# root_cert, # Certificado raíz del servidor
95-
# client_key, # Clave privada del cliente
96-
# client_cert # Certificado del cliente
97-
# )
93+
ssl_credentials = grpc.ssl_channel_credentials(
94+
root_certificates=root_cert, # Certificado raíz del servidor
95+
private_key=client_key, # Clave privada del cliente
96+
certificate_chain=client_cert # Certificado del cliente
97+
)
9898

9999
central_ip = os.getenv("FLOWER_CENTRAL_SERVER_IP")
100100
central_port = os.getenv("FLOWER_CENTRAL_SERVER_PORT")
101-
# channel = grpc.secure_channel(f"{central_ip}:{central_port}", ssl_credentials)
101+
channel = grpc.secure_channel(f"{central_ip}:{central_port}", ssl_credentials)
102102

103103
else:
104104
data_path = config["data_path"]
@@ -141,18 +141,18 @@
141141
if isinstance(client, fl.client.NumPyClient):
142142
fl.client.start_numpy_client(
143143
server_address=f"{central_ip}:{central_port}",
144-
# credentials=ssl_credentials,
145-
root_certificates=root_certificate,
144+
#credentials=ssl_credentials,
145+
#root_certificates=root_certificate,
146146
client=client,
147-
# channel=channel,
147+
channel=channel,
148148
)
149149
else:
150150
fl.client.start_client(
151151
server_address=f"{central_ip}:{central_port}",
152152
# credentials=ssl_credentials,
153-
root_certificates=root_certificate,
153+
# root_certificates=root_certificate,
154154
client=client,
155-
# channel=channel,
155+
channel=channel,
156156
)
157157
break # Si todo salió bien, salimos del bucle
158158
except Exception as e:

0 commit comments

Comments
 (0)