Skip to content

Commit b8b9739

Browse files
committed
feat(RHOAIENG-26487): Cluster lifecycling via RayJob
Signed-off-by: Pat O'Connor <[email protected]>
1 parent 7979429 commit b8b9739

File tree

6 files changed

+551
-190
lines changed

6 files changed

+551
-190
lines changed

src/codeflare_sdk/ray/rayjobs/pretty_print.py

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,23 @@ def print_job_status(job_info: RayJobInfo):
3030
Pretty print the job status in a format similar to cluster status.
3131
"""
3232
status_display, header_color = _get_status_display(job_info.status)
33-
33+
3434
# Create main info table
3535
table = _create_info_table(header_color, job_info.name, status_display)
3636
table.add_row(f"[bold]Job ID:[/bold] {job_info.job_id}")
3737
table.add_row(f"[bold]Status:[/bold] {job_info.status.value}")
3838
table.add_row(f"[bold]RayCluster:[/bold] {job_info.cluster_name}")
3939
table.add_row(f"[bold]Namespace:[/bold] {job_info.namespace}")
40-
40+
4141
# Add timing information if available
4242
if job_info.start_time:
43+
table.add_row()
4344
table.add_row(f"[bold]Started:[/bold] {job_info.start_time}")
44-
45+
4546
# Add attempt counts if there are failures
4647
if job_info.failed_attempts > 0:
4748
table.add_row(f"[bold]Failed Attempts:[/bold] {job_info.failed_attempts}")
48-
49+
4950
_print_table_in_panel(table)
5051

5152

@@ -54,36 +55,46 @@ def print_no_job_found(job_name: str, namespace: str):
5455
Print a message when no job is found.
5556
"""
5657
# Create table with error message
57-
table = _create_info_table("[white on red][bold]Name", job_name, "[bold red]No RayJob found")
58+
table = _create_info_table(
59+
"[white on red][bold]Name", job_name, "[bold red]No RayJob found"
60+
)
5861
table.add_row()
5962
table.add_row("Have you run rayjob.submit() yet?")
6063
table.add_row()
6164
table.add_row(f"[bold]Namespace:[/bold] {namespace}")
62-
65+
6366
_print_table_in_panel(table)
6467

6568

6669
def _get_status_display(status: RayJobDeploymentStatus) -> Tuple[str, str]:
6770
"""
6871
Get the display string and header color for a given status.
69-
72+
7073
Returns:
7174
Tuple of (status_display, header_color)
7275
"""
7376
status_mapping = {
74-
RayJobDeploymentStatus.COMPLETE: ("Complete :white_heavy_check_mark:", "[white on green][bold]Name"),
77+
RayJobDeploymentStatus.COMPLETE: (
78+
"Complete :white_heavy_check_mark:",
79+
"[white on green][bold]Name",
80+
),
7581
RayJobDeploymentStatus.RUNNING: ("Running :gear:", "[white on blue][bold]Name"),
7682
RayJobDeploymentStatus.FAILED: ("Failed :x:", "[white on red][bold]Name"),
77-
RayJobDeploymentStatus.SUSPENDED: ("Suspended :pause_button:", "[white on yellow][bold]Name"),
83+
RayJobDeploymentStatus.SUSPENDED: (
84+
"Suspended :pause_button:",
85+
"[white on yellow][bold]Name",
86+
),
7887
}
79-
80-
return status_mapping.get(status, ("Unknown :question:", "[white on red][bold]Name"))
88+
89+
return status_mapping.get(
90+
status, ("Unknown :question:", "[white on red][bold]Name")
91+
)
8192

8293

8394
def _create_info_table(header_color: str, name: str, status_display: str) -> Table:
8495
"""
8596
Create a standardized info table with header and status.
86-
97+
8798
Returns:
8899
Table with header row, name/status row, and empty separator row
89100
"""
@@ -99,6 +110,8 @@ def _print_table_in_panel(table: Table):
99110
Print a table wrapped in a consistent panel format.
100111
"""
101112
console = Console()
102-
main_table = Table(box=None, title="[bold] :package: CodeFlare RayJob Status :package:")
113+
main_table = Table(
114+
box=None, title="[bold] :package: CodeFlare RayJob Status :package:"
115+
)
103116
main_table.add_row(Panel.fit(table))
104-
console.print(main_table)
117+
console.print(main_table)

0 commit comments

Comments
 (0)