Skip to content

Commit

Permalink
PPML FL change clientID from String to Int (intel-analytics#5647)
Browse files Browse the repository at this point in the history
  • Loading branch information
Litchilitchy authored and ForJadeForest committed Sep 20, 2022
1 parent adc8bbd commit ef66d92
Show file tree
Hide file tree
Showing 51 changed files with 684 additions and 1,855 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def FillNaWithMean(data, columnList):
@click.command()
@click.option('--load_model', default=False)
def run_client(load_model):
client_id = '1'
client_id = 1
init_fl_context(client_id)

df_train = pd.read_csv('./python/ppml/example/fgboost_regression/data/house-prices-train-1.csv')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def FillNaWithMean(data, columnList):
@click.command()
@click.option('--load_model', default=False)
def run_client(load_model):
client_id = '2'
client_id = 2
init_fl_context(client_id)

df_train = pd.read_csv('./python/ppml/example/fgboost_regression/data/house-prices-train-2.csv')
Expand Down
2 changes: 1 addition & 1 deletion python/ppml/example/pytorch_nn_lr/pytorch_nn_lr_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def forward(self, x: List[Tensor]):
@click.option('--load_model', default=False)
@click.option('--data_path', default="./data/diabetes-vfl-1.csv")
def run_client(load_model, data_path):
init_fl_context('1')
init_fl_context(1)
df_train = pd.read_csv(data_path)

df_train['ID'] = df_train['ID'].astype(str)
Expand Down
2 changes: 1 addition & 1 deletion python/ppml/example/pytorch_nn_lr/pytorch_nn_lr_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def forward(self, x):
@click.option('--load_model', default=False)
@click.option('--data_path', default="./data/diabetes-vfl-2.csv")
def run_client(load_model, data_path):
init_fl_context('2')
init_fl_context(2)
df_train = pd.read_csv(data_path)
df_train['ID'] = df_train['ID'].astype(str)
psi = PSI()
Expand Down
2 changes: 1 addition & 1 deletion python/ppml/src/bigdl/ppml/fl/nn/fl_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from ..nn.fl_client import FLClient

def init_fl_context(client_id, target="localhost:8980"):
def init_fl_context(client_id: int, target="localhost:8980"):
FLClient.load_config()
FLClient.set_client_id(client_id)
# target can be set in config file, and also could be overwritten here
Expand Down
46 changes: 43 additions & 3 deletions python/ppml/src/bigdl/ppml/fl/nn/generated/fgboost_service_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import fgboost_service_pb2 as fgboost__service__pb2


class FGBoostServiceStub(object):
"""Missing associated documentation comment in .proto file."""

Expand Down Expand Up @@ -48,6 +49,16 @@ def __init__(self, channel):
request_serializer=fgboost__service__pb2.PredictRequest.SerializeToString,
response_deserializer=fgboost__service__pb2.PredictResponse.FromString,
)
self.saveServerModel = channel.unary_unary(
'/fgboost.FGBoostService/saveServerModel',
request_serializer=fgboost__service__pb2.SaveModelRequest.SerializeToString,
response_deserializer=fgboost__service__pb2.SaveModelResponse.FromString,
)
self.loadServerModel = channel.unary_unary(
'/fgboost.FGBoostService/loadServerModel',
request_serializer=fgboost__service__pb2.LoadModelRequest.SerializeToString,
response_deserializer=fgboost__service__pb2.LoadModelResponse.FromString,
)


class FGBoostServiceServicer(object):
Expand Down Expand Up @@ -95,6 +106,18 @@ def predict(self, request, context):
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def saveServerModel(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def loadServerModel(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')


def add_FGBoostServiceServicer_to_server(servicer, server):
rpc_method_handlers = {
Expand Down Expand Up @@ -133,6 +156,16 @@ def add_FGBoostServiceServicer_to_server(servicer, server):
request_deserializer=fgboost__service__pb2.PredictRequest.FromString,
response_serializer=fgboost__service__pb2.PredictResponse.SerializeToString,
),
'saveServerModel': grpc.unary_unary_rpc_method_handler(
servicer.saveServerModel,
request_deserializer=fgboost__service__pb2.SaveModelRequest.FromString,
response_serializer=fgboost__service__pb2.SaveModelResponse.SerializeToString,
),
'loadServerModel': grpc.unary_unary_rpc_method_handler(
servicer.loadServerModel,
request_deserializer=fgboost__service__pb2.LoadModelRequest.FromString,
response_serializer=fgboost__service__pb2.LoadModelResponse.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
'fgboost.FGBoostService', rpc_method_handlers)
Expand Down Expand Up @@ -261,3 +294,37 @@ def predict(request,
fgboost__service__pb2.PredictResponse.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def saveServerModel(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/fgboost.FGBoostService/saveServerModel',
fgboost__service__pb2.SaveModelRequest.SerializeToString,
fgboost__service__pb2.SaveModelResponse.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def loadServerModel(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/fgboost.FGBoostService/loadServerModel',
fgboost__service__pb2.LoadModelRequest.SerializeToString,
fgboost__service__pb2.LoadModelResponse.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
Loading

0 comments on commit ef66d92

Please sign in to comment.