Allow insecure gRPC connections for federated learning (#8181)

* Allow insecure gRPC connections for federated learning

* format
This commit is contained in:
Rong Ou
2022-08-18 21:16:14 -07:00
committed by GitHub
parent 53d2a733b0
commit ad3bc0edee
7 changed files with 75 additions and 37 deletions

View File

@@ -6,9 +6,9 @@ from .core import _LIB, XGBoostError, _check_call, build_info, c_str
def run_federated_server(
port: int,
world_size: int,
server_key_path: str,
server_cert_path: str,
client_cert_path: str,
server_key_path: str = "",
server_cert_path: str = "",
client_cert_path: str = "",
) -> None:
"""Run the Federated Learning server.
@@ -19,22 +19,25 @@ def run_federated_server(
world_size: int
The number of federated workers.
server_key_path: str
Path to the server private key file.
Path to the server private key file. SSL is turned off if empty.
server_cert_path: str
Path to the server certificate file.
Path to the server certificate file. SSL is turned off if empty.
client_cert_path: str
Path to the client certificate file.
Path to the client certificate file. SSL is turned off if empty.
"""
if build_info()["USE_FEDERATED"]:
_check_call(
_LIB.XGBRunFederatedServer(
port,
world_size,
c_str(server_key_path),
c_str(server_cert_path),
c_str(client_cert_path),
if not server_key_path or not server_cert_path or not client_cert_path:
_check_call(_LIB.XGBRunInsecureFederatedServer(port, world_size))
else:
_check_call(
_LIB.XGBRunFederatedServer(
port,
world_size,
c_str(server_key_path),
c_str(server_cert_path),
c_str(client_cert_path),
)
)
)
else:
raise XGBoostError(
"XGBoost needs to be built with the federated learning plugin "