sagemaker-hyperpod 3.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sagemaker/__init__.py +0 -0
- sagemaker/hyperpod/__init__.py +2 -0
- sagemaker/hyperpod/cli/__init__.py +0 -0
- sagemaker/hyperpod/cli/clients/__init__.py +12 -0
- sagemaker/hyperpod/cli/clients/kubernetes_client.py +365 -0
- sagemaker/hyperpod/cli/commands/__init__.py +0 -0
- sagemaker/hyperpod/cli/commands/cluster.py +627 -0
- sagemaker/hyperpod/cli/commands/inference.py +659 -0
- sagemaker/hyperpod/cli/commands/training.py +347 -0
- sagemaker/hyperpod/cli/constants/__init__.py +0 -0
- sagemaker/hyperpod/cli/constants/command_constants.py +105 -0
- sagemaker/hyperpod/cli/constants/exception_constants.py +13 -0
- sagemaker/hyperpod/cli/constants/hyperpod_instance_types.py +100 -0
- sagemaker/hyperpod/cli/constants/kueue_constants.py +17 -0
- sagemaker/hyperpod/cli/constants/pytorch_constants.py +15 -0
- sagemaker/hyperpod/cli/hyp_cli.py +132 -0
- sagemaker/hyperpod/cli/inference_utils.py +121 -0
- sagemaker/hyperpod/cli/service/__init__.py +12 -0
- sagemaker/hyperpod/cli/service/cancel_training_job.py +70 -0
- sagemaker/hyperpod/cli/service/discover_namespaces.py +108 -0
- sagemaker/hyperpod/cli/service/exec_command.py +75 -0
- sagemaker/hyperpod/cli/service/get_logs.py +136 -0
- sagemaker/hyperpod/cli/service/get_namespaces.py +59 -0
- sagemaker/hyperpod/cli/service/get_training_job.py +110 -0
- sagemaker/hyperpod/cli/service/list_pods.py +138 -0
- sagemaker/hyperpod/cli/service/list_training_jobs.py +178 -0
- sagemaker/hyperpod/cli/service/self_subject_access_review.py +47 -0
- sagemaker/hyperpod/cli/telemetry/__init__.py +12 -0
- sagemaker/hyperpod/cli/telemetry/user_agent.py +36 -0
- sagemaker/hyperpod/cli/templates/__init__.py +12 -0
- sagemaker/hyperpod/cli/templates/k8s_pytorch_job_template.py +74 -0
- sagemaker/hyperpod/cli/training_utils.py +200 -0
- sagemaker/hyperpod/cli/utils.py +183 -0
- sagemaker/hyperpod/cli/validators/__init__.py +12 -0
- sagemaker/hyperpod/cli/validators/cluster_validator.py +52 -0
- sagemaker/hyperpod/cli/validators/job_validator.py +346 -0
- sagemaker/hyperpod/cli/validators/validator.py +75 -0
- sagemaker/hyperpod/common/__init__.py +0 -0
- sagemaker/hyperpod/common/config/__init__.py +1 -0
- sagemaker/hyperpod/common/config/metadata.py +18 -0
- sagemaker/hyperpod/common/utils.py +299 -0
- sagemaker/hyperpod/inference/__init__.py +11 -0
- sagemaker/hyperpod/inference/config/__init__.py +0 -0
- sagemaker/hyperpod/inference/config/constants.py +18 -0
- sagemaker/hyperpod/inference/config/hp_endpoint_config.py +767 -0
- sagemaker/hyperpod/inference/config/hp_jumpstart_endpoint_config.py +572 -0
- sagemaker/hyperpod/inference/hp_endpoint.py +203 -0
- sagemaker/hyperpod/inference/hp_endpoint_base.py +223 -0
- sagemaker/hyperpod/inference/hp_jumpstart_endpoint.py +232 -0
- sagemaker/hyperpod/observability/MonitoringConfig.py +10 -0
- sagemaker/hyperpod/observability/__init__.py +0 -0
- sagemaker/hyperpod/observability/constants.py +2 -0
- sagemaker/hyperpod/observability/utils.py +64 -0
- sagemaker/hyperpod/training/__init__.py +9 -0
- sagemaker/hyperpod/training/config/__init__.py +1 -0
- sagemaker/hyperpod/training/config/hyperpod_pytorch_job_config.py +2977 -0
- sagemaker/hyperpod/training/config/hyperpod_pytorch_job_status.py +3083 -0
- sagemaker/hyperpod/training/hyperpod_pytorch_job.py +253 -0
- sagemaker_hyperpod-3.0.0.dist-info/METADATA +534 -0
- sagemaker_hyperpod-3.0.0.dist-info/RECORD +66 -0
- sagemaker_hyperpod-3.0.0.dist-info/WHEEL +5 -0
- sagemaker_hyperpod-3.0.0.dist-info/entry_points.txt +2 -0
- sagemaker_hyperpod-3.0.0.dist-info/licenses/LICENSE +175 -0
- sagemaker_hyperpod-3.0.0.dist-info/licenses/NOTICE +1 -0
- sagemaker_hyperpod-3.0.0.dist-info/top_level.txt +1 -0
- sagemaker_hyperpod-3.0.0.dist-info/zip-safe +1 -0
|
@@ -0,0 +1,659 @@
|
|
|
1
|
+
import click
|
|
2
|
+
import json
|
|
3
|
+
import boto3
|
|
4
|
+
from typing import Optional
|
|
5
|
+
from tabulate import tabulate
|
|
6
|
+
|
|
7
|
+
from sagemaker.hyperpod.cli.inference_utils import generate_click_command
|
|
8
|
+
from hyperpod_jumpstart_inference_template.registry import SCHEMA_REGISTRY as JS_REG
|
|
9
|
+
from hyperpod_custom_inference_template.registry import SCHEMA_REGISTRY as C_REG
|
|
10
|
+
from sagemaker.hyperpod.inference.hp_jumpstart_endpoint import HPJumpStartEndpoint
|
|
11
|
+
from sagemaker.hyperpod.inference.hp_endpoint import HPEndpoint
|
|
12
|
+
from sagemaker_core.resources import Endpoint
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
# CREATE
|
|
16
|
+
@click.command("hyp-jumpstart-endpoint")
|
|
17
|
+
@click.option(
|
|
18
|
+
"--namespace",
|
|
19
|
+
type=click.STRING,
|
|
20
|
+
required=False,
|
|
21
|
+
default="default",
|
|
22
|
+
help="Optional. The namespace of the jumpstart model endpoint to create. Default set to 'default'",
|
|
23
|
+
)
|
|
24
|
+
@click.option("--version", default="1.0", help="Schema version to use")
|
|
25
|
+
@generate_click_command(
|
|
26
|
+
schema_pkg="hyperpod_jumpstart_inference_template",
|
|
27
|
+
registry=JS_REG,
|
|
28
|
+
)
|
|
29
|
+
def js_create(namespace, version, js_endpoint):
|
|
30
|
+
"""
|
|
31
|
+
Create a jumpstart model endpoint.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
js_endpoint.create(namespace=namespace)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@click.command("hyp-custom-endpoint")
|
|
38
|
+
@click.option(
|
|
39
|
+
"--namespace",
|
|
40
|
+
type=click.STRING,
|
|
41
|
+
required=False,
|
|
42
|
+
default="default",
|
|
43
|
+
help="Optional. The namespace of the jumpstart model endpoint to create. Default set to 'default'",
|
|
44
|
+
)
|
|
45
|
+
@click.option("--version", default="1.0", help="Schema version to use")
|
|
46
|
+
@generate_click_command(
|
|
47
|
+
schema_pkg="hyperpod_custom_inference_template",
|
|
48
|
+
registry=C_REG,
|
|
49
|
+
)
|
|
50
|
+
def custom_create(namespace, version, custom_endpoint):
|
|
51
|
+
"""
|
|
52
|
+
Create a custom model endpoint.
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
custom_endpoint.create(namespace=namespace)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
# INVOKE
|
|
59
|
+
@click.command("hyp-custom-endpoint")
|
|
60
|
+
@click.option(
|
|
61
|
+
"--endpoint-name",
|
|
62
|
+
type=click.STRING,
|
|
63
|
+
required=True,
|
|
64
|
+
help="Required. The name of the model endpoint to invoke.",
|
|
65
|
+
)
|
|
66
|
+
@click.option(
|
|
67
|
+
"--body",
|
|
68
|
+
type=click.STRING,
|
|
69
|
+
required=True,
|
|
70
|
+
help="Required. The body of the request to invoke.",
|
|
71
|
+
)
|
|
72
|
+
def custom_invoke(
|
|
73
|
+
endpoint_name: str,
|
|
74
|
+
body: str,
|
|
75
|
+
):
|
|
76
|
+
"""
|
|
77
|
+
Invoke a model endpoint.
|
|
78
|
+
"""
|
|
79
|
+
try:
|
|
80
|
+
payload = json.dumps(json.loads(body))
|
|
81
|
+
except json.JSONDecodeError:
|
|
82
|
+
raise click.ClickException("--body must be valid JSON")
|
|
83
|
+
|
|
84
|
+
rt = boto3.client("sagemaker-runtime")
|
|
85
|
+
|
|
86
|
+
try:
|
|
87
|
+
endpoint = Endpoint.get(endpoint_name)
|
|
88
|
+
except Exception as e:
|
|
89
|
+
endpoint = None
|
|
90
|
+
|
|
91
|
+
if endpoint and endpoint.endpoint_status != "InService":
|
|
92
|
+
raise click.ClickException(
|
|
93
|
+
f"Endpoint {endpoint_name} creation has been initated but is currently not in service")
|
|
94
|
+
elif not endpoint:
|
|
95
|
+
try:
|
|
96
|
+
hp_endpoint = HPEndpoint.get(endpoint_name)
|
|
97
|
+
except Exception as e:
|
|
98
|
+
hp_endpoint = None
|
|
99
|
+
|
|
100
|
+
if not hp_endpoint:
|
|
101
|
+
raise click.ClickException(f"Endpoint {endpoint_name} not found. Please check the endpoint name input")
|
|
102
|
+
else:
|
|
103
|
+
raise click.ClickException(f"Job has been initiated but the Endpoint is not created yet. Please check logs or wait and try again later")
|
|
104
|
+
|
|
105
|
+
resp = rt.invoke_endpoint(
|
|
106
|
+
EndpointName=endpoint_name,
|
|
107
|
+
Body=payload.encode("utf-8"),
|
|
108
|
+
ContentType="application/json",
|
|
109
|
+
)
|
|
110
|
+
result = resp["Body"].read().decode("utf-8")
|
|
111
|
+
click.echo(result)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
# LIST
|
|
115
|
+
@click.command("hyp-jumpstart-endpoint")
|
|
116
|
+
@click.option(
|
|
117
|
+
"--namespace",
|
|
118
|
+
type=click.STRING,
|
|
119
|
+
required=False,
|
|
120
|
+
default="default",
|
|
121
|
+
help="Optional. The namespace of the jumpstart model endpoint to list. Default set to 'default'",
|
|
122
|
+
)
|
|
123
|
+
def js_list(
|
|
124
|
+
namespace: Optional[str],
|
|
125
|
+
):
|
|
126
|
+
"""
|
|
127
|
+
List jumpstart model endpoints with provided namespace.
|
|
128
|
+
"""
|
|
129
|
+
|
|
130
|
+
endpoints = HPJumpStartEndpoint.model_construct().list(namespace)
|
|
131
|
+
data = [ep.model_dump() for ep in endpoints]
|
|
132
|
+
|
|
133
|
+
if not data:
|
|
134
|
+
click.echo("No endpoints found")
|
|
135
|
+
return
|
|
136
|
+
|
|
137
|
+
headers = ["name", "namespace", "labels", "status"]
|
|
138
|
+
rows = []
|
|
139
|
+
for item in data:
|
|
140
|
+
if not isinstance(item, dict):
|
|
141
|
+
continue
|
|
142
|
+
|
|
143
|
+
metadata = item.get("metadata") or {}
|
|
144
|
+
status = item.get("status") or {}
|
|
145
|
+
deployment_status = status.get("deploymentStatus") or {}
|
|
146
|
+
|
|
147
|
+
row = [
|
|
148
|
+
metadata.get("name", ""),
|
|
149
|
+
metadata.get("namespace", ""),
|
|
150
|
+
metadata.get("labels", ""),
|
|
151
|
+
deployment_status.get("deploymentObjectOverallState", "")
|
|
152
|
+
]
|
|
153
|
+
rows.append(row)
|
|
154
|
+
click.echo(tabulate(rows, headers=headers, tablefmt="github"))
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
@click.command("hyp-custom-endpoint")
|
|
158
|
+
@click.option(
|
|
159
|
+
"--namespace",
|
|
160
|
+
type=click.STRING,
|
|
161
|
+
required=False,
|
|
162
|
+
default="default",
|
|
163
|
+
help="Optional. The namespace of the custom model endpoint to list. Default set to 'default'",
|
|
164
|
+
)
|
|
165
|
+
def custom_list(
|
|
166
|
+
namespace: Optional[str],
|
|
167
|
+
):
|
|
168
|
+
"""
|
|
169
|
+
List custom model endpoints with provided namespace.
|
|
170
|
+
"""
|
|
171
|
+
|
|
172
|
+
endpoints = HPEndpoint.model_construct().list(namespace)
|
|
173
|
+
data = [ep.model_dump() for ep in endpoints]
|
|
174
|
+
|
|
175
|
+
if not data:
|
|
176
|
+
click.echo("No endpoints found")
|
|
177
|
+
return
|
|
178
|
+
|
|
179
|
+
headers = ["name", "namespace", "labels", "status"]
|
|
180
|
+
rows = []
|
|
181
|
+
for item in data:
|
|
182
|
+
if not isinstance(item, dict):
|
|
183
|
+
continue
|
|
184
|
+
|
|
185
|
+
metadata = item.get("metadata") or {}
|
|
186
|
+
status = item.get("status") or {}
|
|
187
|
+
deployment_status = status.get("deploymentStatus") or {}
|
|
188
|
+
|
|
189
|
+
row = [
|
|
190
|
+
metadata.get("name", ""),
|
|
191
|
+
metadata.get("namespace", ""),
|
|
192
|
+
metadata.get("labels", ""),
|
|
193
|
+
deployment_status.get("deploymentObjectOverallState", "")
|
|
194
|
+
]
|
|
195
|
+
rows.append(row)
|
|
196
|
+
click.echo(tabulate(rows, headers=headers, tablefmt="github"))
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
@click.command("hyp-jumpstart-endpoint")
|
|
200
|
+
@click.option(
|
|
201
|
+
"--name",
|
|
202
|
+
type=click.STRING,
|
|
203
|
+
required=True,
|
|
204
|
+
help="Required. The name of the jumpstart model endpoint to describe.",
|
|
205
|
+
)
|
|
206
|
+
@click.option(
|
|
207
|
+
"--namespace",
|
|
208
|
+
type=click.STRING,
|
|
209
|
+
required=False,
|
|
210
|
+
default="default",
|
|
211
|
+
help="Optional. The namespace of the jumpstart model endpoint to describe. Default set to 'default'.",
|
|
212
|
+
)
|
|
213
|
+
@click.option(
|
|
214
|
+
"--full",
|
|
215
|
+
type=click.BOOL,
|
|
216
|
+
is_flag=True,
|
|
217
|
+
default=False,
|
|
218
|
+
required=False,
|
|
219
|
+
help="Optional. If set to `True`, the full json will be displayed",
|
|
220
|
+
)
|
|
221
|
+
def js_describe(
|
|
222
|
+
name: str,
|
|
223
|
+
namespace: Optional[str],
|
|
224
|
+
full: bool
|
|
225
|
+
):
|
|
226
|
+
"""
|
|
227
|
+
Describe a jumpstart model endpoint with provided name and namespace.
|
|
228
|
+
"""
|
|
229
|
+
|
|
230
|
+
my_endpoint = HPJumpStartEndpoint.model_construct().get(name, namespace)
|
|
231
|
+
data = my_endpoint.model_dump()
|
|
232
|
+
|
|
233
|
+
if full:
|
|
234
|
+
click.echo("\nFull JSON:")
|
|
235
|
+
click.echo(json.dumps(data, indent=2))
|
|
236
|
+
|
|
237
|
+
else:
|
|
238
|
+
if not isinstance(data, dict):
|
|
239
|
+
click.echo("Invalid data received: expected a dictionary.")
|
|
240
|
+
return
|
|
241
|
+
|
|
242
|
+
status = data.get("status") or {}
|
|
243
|
+
metadata = data.get("metadata") or {}
|
|
244
|
+
model = data.get("model") or {}
|
|
245
|
+
server = data.get("server") or {}
|
|
246
|
+
tls = data.get("tlsConfig") or {}
|
|
247
|
+
|
|
248
|
+
summary = [
|
|
249
|
+
("Deployment State:", status.get("deploymentStatus", {}).get("deploymentObjectOverallState", "")),
|
|
250
|
+
("Metadata Name:", metadata.get("name", "")),
|
|
251
|
+
("Namespace:", metadata.get("namespace", "")),
|
|
252
|
+
("Label:", metadata.get("label", "")),
|
|
253
|
+
("Model ID:", model.get("modelId", "")),
|
|
254
|
+
("Instance Type:", server.get("instanceType", "")),
|
|
255
|
+
("Accept eula:", model.get("acceptEula", "")),
|
|
256
|
+
("Model Version:", model.get("modelVersion", "")),
|
|
257
|
+
("TLS Cert. Output S3 URI:",tls.get("tlsCertificateOutputS3Uri", "")),
|
|
258
|
+
]
|
|
259
|
+
click.echo(tabulate(summary, tablefmt="plain"))
|
|
260
|
+
|
|
261
|
+
click.echo("\nSageMaker Endpoint:")
|
|
262
|
+
status = data.get("status") or {}
|
|
263
|
+
endpoints = status.get("endpoints") or {}
|
|
264
|
+
sagemaker_info = endpoints.get("sagemaker")
|
|
265
|
+
if not sagemaker_info:
|
|
266
|
+
click.secho(" <no SageMaker endpoint information available>", fg="yellow")
|
|
267
|
+
else:
|
|
268
|
+
ep_rows = [
|
|
269
|
+
("State:", data.get("status", {}).get("endpoints", {}).get("sagemaker", {}).get("state")),
|
|
270
|
+
("Name:", data.get("sageMakerEndpoint", {}).get("name")),
|
|
271
|
+
("ARN:", data.get("status", {}).get("endpoints", {}).get("sagemaker", {}).get("endpointArn")),
|
|
272
|
+
]
|
|
273
|
+
click.echo(tabulate(ep_rows, tablefmt="plain"))
|
|
274
|
+
|
|
275
|
+
click.echo("\nConditions:")
|
|
276
|
+
|
|
277
|
+
status = data.get("status") if isinstance(data, dict) else {}
|
|
278
|
+
status = status or {}
|
|
279
|
+
conds = status.get("conditions", [])
|
|
280
|
+
|
|
281
|
+
if isinstance(conds, list) and conds:
|
|
282
|
+
headers = ["TYPE", "STATUS", "LAST TRANSITION", "LAST UPDATE", "MESSAGE"]
|
|
283
|
+
rows = [
|
|
284
|
+
[
|
|
285
|
+
c.get("type", ""),
|
|
286
|
+
c.get("status", ""),
|
|
287
|
+
c.get("lastTransitionTime", ""),
|
|
288
|
+
c.get("lastUpdateTime", ""),
|
|
289
|
+
c.get("message") or ""
|
|
290
|
+
]
|
|
291
|
+
for c in conds if isinstance(c, dict)
|
|
292
|
+
]
|
|
293
|
+
click.echo(tabulate(rows, headers=headers, tablefmt="github"))
|
|
294
|
+
else:
|
|
295
|
+
click.echo(" <none>")
|
|
296
|
+
|
|
297
|
+
click.echo("\nDeploymentStatus Conditions:")
|
|
298
|
+
|
|
299
|
+
status = data.get("status") if isinstance(data, dict) else {}
|
|
300
|
+
status = status or {}
|
|
301
|
+
|
|
302
|
+
deployment_status = status.get("deploymentStatus") or {}
|
|
303
|
+
dep_status_inner = deployment_status.get("status") or {}
|
|
304
|
+
dep_conds = dep_status_inner.get("conditions") or []
|
|
305
|
+
|
|
306
|
+
if isinstance(dep_conds, list) and dep_conds:
|
|
307
|
+
headers = ["TYPE", "STATUS", "LAST TRANSITION", "LAST UPDATE", "MESSAGE"]
|
|
308
|
+
rows = [
|
|
309
|
+
[
|
|
310
|
+
c.get("type", ""),
|
|
311
|
+
c.get("status", ""),
|
|
312
|
+
c.get("lastTransitionTime", ""),
|
|
313
|
+
c.get("lastUpdateTime", ""),
|
|
314
|
+
c.get("message") or ""
|
|
315
|
+
]
|
|
316
|
+
for c in dep_conds if isinstance(c, dict)
|
|
317
|
+
]
|
|
318
|
+
click.echo(tabulate(rows, headers=headers, tablefmt="github"))
|
|
319
|
+
else:
|
|
320
|
+
click.echo(" <none>")
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
@click.command("hyp-custom-endpoint")
|
|
324
|
+
@click.option(
|
|
325
|
+
"--name",
|
|
326
|
+
type=click.STRING,
|
|
327
|
+
required=True,
|
|
328
|
+
help="Required. The name of the custom model endpoint to describe.",
|
|
329
|
+
)
|
|
330
|
+
@click.option(
|
|
331
|
+
"--namespace",
|
|
332
|
+
type=click.STRING,
|
|
333
|
+
required=False,
|
|
334
|
+
default="default",
|
|
335
|
+
help="Optional. The namespace of the custom model endpoint to describe. Default set to 'default'.",
|
|
336
|
+
)
|
|
337
|
+
@click.option(
|
|
338
|
+
"--full",
|
|
339
|
+
type=click.BOOL,
|
|
340
|
+
is_flag=True,
|
|
341
|
+
default=False,
|
|
342
|
+
required=False,
|
|
343
|
+
help="Optional. If set to `True`, the full json will be displayed",
|
|
344
|
+
)
|
|
345
|
+
def custom_describe(
|
|
346
|
+
name: str,
|
|
347
|
+
namespace: Optional[str],
|
|
348
|
+
full: bool
|
|
349
|
+
):
|
|
350
|
+
"""
|
|
351
|
+
Describe a custom model endpoint with provided name and namespace.
|
|
352
|
+
"""
|
|
353
|
+
|
|
354
|
+
my_endpoint = HPEndpoint.model_construct().get(name, namespace)
|
|
355
|
+
data = my_endpoint.model_dump()
|
|
356
|
+
|
|
357
|
+
if full:
|
|
358
|
+
click.echo("\nFull JSON:")
|
|
359
|
+
click.echo(json.dumps(data, indent=2))
|
|
360
|
+
|
|
361
|
+
else:
|
|
362
|
+
if not isinstance(data, dict):
|
|
363
|
+
click.echo("Invalid data received: expected a dictionary.")
|
|
364
|
+
return
|
|
365
|
+
|
|
366
|
+
# Safe access blocks
|
|
367
|
+
status = data.get("status") or {}
|
|
368
|
+
metadata = data.get("metadata") or {}
|
|
369
|
+
metrics = data.get("metrics") or {}
|
|
370
|
+
model_source = data.get("modelSourceConfig") or {}
|
|
371
|
+
s3_storage = model_source.get("s3Storage") or {}
|
|
372
|
+
fsx_storage = model_source.get("fsxStorage") or {}
|
|
373
|
+
tls = data.get("tlsConfig") or {}
|
|
374
|
+
worker = data.get("worker") or {}
|
|
375
|
+
resources = worker.get("resources") or {}
|
|
376
|
+
volume_mount = worker.get("modelVolumeMount") or {}
|
|
377
|
+
model_port = worker.get("modelInvocationPort") or {}
|
|
378
|
+
cloudwatch = data.get("autoScalingSpec", {}).get("cloudWatchTrigger") or {}
|
|
379
|
+
|
|
380
|
+
summary = [
|
|
381
|
+
("Deployment State:", status.get("deploymentStatus", {}).get("deploymentObjectOverallState", "")),
|
|
382
|
+
("Metadata Name:", metadata.get("name", "")),
|
|
383
|
+
("Namespace:", metadata.get("namespace", "")),
|
|
384
|
+
("Label:", metadata.get("label", "")),
|
|
385
|
+
("Invocation Endpoint", data.get("invocationEndpoint", "")),
|
|
386
|
+
("Instance Type", data.get("instanceType", "")),
|
|
387
|
+
("Metrics Enabled", metrics.get("enabled", "")),
|
|
388
|
+
("Model Name", data.get("modelName", "")),
|
|
389
|
+
("Model Version", data.get("modelVersion", "")),
|
|
390
|
+
("Model Source Type", model_source.get("modelSourceType", "")),
|
|
391
|
+
("Model Location", model_source.get("modelLocation", "")),
|
|
392
|
+
("Prefetch Enabled", model_source.get("prefetchEnabled", "")),
|
|
393
|
+
("TLS Cert S3 URI", tls.get("tlsCertificateOutputS3Uri", "")),
|
|
394
|
+
("FSx DNS Name", fsx_storage.get("dnsName", "")),
|
|
395
|
+
("FSx File System ID", fsx_storage.get("fileSystemId", "")),
|
|
396
|
+
("FSx Mount Name", fsx_storage.get("mountName", "")),
|
|
397
|
+
("S3 Bucket Name", s3_storage.get("bucketName", "")),
|
|
398
|
+
("S3 Region", s3_storage.get("region", "")),
|
|
399
|
+
("Image URI", data.get("imageUri") or worker.get("image", "")),
|
|
400
|
+
("Container Port", data.get("containerPort") or model_port.get("containerPort", "")),
|
|
401
|
+
("Model Volume Mount Path", data.get("modelVolumeMountPath") or volume_mount.get("mountPath", "")),
|
|
402
|
+
("Model Volume Mount Name", data.get("modelVolumeMountName") or volume_mount.get("name", "")),
|
|
403
|
+
("Resources Limits", data.get("resourcesLimits") or resources.get("limits", "")),
|
|
404
|
+
("Resources Requests", data.get("resourcesRequests") or resources.get("requests", "")),
|
|
405
|
+
("Dimensions", data.get("dimensions") or cloudwatch.get("dimensions", "")),
|
|
406
|
+
("Metric Collection Period", data.get("metricCollectionPeriod") or cloudwatch.get("metricCollectionPeriod", "")),
|
|
407
|
+
("Metric Collection Start Time",data.get("metricCollectionStartTime") or cloudwatch.get("metricCollectionStartTime", "")),
|
|
408
|
+
("Metric Name", data.get("metricName") or cloudwatch.get("metricName", "")),
|
|
409
|
+
("Metric Stat", data.get("metricStat") or cloudwatch.get("metricStat", "")),
|
|
410
|
+
("Metric Type", data.get("metricType") or cloudwatch.get("metricType", "")),
|
|
411
|
+
("Min Value", data.get("minValue") or cloudwatch.get("minValue", "")),
|
|
412
|
+
("CW Trigger Name", data.get("cloudWatchTriggerName") or cloudwatch.get("name", "")),
|
|
413
|
+
("CW Trigger Namespace", data.get("cloudWatchTriggerNamespace") or cloudwatch.get("namespace", "")),
|
|
414
|
+
("Target Value", data.get("targetValue") or cloudwatch.get("targetValue", "")),
|
|
415
|
+
("Use Cached Metrics", data.get("useCachedMetrics") or cloudwatch.get("useCachedMetrics", "")),
|
|
416
|
+
]
|
|
417
|
+
|
|
418
|
+
click.echo(tabulate(summary, tablefmt="plain"))
|
|
419
|
+
|
|
420
|
+
click.echo("\nSageMaker Endpoint:")
|
|
421
|
+
sm_endpoints = status.get("endpoints") or {}
|
|
422
|
+
sagemaker_info = sm_endpoints.get("sagemaker")
|
|
423
|
+
if not sagemaker_info:
|
|
424
|
+
click.secho(" <no SageMaker endpoint information available>", fg="yellow")
|
|
425
|
+
else:
|
|
426
|
+
ep_rows = [
|
|
427
|
+
("State:", sm_endpoints.get("sagemaker", {}).get("state", "")),
|
|
428
|
+
("Name:", data.get("sageMakerEndpoint", {}).get("name", "")),
|
|
429
|
+
("ARN:", sm_endpoints.get("sagemaker", {}).get("endpointArn", "")),
|
|
430
|
+
]
|
|
431
|
+
click.echo(tabulate(ep_rows, tablefmt="plain"))
|
|
432
|
+
|
|
433
|
+
click.echo("\nConditions:")
|
|
434
|
+
conds = status.get("conditions", [])
|
|
435
|
+
if isinstance(conds, list) and conds:
|
|
436
|
+
headers = ["TYPE", "STATUS", "LAST TRANSITION", "LAST UPDATE", "MESSAGE"]
|
|
437
|
+
rows = [
|
|
438
|
+
[
|
|
439
|
+
c.get("type", ""),
|
|
440
|
+
c.get("status", ""),
|
|
441
|
+
c.get("lastTransitionTime", ""),
|
|
442
|
+
c.get("lastUpdateTime", ""),
|
|
443
|
+
c.get("message") or ""
|
|
444
|
+
]
|
|
445
|
+
for c in conds if isinstance(c, dict)
|
|
446
|
+
]
|
|
447
|
+
click.echo(tabulate(rows, headers=headers, tablefmt="github"))
|
|
448
|
+
else:
|
|
449
|
+
click.echo(" <none>")
|
|
450
|
+
|
|
451
|
+
click.echo("\nDeploymentStatus Conditions:")
|
|
452
|
+
deployment_status = status.get("deploymentStatus") or {}
|
|
453
|
+
dep_status_inner = deployment_status.get("status") or {}
|
|
454
|
+
dep_conds = dep_status_inner.get("conditions") or []
|
|
455
|
+
if isinstance(dep_conds, list) and dep_conds:
|
|
456
|
+
headers = ["TYPE", "STATUS", "LAST TRANSITION", "LAST UPDATE", "MESSAGE"]
|
|
457
|
+
rows = [
|
|
458
|
+
[
|
|
459
|
+
c.get("type", ""),
|
|
460
|
+
c.get("status", ""),
|
|
461
|
+
c.get("lastTransitionTime", ""),
|
|
462
|
+
c.get("lastUpdateTime", ""),
|
|
463
|
+
c.get("message") or ""
|
|
464
|
+
]
|
|
465
|
+
for c in dep_conds if isinstance(c, dict)
|
|
466
|
+
]
|
|
467
|
+
click.echo(tabulate(rows, headers=headers, tablefmt="github"))
|
|
468
|
+
else:
|
|
469
|
+
click.echo(" <none>")
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
@click.command("hyp-jumpstart-endpoint")
|
|
473
|
+
@click.option(
|
|
474
|
+
"--name",
|
|
475
|
+
type=click.STRING,
|
|
476
|
+
required=True,
|
|
477
|
+
help="Required. The name of the jumpstart model endpoint to delete.",
|
|
478
|
+
)
|
|
479
|
+
@click.option(
|
|
480
|
+
"--namespace",
|
|
481
|
+
type=click.STRING,
|
|
482
|
+
required=False,
|
|
483
|
+
default="default",
|
|
484
|
+
help="Optional. The namespace of the jumpstart model endpoint to delete. Default set to 'default'.",
|
|
485
|
+
)
|
|
486
|
+
def js_delete(
|
|
487
|
+
name: str,
|
|
488
|
+
namespace: Optional[str],
|
|
489
|
+
):
|
|
490
|
+
"""
|
|
491
|
+
Delete a jumpstart model endpoint with provided name and namespace.
|
|
492
|
+
"""
|
|
493
|
+
my_endpoint = HPJumpStartEndpoint.model_construct().get(name, namespace)
|
|
494
|
+
my_endpoint.delete()
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
@click.command("hyp-custom-endpoint")
|
|
498
|
+
@click.option(
|
|
499
|
+
"--name",
|
|
500
|
+
type=click.STRING,
|
|
501
|
+
required=True,
|
|
502
|
+
help="Required. The names of the custom model endpoint to delete.",
|
|
503
|
+
)
|
|
504
|
+
@click.option(
|
|
505
|
+
"--namespace",
|
|
506
|
+
type=click.STRING,
|
|
507
|
+
required=False,
|
|
508
|
+
default="default",
|
|
509
|
+
help="Optional. The namespace of the custom model endpoint to delete. Default set to 'default'.",
|
|
510
|
+
)
|
|
511
|
+
def custom_delete(
|
|
512
|
+
name: str,
|
|
513
|
+
namespace: Optional[str],
|
|
514
|
+
):
|
|
515
|
+
"""
|
|
516
|
+
Delete a custom model endpoint with provided name and namespace.
|
|
517
|
+
"""
|
|
518
|
+
my_endpoint = HPEndpoint.model_construct().get(name, namespace)
|
|
519
|
+
my_endpoint.delete()
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
@click.command("hyp-jumpstart-endpoint")
|
|
523
|
+
@click.option(
|
|
524
|
+
"--namespace",
|
|
525
|
+
type=click.STRING,
|
|
526
|
+
required=False,
|
|
527
|
+
default="default",
|
|
528
|
+
help="Optional. The namespace of the jumpstart model to list pods for. Default set to 'default'.",
|
|
529
|
+
)
|
|
530
|
+
def js_list_pods(
|
|
531
|
+
namespace: Optional[str],
|
|
532
|
+
):
|
|
533
|
+
"""
|
|
534
|
+
Get specific pod log for jumpstart model endpoint.
|
|
535
|
+
"""
|
|
536
|
+
my_endpoint = HPJumpStartEndpoint.model_construct()
|
|
537
|
+
pods = my_endpoint.list_pods(namespace=namespace)
|
|
538
|
+
click.echo(pods)
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
@click.command("hyp-custom-endpoint")
|
|
542
|
+
@click.option(
|
|
543
|
+
"--namespace",
|
|
544
|
+
type=click.STRING,
|
|
545
|
+
required=False,
|
|
546
|
+
default="default",
|
|
547
|
+
help="Optional. The namespace of the custom model to list pods for. Default set to 'default'.",
|
|
548
|
+
)
|
|
549
|
+
def custom_list_pods(
|
|
550
|
+
namespace: Optional[str],
|
|
551
|
+
):
|
|
552
|
+
"""
|
|
553
|
+
Get specific pod log for custom model endpoint.
|
|
554
|
+
"""
|
|
555
|
+
my_endpoint = HPEndpoint.model_construct()
|
|
556
|
+
pods = my_endpoint.list_pods(namespace=namespace)
|
|
557
|
+
click.echo(pods)
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
@click.command("hyp-jumpstart-endpoint")
|
|
561
|
+
@click.option(
|
|
562
|
+
"--pod-name",
|
|
563
|
+
type=click.STRING,
|
|
564
|
+
required=True,
|
|
565
|
+
help="Required. The pod name to get logs for.",
|
|
566
|
+
)
|
|
567
|
+
@click.option(
|
|
568
|
+
"--container",
|
|
569
|
+
type=click.STRING,
|
|
570
|
+
required=False,
|
|
571
|
+
help="Optional. The container name to get logs for.",
|
|
572
|
+
)
|
|
573
|
+
@click.option(
|
|
574
|
+
"--namespace",
|
|
575
|
+
type=click.STRING,
|
|
576
|
+
required=False,
|
|
577
|
+
default="default",
|
|
578
|
+
help="Optional. The namespace of the jumpstart model to get logs for. Default set to 'default'.",
|
|
579
|
+
)
|
|
580
|
+
def js_get_logs(
|
|
581
|
+
pod_name: str,
|
|
582
|
+
container: Optional[str],
|
|
583
|
+
namespace: Optional[str],
|
|
584
|
+
):
|
|
585
|
+
"""
|
|
586
|
+
Get specific pod log for jumpstart model endpoint.
|
|
587
|
+
"""
|
|
588
|
+
my_endpoint = HPJumpStartEndpoint.model_construct()
|
|
589
|
+
logs = my_endpoint.get_logs(pod=pod_name, container=container, namespace=namespace)
|
|
590
|
+
click.echo(logs)
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
@click.command("hyp-custom-endpoint")
|
|
594
|
+
@click.option(
|
|
595
|
+
"--pod-name",
|
|
596
|
+
type=click.STRING,
|
|
597
|
+
required=True,
|
|
598
|
+
help="Required. The pod name to get logs for.",
|
|
599
|
+
)
|
|
600
|
+
@click.option(
|
|
601
|
+
"--container",
|
|
602
|
+
type=click.STRING,
|
|
603
|
+
required=False,
|
|
604
|
+
help="Optional. The container name to get logs for.",
|
|
605
|
+
)
|
|
606
|
+
@click.option(
|
|
607
|
+
"--namespace",
|
|
608
|
+
type=click.STRING,
|
|
609
|
+
required=False,
|
|
610
|
+
default="default",
|
|
611
|
+
help="Optional. The namespace of the custom model to get logs for. Default set to 'default'.",
|
|
612
|
+
)
|
|
613
|
+
def custom_get_logs(
|
|
614
|
+
pod_name: str,
|
|
615
|
+
container: Optional[str],
|
|
616
|
+
namespace: Optional[str],
|
|
617
|
+
):
|
|
618
|
+
"""
|
|
619
|
+
Get specific pod log for custom model endpoint.
|
|
620
|
+
"""
|
|
621
|
+
my_endpoint = HPEndpoint.model_construct()
|
|
622
|
+
logs = my_endpoint.get_logs(pod=pod_name, container=container, namespace=namespace)
|
|
623
|
+
click.echo(logs)
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
@click.command("hyp-jumpstart-endpoint")
|
|
627
|
+
@click.option(
|
|
628
|
+
"--since-hours",
|
|
629
|
+
type=click.FLOAT,
|
|
630
|
+
required=True,
|
|
631
|
+
help="Required. The time frame to get logs for.",
|
|
632
|
+
)
|
|
633
|
+
def js_get_operator_logs(
|
|
634
|
+
since_hours: float,
|
|
635
|
+
):
|
|
636
|
+
"""
|
|
637
|
+
Get operator logs for jumpstart model endpoint in the set time frame.
|
|
638
|
+
"""
|
|
639
|
+
my_endpoint = HPJumpStartEndpoint.model_construct()
|
|
640
|
+
logs = my_endpoint.get_operator_logs(since_hours=since_hours)
|
|
641
|
+
click.echo(logs)
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
@click.command("hyp-custom-endpoint")
|
|
645
|
+
@click.option(
|
|
646
|
+
"--since-hours",
|
|
647
|
+
type=click.FLOAT,
|
|
648
|
+
required=True,
|
|
649
|
+
help="Required. The time frame get logs for.",
|
|
650
|
+
)
|
|
651
|
+
def custom_get_operator_logs(
|
|
652
|
+
since_hours: float,
|
|
653
|
+
):
|
|
654
|
+
"""
|
|
655
|
+
Get operator logs for custom model endpoint in the set time frame.
|
|
656
|
+
"""
|
|
657
|
+
my_endpoint = HPEndpoint.model_construct()
|
|
658
|
+
logs = my_endpoint.get_operator_logs(since_hours=since_hours)
|
|
659
|
+
click.echo(logs)
|