Skip to content

Commit dc119db

Browse files
author
Mohamed Zeidan
committed
more error handling
1 parent b8d71a0 commit dc119db

File tree

1 file changed

+32
-12
lines changed

1 file changed

+32
-12
lines changed

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

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -630,9 +630,14 @@ def js_list_pods(
630630
"""
631631
List all pods related to jumpstart model endpoint.
632632
"""
633-
my_endpoint = HPJumpStartEndpoint.model_construct()
634-
pods = my_endpoint.list_pods(namespace=namespace)
635-
click.echo(pods)
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)
636641

637642

638643
@click.command("hyp-custom-endpoint")
@@ -650,9 +655,14 @@ def custom_list_pods(
650655
"""
651656
List all pods related to custom model endpoint.
652657
"""
653-
my_endpoint = HPEndpoint.model_construct()
654-
pods = my_endpoint.list_pods(namespace=namespace)
655-
click.echo(pods)
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)
656666

657667

658668
@click.command("hyp-jumpstart-endpoint")
@@ -684,9 +694,14 @@ def js_get_logs(
684694
"""
685695
Get specific pod log for jumpstart model endpoint.
686696
"""
687-
my_endpoint = HPJumpStartEndpoint.model_construct()
688-
logs = my_endpoint.get_logs(pod=pod_name, container=container, namespace=namespace)
689-
click.echo(logs)
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)
690705

691706

692707
@click.command("hyp-custom-endpoint")
@@ -718,9 +733,14 @@ def custom_get_logs(
718733
"""
719734
Get specific pod log for custom model endpoint.
720735
"""
721-
my_endpoint = HPEndpoint.model_construct()
722-
logs = my_endpoint.get_logs(pod=pod_name, container=container, namespace=namespace)
723-
click.echo(logs)
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)
724744

725745

726746
@click.command("hyp-jumpstart-endpoint")

0 commit comments

Comments
 (0)