-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessages.py
85 lines (75 loc) · 2.24 KB
/
messages.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
"""Message structure for worker and manager communication."""
class Message():
"""Base Message Class"""
def __init__(self):
self.type = ""
def __eq__(self, other):
return self.__dict__ == other.__dict__
class Init(Message):
"""Initialization message sent by worker."""
def __init__(self, data=None):
super().__init__()
self.type = "init"
self.hostname = ""
if data:
self.__dict__ = data
class Init_Response(Message):
"""Manager response to initialization message."""
def __init__(self, data=None):
super().__init__()
self.type = "init_resp"
self.id = 0
self.model = ""
self.loss = ""
self.optimizer = ""
self.metrics = []
self.weights = ""
if data:
self.__dict__ = data
class Pull(Message):
"""Request model parameters from the manager."""
def __init__(self, data=None):
super().__init__()
self.type = "pull"
self.hostname = ""
if data:
self.__dict__ = data
class Pull_Response(Message):
"""Return model parameters to the worker that requested them."""
def __init__(self, data=None):
super().__init__()
self.type = "pull_resp"
self.weights = ""
if data:
self.__dict__ = data
class Push(Message):
"""Supply the manager with model information."""
def __init__(self, data=None):
super().__init__()
self.type = "push"
self.weights = ""
self.hostname = ""
if data:
self.__dict__ = data
class Terminate(Message):
"""WHAT ARE YOU DOUUUUINGGK? KILL MEEH NAAHHOUUUU!!!!""" # lol
def __init__(self, data=None):
super().__init__()
self.type = "terminate"
if data:
self.__dict__ = data
class Empty(Message):
"""Empty Message"""
def __init__(self, data=None):
super().__init__()
self.type = "empty"
if data:
self.__dict__ = data
class Heartbeat(Message):
"""Keep Alive Message"""
def __init__(self, data=None):
super().__init__()
self.type = "heartbeat"
self.hostname = ""
if data:
self.__dict__ = data