Skip to content

Commit

Permalink
Add start-fl-server.py to Docker Image
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanyu-Jin committed Aug 19, 2022
1 parent d8b4320 commit 74089ba
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions ppml/trusted-big-data-ml/python/docker-graphene/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ ADD ./test-suites /ppml/trusted-big-data-ml/work/test-suites
ADD ./_dill.py.patch ./_dill.py.patch
ADD ./python-uuid.patch ./python-uuid.patch
ADD ./python-pslinux.patch ./python-pslinux.patch
ADD ../../../../python/ppml/scripts/start-fl-server.py /ppml/trusted-big-data-ml/work/examples

RUN zip -u ${BIGDL_HOME}/jars/bigdl-dllib-spark_${SPARK_VERSION}-${BIGDL_VERSION}.jar ./tracker.py && \
patch /usr/local/lib/python3.7/dist-packages/dill/_dill.py ./_dill.py.patch && \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#
# Copyright 2016 The BigDL Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# 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__':

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()

0 comments on commit 74089ba

Please sign in to comment.