forked from FederatedAI/FATE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
constant.py
173 lines (129 loc) · 3.8 KB
/
constant.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from enum import IntEnum
class WorkMode(IntEnum):
STANDALONE = 0
CLUSTER = 1
class Backend(IntEnum):
EGGROLL = 0
SPARK_RABBITMQ = 1
SPARK_PULSAR = 2
def is_eggroll(self):
return self.value == self.EGGROLL
def is_spark_rabbitmq(self):
return self.value == self.SPARK_RABBITMQ
def is_spark_pulsar(self):
return self.value == self.SPARK_PULSAR
class StoreEngine(IntEnum):
EGGROLL = 0
HDFS = 1
def is_hdfs(self):
return self.value == self.HDFS
def is_eggroll(self):
return self.value == self.EGGROLL
class RetCode(IntEnum):
SUCCESS = 0
EXCEPTION_ERROR = 100
PARAMETER_ERROR = 101
DATA_ERROR = 102
OPERATING_ERROR = 103
FEDERATED_ERROR = 104
CONNECTION_ERROR = 105
SERVER_ERROR = 500
class SchedulingStatusCode(object):
SUCCESS = 0
NO_RESOURCE = 1
PASS = 1
NO_NEXT = 2
HAVE_NEXT = 3
FAILED = 4
class FederatedSchedulingStatusCode(object):
SUCCESS = 0
PARTIAL = 1
FAILED = 2
class BaseStatus(object):
@classmethod
def status_list(cls):
return [cls.__dict__[k] for k in cls.__dict__.keys() if not callable(getattr(cls, k)) and not k.startswith("__")]
@classmethod
def contains(cls, status):
return status in cls.status_list()
class StatusSet(BaseStatus):
WAITING = 'waiting'
START = 'start'
RUNNING = "running"
CANCELED = "canceled"
TIMEOUT = "timeout"
FAILED = "failed"
SUCCESS = "success"
@classmethod
def get_level(cls, status):
return dict(zip(cls.status_list(), range(len(cls.status_list())))).get(status, None)
class JobStatus(BaseStatus):
WAITING = StatusSet.WAITING
RUNNING = StatusSet.RUNNING
CANCELED = StatusSet.CANCELED
TIMEOUT = StatusSet.TIMEOUT
FAILED = StatusSet.FAILED
SUCCESS = StatusSet.SUCCESS
class TaskSetStatus(BaseStatus):
WAITING = StatusSet.WAITING
RUNNING = StatusSet.RUNNING
CANCELED = StatusSet.CANCELED
TIMEOUT = StatusSet.TIMEOUT
FAILED = StatusSet.FAILED
SUCCESS = StatusSet.SUCCESS
class TaskStatus(BaseStatus):
WAITING = StatusSet.WAITING
RUNNING = StatusSet.RUNNING
CANCELED = StatusSet.CANCELED
TIMEOUT = StatusSet.TIMEOUT
FAILED = StatusSet.FAILED
SUCCESS = StatusSet.SUCCESS
class OngoingStatus(BaseStatus):
WAITING = StatusSet.WAITING
RUNNING = StatusSet.RUNNING
class InterruptStatus(BaseStatus):
CANCELED = StatusSet.CANCELED
TIMEOUT = StatusSet.TIMEOUT
FAILED = StatusSet.FAILED
class EndStatus(BaseStatus):
CANCELED = StatusSet.CANCELED
TIMEOUT = StatusSet.TIMEOUT
FAILED = StatusSet.FAILED
SUCCESS = StatusSet.SUCCESS
@staticmethod
def is_end_status(status):
return status in EndStatus.__dict__.keys()
class ModelStorage(object):
REDIS = "redis"
MYSQL = "mysql"
class ModelOperation(object):
STORE = "store"
RESTORE = "restore"
EXPORT = "export"
IMPORT = "import"
LOAD = "load"
BIND = "bind"
class ProcessRole(object):
SERVER = "server"
EXECUTOR = "executor"
class TagOperation(object):
CREATE = "create"
RETRIEVE = "retrieve"
UPDATE = "update"
DESTROY = "destroy"
LIST = "list"