Skip to content

Commit

Permalink
Prepend task id if it exists to "ray task list --detail" (ray-project…
Browse files Browse the repository at this point in the history
…#32353)

This change addresses this issue: ray-project#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:

Signed-off-by: Edward Oakes <[email protected]>
  • Loading branch information
ProjectsByJackHe authored and edoakes committed Mar 22, 2023
1 parent 7bf863e commit fa0f3db
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 fa0f3db

Please sign in to comment.