logger.info("Set heter parameter server env: {}".format(
pretty_print_envs(environs)))
classParameterServerLauncher(object):
def__init__(self,args):
self.server_num=0
self.worker_num=0
self.heter_worker_num=0
self.server_endpoints=[]
self.server_endpoints_ips=[]
self.server_endpoints_port=[]
self.worker_endpoints=[]
self.worker_endpoints_ips=[]
self.worker_endpoints_port=[]
self.heter_worker_endpoints=[]
self.heter_worker_endpoints_ips=[]
self.heter_worker_endpoints_port=[]
self.is_local=True
self.current_node_ip=""
self.get_role_endpoints(args)
defget_role_endpoints(self,args):
# get server envs
ifargs.server_num:
self.server_num=args.server_num
ifargs.servers:
assertlen(
args.servers.split(",")
)==self.server_num,"The server_num and servers doesn't match. Expect servers endpoints num epual to server_num, but received servers enpoint num: {} and server_num {}".format(
len(args.servers.split(",")),self.server_num)
self.server_endpoints=args.servers
else:
ports=get_ports(self.server_num,0)
self.server_endpoints=",".join(
["127.0.0.1:"+str(x)forxinports])
else:
assertargs.servers!="","The setting of Parameter-Server must has server_num or servers."
)==self.worker_num,"The worker_num and workers doesn't match. Expect workers endpoints num epual to worker_num, but received workers enpoint num: {} and worker_num {}".format(
len(args.workers.split(",")),self.worker_num)
self.worker_endpoints=args.workers
else:
ports=get_ports(self.worker_num,self.server_num)
self.worker_endpoints=",".join(
["127.0.0.1:"+str(x)forxinports])
else:
assertargs.workers!="","The setting of Parameter-Server must has worker_num or workers."
)==self.heter_worker_num,"The heter_worker_num and heter_workers doesn't match. Expect heter_workers endpoints num epual to heter_worker_num, but received heter_workers enpoint num: {} and heter_worker_num {}".format(
len(args.heter_workers.split(",")),
self.heter_worker_num)
self.heter_worker_endpoints=args.heter_workers
else:
ports=get_ports(self.heter_worker_num,
self.server_num+self.worker_num)
self.heter_worker_endpoints=",".join(
["127.0.0.1:"+str(x)forxinports])
else:
assertargs.heter_workers!="","The setting of Parameter-Server heter mode must has heter_worker_num or heter_workers."