Skip to content

Commit

Permalink
Enable FL Server in SGX
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanyu-Jin committed Aug 15, 2022
1 parent 82192a7 commit ee493aa
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 35 deletions.
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 @@ -52,7 +52,7 @@ def forward(self, x: List[Tensor]):
# fl_server = FLServer(2)
# fl_server.build()
# fl_server.start()
df_train = pd.read_csv('./python/ppml/example/pytorch_nn_lr/data/diabetes-vfl-1.csv')
df_train = pd.read_csv('.data/diabetes-vfl-1.csv')

# this should wait for the merge of 2 FLServer (Py4J Java gRPC and Python gRPC)
# 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 @@ -35,7 +35,7 @@ def forward(self, x):


if __name__ == '__main__':
df_train = pd.read_csv('./python/ppml/example/pytorch_nn_lr/data/diabetes-vfl-2.csv')
df_train = pd.read_csv('.data/diabetes-vfl-2.csv')

# this should wait for the merge of 2 FLServer (Py4J Java gRPC and Python gRPC)
# df_train['ID'] = df_train['ID'].astype(str)
Expand Down
2 changes: 1 addition & 1 deletion python/ppml/scripts/setup-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ PYTHON_ZIP=$(find lib -name *-python-api.zip)
JAR=$(find lib -name *-jar-with-dependencies.jar)
export PYTHONPATH=$PYTHONPATH:$(pwd)/$PYTHON_ZIP
export PYTHONPATH=$PYTHONPATH:$(pwd)/$PYTHON_ZIP/bigdl/ppml/fl/nn/generated
export BIGDL_CLASSPATH=$JAR
export BIGDL_CLASSPATH=$JAR
43 changes: 41 additions & 2 deletions python/ppml/scripts/start-fl-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,49 @@
# limitations under the License.
#

import sys
import os
import fnmatch
import getopt

for files in os.listdir('/ppml/trusted-big-data-ml/work/bigdl-2.1.0-SNAPSHOT/python/'):
if fnmatch.fnmatch(files, 'bigdl-ppml-*-python-api.zip'):
sys.path.append('/ppml/trusted-big-data-ml/work/bigdl-2.1.0-SNAPSHOT/python/' + files)
sys.path.append('/ppml/trusted-big-data-ml/work/bigdl-2.1.0-SNAPSHOT/python/' + files + '/bigdl/ppml/fl/nn/generated')

if '/usr/lib/python3.6' in sys.path:
sys.path.remove('/usr/lib/python3.6')
if '/usr/lib/python3.6/lib-dynload' in sys.path:
sys.path.remove('/usr/lib/python3.6/lib-dynload')
if '/usr/local/lib/python3.6/dist-packages' in sys.path:
sys.path.remove('/usr/local/lib/python3.6/dist-packages')
if '/usr/lib/python3/dist-packages' in sys.path:
sys.path.remove('/usr/lib/python3/dist-packages')

from bigdl.ppml.fl.nn.fl_server import FLServer

if __name__ == '__main__':
fl_server = FLServer()

client_num = 2
port = 8980

try:
opts, args = getopt.getopt(sys.argv[1:], "hc:p:", ["client-num=", "port="])
except getopt.GetoptError:
print("start_fl_server.py -c <client-num> -p <port>")
sys.exit(2)

for opt, arg in opts:
if opt == '-h':
print("start_fl_server.py -c <client-num> -p <port>")
elif opt in ("-c", "--client-num"):
client_num = arg
elif opt in ("-p", "--port"):
port = arg

fl_server = FLServer(client_num)
fl_server.set_port(port)
fl_server.build()
fl_server.start()
fl_server.wait_for_termination()

fl_server.wait_for_termination()
4 changes: 1 addition & 3 deletions python/ppml/src/bigdl/ppml/fl/nn/fl_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ def load_config(self):
( (private_key, certificate_chain), ) )
if 'serverPort' in conf:
self.port = conf['serverPort']
if 'clientNum' in conf:
self.client_num = conf['clientNum']

except yaml.YAMLError as e:
logging.warn('Loading config failed, using default config ')
Expand All @@ -81,4 +79,4 @@ def wait_for_termination(self):
fl_server = FLServer(2)
fl_server.build()
fl_server.start()
fl_server.wait_for_termination()
fl_server.wait_for_termination()
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import grpc

import fgboost_service_pb2 as fgboost__service__pb2
from bigdl.dllib.utils.log4Error import invalidInputError


class FGBoostServiceStub(object):
"""Missing associated documentation comment in .proto file."""
Expand Down Expand Up @@ -59,43 +57,43 @@ def uploadLabel(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
invalidInputError(False, 'Method not implemented!')
raise NotImplementedError('Method not implemented!')

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

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

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

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

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

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


def add_FGBoostServiceServicer_to_server(servicer, server):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import grpc

import psi_service_pb2 as psi__service__pb2
from bigdl.dllib.utils.log4Error import invalidInputError


class PSIServiceStub(object):
Expand Down Expand Up @@ -40,19 +39,19 @@ def getSalt(self, request, context):
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
invalidInputError(False, 'Method not implemented!')
raise NotImplementedError('Method not implemented!')

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

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


def add_PSIServiceServicer_to_server(servicer, server):
Expand Down
14 changes: 0 additions & 14 deletions scala/ppml/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -414,20 +414,6 @@
<goal>single</goal>
</goals>
</execution>
<execution>
<id>assembly</id>
<inherited>false</inherited>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>${project.basedir}/src/assembly/ppml-assembly.xml
</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Expand Down

0 comments on commit ee493aa

Please sign in to comment.