-
Notifications
You must be signed in to change notification settings - Fork 0
/
distribution_config.py
87 lines (71 loc) · 2 KB
/
distribution_config.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
86
87
from enum import Enum
import dbm
dconf = {
"MASTER_IP": "211.180.114.12",
"SLAVE_IPS": ["211.180.114.9"],
'PORT': 8989,
'REMOTE_PASSWORD': b'SejongGoPassword'
}
class ASYNC_PIPELINE_STATE(Enum):
SELF_PLAYING = 1
EVALUATING = 2
TRAINING = 3
OTHERS = 4
def turn_on_event(state):
db = dbm.open("events", 'c')
if state == ASYNC_PIPELINE_STATE.SELF_PLAYING:
db['self_play_event'] = '1'
db['evaluate_event'] = '0'
db['training'] = '0'
elif state == ASYNC_PIPELINE_STATE.EVALUATING:
db['evaluate_event'] = '1'
db['self_play_event'] = '0'
db['training'] = '0'
elif state == ASYNC_PIPELINE_STATE.TRAINING:
db['training'] = '1'
db['self_play_event'] = '0'
db['evaluate_event'] = '0'
db.close()
def set_slave_working(is_working):
db = dbm.open("events", 'c')
if is_working:
db['slave_working'] = '1'
else:
db['slave_working'] = '0'
db.close()
def set_best_model_name(best_model_name):
db = dbm.open("events", 'c')
db['best_model'] = best_model_name
db.close()
def set_latest_model_name(best_model_name):
db = dbm.open("events", 'c')
db['latest_model'] = best_model_name
db.close()
def get_best_model_name():
try:
db = dbm.open("events", 'r')
best_model_name = db['best_model']
db.close()
except Exception:
return ""
return best_model_name.decode("utf-8")
def get_latest_model_name():
try:
db = dbm.open("events", 'r')
latest_model_name = db['latest_model']
db.close()
except Exception:
return ""
return latest_model_name.decode("utf-8")
def is_slave_working():
try:
db = dbm.open("events", 'r')
r = db['slave_working']
db.close()
except Exception as e:
print("Exception while checking for working slave. DB may not exist. Return False")
print(e)
return False
if r == b'1':
return True
return False