Skip to content

Commit e3fafe0

Browse files
rsareddy0329Roja Reddy Sareddy
andauthored
Enable telemetry for cli (#165)
* Enable Hyperpod telemetry * Enable Hyperpod telemetry * Enable Hyperpod telemetry * Enable Hyperpod telemetry * Enable Hyperpod telemetry * Enable Hyperpod telemetry * CLI: Enable Telemetry * CLI: Enable Telemetry --------- Co-authored-by: Roja Reddy Sareddy <[email protected]>
1 parent d2130e9 commit e3fafe0

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

src/sagemaker/hyperpod/cli/commands/inference.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
from sagemaker.hyperpod.inference.hp_jumpstart_endpoint import HPJumpStartEndpoint
1111
from sagemaker.hyperpod.inference.hp_endpoint import HPEndpoint
1212
from sagemaker_core.resources import Endpoint
13+
from sagemaker.hyperpod.common.telemetry.telemetry_logging import (
14+
_hyperpod_telemetry_emitter,
15+
)
16+
from sagemaker.hyperpod.common.telemetry.constants import Feature
1317

1418

1519
# CREATE
@@ -26,6 +30,7 @@
2630
schema_pkg="hyperpod_jumpstart_inference_template",
2731
registry=JS_REG,
2832
)
33+
@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "create_js_endpoint_cli")
2934
def js_create(namespace, version, js_endpoint):
3035
"""
3136
Create a jumpstart model endpoint.
@@ -47,6 +52,7 @@ def js_create(namespace, version, js_endpoint):
4752
schema_pkg="hyperpod_custom_inference_template",
4853
registry=C_REG,
4954
)
55+
@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "create_custom_endpoint_cli")
5056
def custom_create(namespace, version, custom_endpoint):
5157
"""
5258
Create a custom model endpoint.
@@ -76,6 +82,7 @@ def custom_create(namespace, version, custom_endpoint):
7682
default="application/json",
7783
help="Optional. The content type of the request to invoke. Default set to 'application/json'",
7884
)
85+
@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "invoke_custom_endpoint_cli")
7986
def custom_invoke(
8087
endpoint_name: str,
8188
body: str,
@@ -128,6 +135,7 @@ def custom_invoke(
128135
default="default",
129136
help="Optional. The namespace of the jumpstart model endpoint to list. Default set to 'default'",
130137
)
138+
@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "list_js_endpoints_cli")
131139
def js_list(
132140
namespace: Optional[str],
133141
):
@@ -170,6 +178,7 @@ def js_list(
170178
default="default",
171179
help="Optional. The namespace of the custom model endpoint to list. Default set to 'default'",
172180
)
181+
@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "list_custom_endpoints_cli")
173182
def custom_list(
174183
namespace: Optional[str],
175184
):
@@ -226,6 +235,7 @@ def custom_list(
226235
required=False,
227236
help="Optional. If set to `True`, the full json will be displayed",
228237
)
238+
@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "get_js_endpoint_cli")
229239
def js_describe(
230240
name: str,
231241
namespace: Optional[str],
@@ -374,6 +384,7 @@ def js_describe(
374384
required=False,
375385
help="Optional. If set to `True`, the full json will be displayed",
376386
)
387+
@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "get_custom_endpoint_cli")
377388
def custom_describe(
378389
name: str,
379390
namespace: Optional[str],
@@ -548,6 +559,7 @@ def custom_describe(
548559
default="default",
549560
help="Optional. The namespace of the jumpstart model endpoint to delete. Default set to 'default'.",
550561
)
562+
@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "delete_js_endpoint_cli")
551563
def js_delete(
552564
name: str,
553565
namespace: Optional[str],
@@ -573,6 +585,7 @@ def js_delete(
573585
default="default",
574586
help="Optional. The namespace of the custom model endpoint to delete. Default set to 'default'.",
575587
)
588+
@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "delete_custom_endpoint_cli")
576589
def custom_delete(
577590
name: str,
578591
namespace: Optional[str],
@@ -592,6 +605,7 @@ def custom_delete(
592605
default="default",
593606
help="Optional. The namespace of the jumpstart model to list pods for. Default set to 'default'.",
594607
)
608+
@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "list_pods_js_endpoint_cli")
595609
def js_list_pods(
596610
namespace: Optional[str],
597611
):
@@ -611,6 +625,7 @@ def js_list_pods(
611625
default="default",
612626
help="Optional. The namespace of the custom model to list pods for. Default set to 'default'.",
613627
)
628+
@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "list_pods_custom_endpoint_cli")
614629
def custom_list_pods(
615630
namespace: Optional[str],
616631
):
@@ -642,6 +657,7 @@ def custom_list_pods(
642657
default="default",
643658
help="Optional. The namespace of the jumpstart model to get logs for. Default set to 'default'.",
644659
)
660+
@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "get_logs_js_endpoint")
645661
def js_get_logs(
646662
pod_name: str,
647663
container: Optional[str],
@@ -675,6 +691,7 @@ def js_get_logs(
675691
default="default",
676692
help="Optional. The namespace of the custom model to get logs for. Default set to 'default'.",
677693
)
694+
@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "get_logs_custom_endpoint")
678695
def custom_get_logs(
679696
pod_name: str,
680697
container: Optional[str],
@@ -695,6 +712,7 @@ def custom_get_logs(
695712
required=True,
696713
help="Required. The time frame to get logs for.",
697714
)
715+
@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "get_js_operator_logs")
698716
def js_get_operator_logs(
699717
since_hours: float,
700718
):
@@ -713,6 +731,7 @@ def js_get_operator_logs(
713731
required=True,
714732
help="Required. The time frame get logs for.",
715733
)
734+
@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "get_custom_operator_logs")
716735
def custom_get_operator_logs(
717736
since_hours: float,
718737
):

src/sagemaker/hyperpod/cli/commands/training.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
from sagemaker.hyperpod.cli.training_utils import generate_click_command
1313
from importlib.metadata import entry_points
1414
from hyperpod_pytorch_job_template.registry import SCHEMA_REGISTRY
15+
from sagemaker.hyperpod.common.telemetry.telemetry_logging import (
16+
_hyperpod_telemetry_emitter,
17+
)
18+
from sagemaker.hyperpod.common.telemetry.constants import Feature
1519

1620

1721
@click.command("hyp-pytorch-job")
@@ -21,6 +25,7 @@
2125
schema_pkg="hyperpod_pytorch_job_template",
2226
registry=SCHEMA_REGISTRY,
2327
)
28+
@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "create_pytorchjob_cli")
2429
def pytorch_create(version, debug, config):
2530
"""Create a PyTorch job."""
2631
try:
@@ -63,6 +68,7 @@ def pytorch_create(version, debug, config):
6368
default="default",
6469
help="Optional. The namespace to list jobs from. Defaults to 'default' namespace.",
6570
)
71+
@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "list_pytorchjobs_cli")
6672
def list_jobs(namespace: str):
6773
"""List all HyperPod PyTorch jobs."""
6874
try:
@@ -143,6 +149,7 @@ def list_jobs(namespace: str):
143149
default="default",
144150
help="Optional. The namespace of the job. Defaults to 'default' namespace.",
145151
)
152+
@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "get_pytorchjob_cli")
146153
def pytorch_describe(job_name: str, namespace: str):
147154
"""Describe a HyperPod PyTorch job."""
148155
try:
@@ -244,6 +251,7 @@ def pytorch_describe(job_name: str, namespace: str):
244251
default="default",
245252
help="Optional. The namespace of the job. Defaults to 'default' namespace.",
246253
)
254+
@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "delete_pytorchjob_cli")
247255
def pytorch_delete(job_name: str, namespace: str):
248256
"""Delete a HyperPod PyTorch job."""
249257
try:
@@ -269,6 +277,7 @@ def pytorch_delete(job_name: str, namespace: str):
269277
default="default",
270278
help="Optional. The namespace of the job. Defaults to 'default' namespace.",
271279
)
280+
@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "list_pods_pytorchjob_cli")
272281
def pytorch_list_pods(job_name: str, namespace: str):
273282
"""List all HyperPod PyTorch pods related to the job."""
274283
try:
@@ -315,6 +324,7 @@ def pytorch_list_pods(job_name: str, namespace: str):
315324
default="default",
316325
help="Optional. The namespace of the job. Defaults to 'default' namespace.",
317326
)
327+
@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "get_pytorchjob_logs_from_pod_cli")
318328
def pytorch_get_logs(job_name: str, pod_name: str, namespace: str):
319329
"""Get specific pod log for Hyperpod Pytorch job."""
320330
try:

src/sagemaker/hyperpod/common/telemetry/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class Feature(Enum):
66
"""Enumeration of feature names used in telemetry."""
77

88
HYPERPOD = 6 # Added to support telemetry in sagemaker-hyperpod-cli
9+
HYPERPOD_CLI = 7
910

1011
def __str__(self): # pylint: disable=E0307
1112
"""Return the feature name."""

src/sagemaker/hyperpod/common/telemetry/telemetry_logging.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
FEATURE_TO_CODE = {
2626
str(Feature.HYPERPOD): 6, # Added to support telemetry in sagemaker-hyperpod-cli
27+
str(Feature.HYPERPOD_CLI): 7,
2728
}
2829

2930
STATUS_TO_CODE = {

0 commit comments

Comments
 (0)