1414 _hyperpod_telemetry_emitter ,
1515)
1616from sagemaker .hyperpod .common .telemetry .constants import Feature
17+ from sagemaker .hyperpod .common .cli_decorators import handle_cli_exceptions , smart_cli_exception_handler
1718
1819
1920# CREATE
@@ -236,6 +237,7 @@ def custom_list(
236237 help = "Optional. If set to `True`, the full json will be displayed" ,
237238)
238239@_hyperpod_telemetry_emitter (Feature .HYPERPOD_CLI , "get_js_endpoint_cli" )
240+ @handle_cli_exceptions
239241def js_describe (
240242 name : str ,
241243 namespace : Optional [str ],
@@ -244,13 +246,8 @@ def js_describe(
244246 """
245247 Describe a Hyperpod Jumpstart model endpoint.
246248 """
247- try :
248- my_endpoint = HPJumpStartEndpoint .model_construct ().get (name , namespace )
249- data = my_endpoint .model_dump ()
250- except Exception as e :
251- click .echo (str (e ))
252- import sys
253- sys .exit (1 )
249+ my_endpoint = HPJumpStartEndpoint .model_construct ().get (name , namespace )
250+ data = my_endpoint .model_dump ()
254251
255252 if full :
256253 click .echo ("\n Full JSON:" )
@@ -389,6 +386,7 @@ def js_describe(
389386 help = "Optional. If set to `True`, the full json will be displayed" ,
390387)
391388@_hyperpod_telemetry_emitter (Feature .HYPERPOD_CLI , "get_custom_endpoint_cli" )
389+ @handle_cli_exceptions
392390def custom_describe (
393391 name : str ,
394392 namespace : Optional [str ],
@@ -397,13 +395,8 @@ def custom_describe(
397395 """
398396 Describe a Hyperpod custom model endpoint.
399397 """
400- try :
401- my_endpoint = HPEndpoint .model_construct ().get (name , namespace )
402- data = my_endpoint .model_dump ()
403- except Exception as e :
404- click .echo (str (e ))
405- import sys
406- sys .exit (1 )
398+ my_endpoint = HPEndpoint .model_construct ().get (name , namespace )
399+ data = my_endpoint .model_dump ()
407400
408401 if full :
409402 click .echo ("\n Full JSON:" )
@@ -568,20 +561,18 @@ def custom_describe(
568561 help = "Optional. The namespace of the jumpstart model endpoint to delete. Default set to 'default'." ,
569562)
570563@_hyperpod_telemetry_emitter (Feature .HYPERPOD_CLI , "delete_js_endpoint_cli" )
564+ @smart_cli_exception_handler
571565def js_delete (
572566 name : str ,
573567 namespace : Optional [str ],
574568):
575569 """
576570 Delete a Hyperpod Jumpstart model endpoint.
577571 """
578- try :
579- my_endpoint = HPJumpStartEndpoint .model_construct ().get (name , namespace )
580- my_endpoint .delete ()
581- except Exception as e :
582- click .echo (str (e ))
583- import sys
584- sys .exit (1 )
572+ # Auto-detects the endpoint type and operation
573+ # 0Provides 404 message: "❓ JumpStart endpoint 'missing-name' not found..."
574+ my_endpoint = HPJumpStartEndpoint .model_construct ().get (name , namespace )
575+ my_endpoint .delete ()
585576
586577
587578@click .command ("hyp-custom-endpoint" )
@@ -599,20 +590,16 @@ def js_delete(
599590 help = "Optional. The namespace of the custom model endpoint to delete. Default set to 'default'." ,
600591)
601592@_hyperpod_telemetry_emitter (Feature .HYPERPOD_CLI , "delete_custom_endpoint_cli" )
593+ @handle_cli_exceptions
602594def custom_delete (
603595 name : str ,
604596 namespace : Optional [str ],
605597):
606598 """
607599 Delete a Hyperpod custom model endpoint.
608600 """
609- try :
610- my_endpoint = HPEndpoint .model_construct ().get (name , namespace )
611- my_endpoint .delete ()
612- except Exception as e :
613- click .echo (str (e ))
614- import sys
615- sys .exit (1 )
601+ my_endpoint = HPEndpoint .model_construct ().get (name , namespace )
602+ my_endpoint .delete ()
616603
617604
618605@click .command ("hyp-jumpstart-endpoint" )
@@ -624,20 +611,16 @@ def custom_delete(
624611 help = "Optional. The namespace of the jumpstart model to list pods for. Default set to 'default'." ,
625612)
626613@_hyperpod_telemetry_emitter (Feature .HYPERPOD_CLI , "list_pods_js_endpoint_cli" )
614+ @handle_cli_exceptions
627615def js_list_pods (
628616 namespace : Optional [str ],
629617):
630618 """
631619 List all pods related to jumpstart model endpoint.
632620 """
633- try :
634- my_endpoint = HPJumpStartEndpoint .model_construct ()
635- pods = my_endpoint .list_pods (namespace = namespace )
636- click .echo (pods )
637- except Exception as e :
638- click .echo (str (e ))
639- import sys
640- sys .exit (1 )
621+ my_endpoint = HPJumpStartEndpoint .model_construct ()
622+ pods = my_endpoint .list_pods (namespace = namespace )
623+ click .echo (pods )
641624
642625
643626@click .command ("hyp-custom-endpoint" )
@@ -649,20 +632,16 @@ def js_list_pods(
649632 help = "Optional. The namespace of the custom model to list pods for. Default set to 'default'." ,
650633)
651634@_hyperpod_telemetry_emitter (Feature .HYPERPOD_CLI , "list_pods_custom_endpoint_cli" )
635+ @handle_cli_exceptions
652636def custom_list_pods (
653637 namespace : Optional [str ],
654638):
655639 """
656640 List all pods related to custom model endpoint.
657641 """
658- try :
659- my_endpoint = HPEndpoint .model_construct ()
660- pods = my_endpoint .list_pods (namespace = namespace )
661- click .echo (pods )
662- except Exception as e :
663- click .echo (str (e ))
664- import sys
665- sys .exit (1 )
642+ my_endpoint = HPEndpoint .model_construct ()
643+ pods = my_endpoint .list_pods (namespace = namespace )
644+ click .echo (pods )
666645
667646
668647@click .command ("hyp-jumpstart-endpoint" )
@@ -686,6 +665,7 @@ def custom_list_pods(
686665 help = "Optional. The namespace of the jumpstart model to get logs for. Default set to 'default'." ,
687666)
688667@_hyperpod_telemetry_emitter (Feature .HYPERPOD_CLI , "get_logs_js_endpoint" )
668+ @handle_cli_exceptions
689669def js_get_logs (
690670 pod_name : str ,
691671 container : Optional [str ],
@@ -694,14 +674,9 @@ def js_get_logs(
694674 """
695675 Get specific pod log for jumpstart model endpoint.
696676 """
697- try :
698- my_endpoint = HPJumpStartEndpoint .model_construct ()
699- logs = my_endpoint .get_logs (pod = pod_name , container = container , namespace = namespace )
700- click .echo (logs )
701- except Exception as e :
702- click .echo (str (e ))
703- import sys
704- sys .exit (1 )
677+ my_endpoint = HPJumpStartEndpoint .model_construct ()
678+ logs = my_endpoint .get_logs (pod = pod_name , container = container , namespace = namespace )
679+ click .echo (logs )
705680
706681
707682@click .command ("hyp-custom-endpoint" )
@@ -725,6 +700,7 @@ def js_get_logs(
725700 help = "Optional. The namespace of the custom model to get logs for. Default set to 'default'." ,
726701)
727702@_hyperpod_telemetry_emitter (Feature .HYPERPOD_CLI , "get_logs_custom_endpoint" )
703+ @handle_cli_exceptions
728704def custom_get_logs (
729705 pod_name : str ,
730706 container : Optional [str ],
@@ -733,14 +709,9 @@ def custom_get_logs(
733709 """
734710 Get specific pod log for custom model endpoint.
735711 """
736- try :
737- my_endpoint = HPEndpoint .model_construct ()
738- logs = my_endpoint .get_logs (pod = pod_name , container = container , namespace = namespace )
739- click .echo (logs )
740- except Exception as e :
741- click .echo (str (e ))
742- import sys
743- sys .exit (1 )
712+ my_endpoint = HPEndpoint .model_construct ()
713+ logs = my_endpoint .get_logs (pod = pod_name , container = container , namespace = namespace )
714+ click .echo (logs )
744715
745716
746717@click .command ("hyp-jumpstart-endpoint" )
0 commit comments