forked from logicalclocks/hopsworks-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconstants.py
266 lines (205 loc) · 7.11 KB
/
constants.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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
#
# Copyright 2022 Logical Clocks AB
#
# 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.
#
class Default:
"""An object of this class is used in place of optional arguments in
cases when passing None should result in an exception or other behaviour.
Overwritting None with a default value is undesirable in some cases,
and this class solves the problem."""
def __repr__(self):
return "DEFAULT"
def __eq__(self, other):
return isinstance(other, Default)
DEFAULT = Default()
class JOBS:
SUCCESS_STATES = ["FINISHED", "SUCCEEDED"]
ERROR_STATES = [
"FAILED",
"KILLED",
"FRAMEWORK_FAILURE",
"APP_MASTER_START_FAILED",
"INITIALIZATION_FAILED",
]
class GIT:
SUCCESS_STATES = ["SUCCESS"]
ERROR_STATES = ["FAILED", "KILLED", "INITIALIZATION_FAILED", "TIMEDOUT"]
class SERVICES:
LIST = ["JOBS", "KAFKA", "JUPYTER", "HIVE", "SERVING", "FEATURESTORE", "AIRFLOW"]
class OPENSEARCH_CONFIG:
SSL_CONFIG = "es.net.ssl"
NODES_WAN_ONLY = "es.nodes.wan.only"
NODES = "es.nodes"
SSL_KEYSTORE_LOCATION = "es.net.ssl.keystore.location"
SSL_KEYSTORE_PASSWORD = "es.net.ssl.keystore.pass"
SSL_TRUSTSTORE_LOCATION = "es.net.ssl.truststore.location"
SSL_TRUSTSTORE_PASSWORD = "es.net.ssl.truststore.pass"
HTTP_AUTHORIZATION = "es.net.http.header.Authorization"
INDEX = "es.resource"
HOSTS = "hosts"
HTTP_COMPRESS = "http_compress"
HEADERS = "headers"
USE_SSL = "use_ssl"
VERIFY_CERTS = "verify_certs"
SSL_ASSERT_HOSTNAME = "ssl_assert_hostname"
CA_CERTS = "ca_certs"
class FEATURES:
"""
Class that stores constants about a feature.
"""
MAX_LENGTH_NAME = 63
class KAFKA_SSL_CONFIG:
"""
Kafka SSL constant strings for configuration
"""
SSL = "SSL"
SSL_TRUSTSTORE_LOCATION_CONFIG = "ssl.truststore.location"
SSL_TRUSTSTORE_LOCATION_DOC = "The location of the trust store file. "
SSL_TRUSTSTORE_PASSWORD_CONFIG = "ssl.truststore.password"
SSL_TRUSTSTORE_PASSWORD_DOC = "The password for the trust store file. If a password is not set access to the truststore is still available, but integrity checking is disabled."
SSL_KEYSTORE_LOCATION_CONFIG = "ssl.keystore.location"
SSL_KEYSTORE_PASSWORD_CONFIG = "ssl.keystore.password"
SSL_KEY_PASSWORD_CONFIG = "ssl.key.password"
SECURITY_PROTOCOL_CONFIG = "security.protocol"
SSL_CERTIFICATE_LOCATION_CONFIG = "ssl.certificate.location"
SSL_CA_LOCATION_CONFIG = "ssl.ca.location"
SSL_PRIVATE_KEY_LOCATION_CONFIG = "ssl.key.location"
SSL_ENDPOINT_IDENTIFICATION_ALGORITHM_CONFIG = (
"ssl.endpoint.identification.algorithm"
)
class KAFKA_PRODUCER_CONFIG:
"""
Constant strings for Kafka producers
"""
BOOTSTRAP_SERVERS_CONFIG = "bootstrap.servers"
KEY_SERIALIZER_CLASS_CONFIG = "key.serializer"
VALUE_SERIALIZER_CLASS_CONFIG = "value.serializer"
class KAFKA_CONSUMER_CONFIG:
"""
Constant strings for Kafka consumers
"""
GROUP_ID_CONFIG = "group.id"
CLIENT_ID_CONFIG = "client.id"
ENABLE_AUTO_COMMIT_CONFIG = "enable.auto.commit"
AUTO_COMMIT_INTERVAL_MS_CONFIG = "auto.commit.interval.ms"
SESSION_TIMEOUT_MS_CONFIG = "session.timeout.ms"
KEY_DESERIALIZER_CLASS_CONFIG = "key.deserializer"
VALUE_DESERIALIZER_CLASS_CONFIG = "value.deserializer"
AUTO_OFFSET_RESET_CONFIG = "auto.offset.reset"
ENABLE_AUTO_COMMIT_CONFIG = "enable.auto.commit"
KEY_DESERIALIZER_CLASS_CONFIG = "key.deserializer"
VALUE_DESERIALIZER_CLASS_CONFIG = "value.deserializer"
class ENV_VARS:
"""
Constant strings for environment variables
"""
KAFKA_BROKERS = "KAFKA_BROKERS"
ELASTIC_ENDPOINT_ENV_VAR = "ELASTIC_ENDPOINT"
class SSL_CONFIG:
"""
General SSL configuration constants for Hops-TLS
"""
KEYSTORE_SUFFIX = "__kstore.jks"
TRUSTSTORE_SUFFIX = "__tstore.jks"
PASSWORD_SUFFIX = "__cert.key"
K_CERTIFICATE_CONFIG = "k_certificate"
T_CERTIFICATE_CONFIG = "t_certificate"
PEM_CLIENT_CERTIFICATE_CONFIG = "client.pem"
PEM_CLIENT_KEY_CONFIG = "client_key.pem"
PEM_CA_CHAIN_CERTIFICATE_CONFIG = "ca_chain.pem"
DOMAIN_CA_TRUSTSTORE = "domain_ca_truststore"
CRYPTO_MATERIAL_PASSWORD = "material_passwd"
PEM_CA_ROOT_CERT = "/srv/hops/kagent/host-certs/hops_root_ca.pem"
SSL_ENABLED = "ipc.server.ssl.enabled"
class HOSTS:
APP_HOST = "c.app.hopsworks.ai"
class MODEL:
FRAMEWORK_TENSORFLOW = "TENSORFLOW"
FRAMEWORK_TORCH = "TORCH"
FRAMEWORK_PYTHON = "PYTHON"
FRAMEWORK_SKLEARN = "SKLEARN"
FRAMEWORK_LLM = "LLM"
class MODEL_REGISTRY:
HOPSFS_MOUNT_PREFIX = "/hopsfs/"
MODEL_FILES_DIR_NAME = "Files"
class MODEL_SERVING:
MODELS_DATASET = "Models"
ARTIFACTS_DIR_NAME = "Artifacts"
class ARTIFACT_VERSION:
CREATE = "CREATE"
class RESOURCES:
MIN_NUM_INSTANCES = 1 # disable scale-to-zero by default
# default values, not hard limits
MIN_CORES = 0.2
MIN_MEMORY = 32
MIN_GPUS = 0
MAX_CORES = 2
MAX_MEMORY = 1024
MAX_GPUS = 0
class KAFKA_TOPIC:
NONE = "NONE"
CREATE = "CREATE"
NUM_REPLICAS = 1
NUM_PARTITIONS = 1
class INFERENCE_LOGGER:
MODE_NONE = "NONE"
MODE_ALL = "ALL"
MODE_MODEL_INPUTS = "MODEL_INPUTS"
MODE_PREDICTIONS = "PREDICTIONS"
class INFERENCE_BATCHER:
ENABLED = False
class DEPLOYMENT:
ACTION_START = "START"
ACTION_STOP = "STOP"
class PREDICTOR:
# model server
MODEL_SERVER_PYTHON = "PYTHON"
MODEL_SERVER_TF_SERVING = "TENSORFLOW_SERVING"
MODEL_SERVER_VLLM = "VLLM"
# serving tool
SERVING_TOOL_DEFAULT = "DEFAULT"
SERVING_TOOL_KSERVE = "KSERVE"
class PREDICTOR_STATE:
# status
STATUS_CREATING = "Creating"
STATUS_CREATED = "Created"
STATUS_STARTING = "Starting"
STATUS_FAILED = "Failed"
STATUS_RUNNING = "Running"
STATUS_IDLE = "Idle"
STATUS_UPDATING = "Updating"
STATUS_STOPPING = "Stopping"
STATUS_STOPPED = "Stopped"
# condition type
CONDITION_TYPE_STOPPED = "STOPPED"
CONDITION_TYPE_SCHEDULED = "SCHEDULED"
CONDITION_TYPE_INITIALIZED = "INITIALIZED"
CONDITION_TYPE_STARTED = "STARTED"
CONDITION_TYPE_READY = "READY"
class INFERENCE_ENDPOINTS:
# endpoint type
ENDPOINT_TYPE_NODE = "NODE"
ENDPOINT_TYPE_KUBE_CLUSTER = "KUBE_CLUSTER"
ENDPOINT_TYPE_LOAD_BALANCER = "LOAD_BALANCER"
# port name
PORT_NAME_HTTP = "HTTP"
PORT_NAME_HTTPS = "HTTPS"
PORT_NAME_STATUS_PORT = "STATUS"
PORT_NAME_TLS = "TLS"
# protocol
API_PROTOCOL_REST = "REST"
API_PROTOCOL_GRPC = "GRPC"
class DEPLOYABLE_COMPONENT:
PREDICTOR = "predictor"
TRANSFORMER = "transformer"