diff --git a/docs/requirements.txt b/docs/requirements.txt index 1560ebc5f9d74fbae773ac5bc45c5b42b044287a..90c6171099d9bb6e5ce32ac1164ba848c14426f4 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -2,3 +2,4 @@ sphinx==2.1.0 mistune sphinx_rtd_theme paddlepaddle>=1.6 +zmq diff --git a/paddle_fl/core/scheduler/agent_master.py b/paddle_fl/core/scheduler/agent_master.py index 8f4a1a0a15be1dc25f9470c45d84692120e95108..d436b822865fe0189bddb1c871b69a20dcdeae17 100644 --- a/paddle_fl/core/scheduler/agent_master.py +++ b/paddle_fl/core/scheduler/agent_master.py @@ -4,7 +4,7 @@ import random def recv_and_parse_kv(socket): message = socket.recv() - group = message.split("\t") + group = message.decode().split("\t") if group[0] == "alive": return group[0], "0" else: @@ -23,9 +23,9 @@ class FLServerAgent(object): def connect_scheduler(self): while True: - self.socket.send("SERVER_EP\t{}".format(self.current_ep)) + self.socket.send_string("SERVER_EP\t{}".format(self.current_ep)) message = self.socket.recv() - group = message.split("\t") + group = message.decode().split("\t") if group[0] == 'INIT': break @@ -39,14 +39,14 @@ class FLWorkerAgent(object): def connect_scheduler(self): while True: - self.socket.send("WORKER_EP\t{}".format(self.current_ep)) + self.socket.send_string("WORKER_EP\t{}".format(self.current_ep)) message = self.socket.recv() - group = message.split("\t") + group = message.decode().split("\t") if group[0] == 'INIT': break def finish_training(self): - self.socket.send("FINISH\t{}".format(self.current_ep)) + self.socket.send_string("FINISH\t{}".format(self.current_ep)) key, value = recv_and_parse_kv(self.socket) if key == "WAIT": time.sleep(3) @@ -54,7 +54,7 @@ class FLWorkerAgent(object): return False def can_join_training(self): - self.socket.send("JOIN\t{}".format(self.current_ep)) + self.socket.send_string("JOIN\t{}".format(self.current_ep)) key, value = recv_and_parse_kv(self.socket) if key == "ACCEPT": @@ -91,13 +91,13 @@ class FLScheduler(object): key, value = recv_and_parse_kv(self.socket) if key == WORKER_EP: self.fl_workers.append(value) - self.socket.send("INIT\t{}".format(value)) + self.socket.send_string("INIT\t{}".format(value)) elif key == SERVER_EP: self.fl_servers.append(value) - self.socket.send("INIT\t{}".format(value)) + self.socket.send_string("INIT\t{}".format(value)) else: time.sleep(3) - self.socket.send("REJECT\t0") + self.socket.send_string("REJECT\t0") if len(self.fl_workers) == self.worker_num and \ len(self.fl_servers) == self.server_num: ready = True @@ -122,12 +122,12 @@ class FLScheduler(object): if worker_dict[value] == 0: ready_workers.append(value) worker_dict[value] = 1 - self.socket.send("ACCEPT\t0") + self.socket.send_string("ACCEPT\t0") continue else: if value not in ready_workers: ready_workers.append(value) - self.socket.send("REJECT\t0") + self.socket.send_string("REJECT\t0") if len(ready_workers) == len(self.fl_workers): all_ready_to_train = True @@ -137,9 +137,9 @@ class FLScheduler(object): key, value = recv_and_parse_kv(self.socket) if key == "FINISH": finish_training_dict[value] = 1 - self.socket.send("WAIT\t0") + self.socket.send_string("WAIT\t0") else: - self.socket.send("REJECT\t0") + self.socket.send_string("REJECT\t0") if len(finish_training_dict) == len(worker_dict): all_finish_training = True time.sleep(5) diff --git a/paddle_fl/core/trainer/diffiehellman/diffiehellman.py b/paddle_fl/core/trainer/diffiehellman/diffiehellman.py index 3d3e18a706a15865d9ef50c8bd3138645e0cff8c..364d01b82d560627555e031873c1a07993d41165 100644 --- a/paddle_fl/core/trainer/diffiehellman/diffiehellman.py +++ b/paddle_fl/core/trainer/diffiehellman/diffiehellman.py @@ -42,9 +42,9 @@ try: from ssl import RAND_bytes rng = RAND_bytes except(AttributeError, ImportError): - raise RNGError -#python2 -#rng = os.urandom + #python2 + rng = os.urandom + #raise RNGError class DiffieHellman: """ diff --git a/paddle_fl/core/trainer/fl_trainer.py b/paddle_fl/core/trainer/fl_trainer.py index dce6086509154ddf137722a49b5f71af0dfb73cf..0252f1dd5c1ae5f92dd922c2a40b525121d505dd 100755 --- a/paddle_fl/core/trainer/fl_trainer.py +++ b/paddle_fl/core/trainer/fl_trainer.py @@ -16,7 +16,7 @@ import logging from paddle_fl.core.scheduler.agent_master import FLWorkerAgent import numpy import hmac -#from .diffiehellman.diffiehellman import DiffieHellman +from .diffiehellman.diffiehellman import DiffieHellman class FLTrainerFactory(object): def __init__(self): diff --git a/paddle_fl/version.py b/paddle_fl/version.py index 95f05ed054c388c19eaca74fdf05b6d9a8400cdb..be6e9b3698d5d6a5012dfb4edef80c3ac01ff798 100644 --- a/paddle_fl/version.py +++ b/paddle_fl/version.py @@ -12,5 +12,5 @@ # See the License for the specific language governing permissions and # limitations under the License. """ PaddleFL version string """ -fl_version = "0.1.3" -module_proto_version = "0.1.3" +fl_version = "0.1.5" +module_proto_version = "0.1.5"