Skip to content

Commit 8a3dfdc

Browse files
author
Mohamed Zeidan
committed
integrated new pytorch get-operator-logs
1 parent 58325b4 commit 8a3dfdc

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def pytorch_describe(job_name: str, namespace: str):
149149
job = HyperPodPytorchJob.get(name=job_name, namespace=namespace)
150150

151151
if job is None:
152-
raise click.UsageError(f"Job {job_name} not found in namespace {namespace}")
152+
raise Exception(f"Job {job_name} not found in namespace {namespace}")
153153

154154
# Print basic info
155155
click.echo("\nJob Details:")
@@ -316,4 +316,21 @@ def pytorch_get_logs(job_name: str, pod_name: str, namespace: str):
316316
logs = job.get_logs_from_pod(pod_name=pod_name)
317317

318318
# Use common log display utility for consistent formatting across all job types
319-
display_formatted_logs(logs, title=f"Pod Logs for {pod_name}")
319+
display_formatted_logs(logs, title=f"Pod Logs for {pod_name}")
320+
321+
322+
@click.command("hyp-pytorch-job")
323+
@click.option(
324+
"--since-hours",
325+
type=click.FLOAT,
326+
required=True,
327+
help="Required. The time frame to get logs for.",
328+
)
329+
@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "get_pytorch_operator_logs")
330+
@handle_cli_exceptions()
331+
def pytorch_get_operator_logs(since_hours: float):
332+
"""Get operator logs for pytorch training jobs."""
333+
logs = HyperPodPytorchJob.get_operator_logs(since_hours=since_hours)
334+
335+
# Use common log display utility for consistent formatting across all job types
336+
display_formatted_logs(logs, title="PyTorch Operator Logs")

0 commit comments

Comments
 (0)