From 74089ba2840edbd2c632c76c6b186937479e1d6f Mon Sep 17 00:00:00 2001 From: Jin Hanyu <476099001@qq.com> Date: Fri, 19 Aug 2022 13:38:06 +0800 Subject: [PATCH] Add start-fl-server.py to Docker Image --- .../python/docker-graphene/Dockerfile | 1 + .../examples/start-fl-server.py | 62 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 ppml/trusted-big-data-ml/python/docker-graphene/examples/start-fl-server.py diff --git a/ppml/trusted-big-data-ml/python/docker-graphene/Dockerfile b/ppml/trusted-big-data-ml/python/docker-graphene/Dockerfile index 91ed7406db4a..214687384529 100644 --- a/ppml/trusted-big-data-ml/python/docker-graphene/Dockerfile +++ b/ppml/trusted-big-data-ml/python/docker-graphene/Dockerfile @@ -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 && \ diff --git a/ppml/trusted-big-data-ml/python/docker-graphene/examples/start-fl-server.py b/ppml/trusted-big-data-ml/python/docker-graphene/examples/start-fl-server.py new file mode 100644 index 000000000000..c72ac47ec34f --- /dev/null +++ b/ppml/trusted-big-data-ml/python/docker-graphene/examples/start-fl-server.py @@ -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 -p ") + sys.exit(2) + + for opt, arg in opts: + if opt == '-h': + print("start_fl_server.py -c -p ") + 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()