1# Copyright 2021 Huawei Technologies Co., Ltd 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14# ============================================================================ 15 16import argparse 17import subprocess 18import os 19import ast 20 21parser = argparse.ArgumentParser(description="Run test_mobile_lenet.py case") 22parser.add_argument("--device_target", type=str, default="CPU") 23parser.add_argument("--server_mode", type=str, default="FEDERATED_LEARNING") 24parser.add_argument("--worker_num", type=int, default=0) 25parser.add_argument("--server_num", type=int, default=2) 26parser.add_argument("--scheduler_ip", type=str, default="127.0.0.1") 27parser.add_argument("--scheduler_port", type=int, default=8113) 28parser.add_argument("--fl_server_port", type=int, default=6666) 29parser.add_argument("--scheduler_manage_port", type=int, default=11202) 30parser.add_argument("--config_file_path", type=str, default="") 31parser.add_argument("--client_password", type=str, default="") 32parser.add_argument("--server_password", type=str, default="") 33parser.add_argument("--enable_ssl", type=ast.literal_eval, default=False) 34 35if __name__ == "__main__": 36 args, _ = parser.parse_known_args() 37 device_target = args.device_target 38 server_mode = args.server_mode 39 worker_num = args.worker_num 40 server_num = args.server_num 41 scheduler_ip = args.scheduler_ip 42 scheduler_port = args.scheduler_port 43 fl_server_port = args.fl_server_port 44 scheduler_manage_port = args.scheduler_manage_port 45 config_file_path = args.config_file_path 46 client_password = args.client_password 47 server_password = args.server_password 48 enable_ssl = args.enable_ssl 49 50 os.environ['MS_NODE_ID'] = "20" 51 cmd_sched = "execute_path=$(pwd) && self_path=$(dirname \"${script_self}\") && rm -rf ${execute_path}/scheduler/ &&" 52 cmd_sched += "mkdir ${execute_path}/scheduler/ &&" 53 cmd_sched += "cd ${execute_path}/scheduler/ || exit && export GLOG_v=1 &&" 54 cmd_sched += "python ${self_path}/../test_mobile_lenet.py" 55 cmd_sched += " --device_target=" + device_target 56 cmd_sched += " --server_mode=" + server_mode 57 cmd_sched += " --ms_role=MS_SCHED" 58 cmd_sched += " --worker_num=" + str(worker_num) 59 cmd_sched += " --server_num=" + str(server_num) 60 cmd_sched += " --scheduler_ip=" + scheduler_ip 61 cmd_sched += " --scheduler_port=" + str(scheduler_port) 62 cmd_sched += " --config_file_path=" + str(config_file_path) 63 cmd_sched += " --fl_server_port=" + str(fl_server_port) 64 cmd_sched += " --client_password=" + str(client_password) 65 cmd_sched += " --server_password=" + str(server_password) 66 cmd_sched += " --enable_ssl=" + str(enable_ssl) 67 cmd_sched += " --scheduler_manage_port=" + str(scheduler_manage_port) 68 cmd_sched += " > scheduler.log 2>&1 &" 69 70 subprocess.call(['bash', '-c', cmd_sched]) 71