Skip to content

Commit

Permalink
Prepend task id if it exists to "ray task list --detail" (#32353)
Browse files Browse the repository at this point in the history
This change addresses this issue: #30805.

It solves a UX issue where the "task_id" field isn't printed FIRST. So this change prepends it, which can be shown in the following screenshot:

UPDATED screenshot:
  • Loading branch information
ProjectsByJackHe authored Feb 23, 2023
1 parent d2b7187 commit 544f299
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions python/ray/experimental/state/state_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
StateResource,
StateSchema,
SupportedFilterType,
TaskState,
resource_to_schema,
)
from ray.experimental.state.exception import RayStateApiException
Expand Down Expand Up @@ -282,9 +283,17 @@ def format_get_api_output(
schema: StateSchema,
format: AvailableFormat = AvailableFormat.YAML,
) -> str:

if not state_data or len(state_data) == 0:
return f"Resource with id={id} not found in the cluster."

if schema == TaskState and format == AvailableFormat.YAML:
augmented_task_state_data = [
{("task_id: " + state["task_id"]): state} for state in state_data
]
return output_with_format(
augmented_task_state_data, schema=schema, format=format
)
return output_with_format(state_data, schema=schema, format=format)


Expand All @@ -296,6 +305,13 @@ def format_list_api_output(
) -> str:
if len(state_data) == 0:
return "No resource in the cluster"
if schema == TaskState and format == AvailableFormat.YAML:
augmented_task_state_data = [
{("task_id: " + state["task_id"]): state} for state in state_data
]
return output_with_format(
augmented_task_state_data, schema=schema, format=format
)
return output_with_format(state_data, schema=schema, format=format)


Expand Down

0 comments on commit 544f299

Please sign in to comment.