Skip to content

[core] Group observability APIs in ray CLI help output#62748

Merged
edoakes merged 5 commits intoray-project:masterfrom
nhquana2:ray-help
Apr 20, 2026
Merged

[core] Group observability APIs in ray CLI help output#62748
edoakes merged 5 commits intoray-project:masterfrom
nhquana2:ray-help

Conversation

@nhquana2
Copy link
Copy Markdown
Contributor

Description

Currently, when running ray --help, the core State API CLI commands (get, list, summary, and logs) are mixed alphabetically in the general "Commands" section alongside other commands. This makes it difficult for users to quickly identify which tools are available without referring to Ray's documentation.

I solved the issue by constructing a custom click Group subclass (RayCLI) that intercepts formatting. It groups the State API commands correctly under the Observability section when calling ray --help.

Implementation details

  1. Created RayCLI Class: Overrides standard click.Group's format_commands() method to intercept and separate incoming subcommands.
  2. Filtering State APIs: The method scans the loaded commands for "list", "get", "summary", and "logs".
  3. Partitioned sections: Any matched commands are pushed into an Observability dict buffer while all remaining commands are pushed into the standard Commands.
  4. Integration: Simply replaced the default @click.group() app entry decorator at scripts.py:cli with @click.group(cls=RayCLI).

Output of ray --help after changes:

Usage: ray [OPTIONS] COMMAND [ARGS]...

Options:
  --logging-level TEXT   The logging level threshold, choices=['debug',
                         'info', 'warning', 'error', 'critical'],
                         default='info'
  --logging-format TEXT  The logging format.
                         default="%%(asctime)s\t%%(levelname)s
                         %%(filename)s:%%(lineno)s -- %%(message)s"
  --version              Show the version and exit.
  --help                 Show this message and exit.

Commands:
  attach               Create or attach to a SSH session to a Ray cluster.
  check-open-ports     Check open ports in the local Ray cluster.
  cluster-dump         Get log data from one or more nodes.
  cpp                  Show the cpp library path and generate the bazel...
  dashboard            Port-forward a Ray cluster's dashboard to the...
  debug                Show all active breakpoints and exceptions in the...
  disable-usage-stats  Disable usage stats collection.
  down                 Tear down a Ray cluster.
  enable-usage-stats   Enable usage stats collection.
  exec                 Execute a command via SSH on a Ray cluster.
  get-auth-token       Prints the Ray authentication token to stdout.
  get-head-ip          Return the head node IP of a Ray cluster.
  get-worker-ips       Return the list of worker IPs of a Ray cluster.
  job                  Submit, stop, delete, or list Ray jobs.
  kill-actor           Kill an actor by name.
  memory               Print object references held in a Ray cluster.
  metrics
  microbenchmark       Run a local Ray microbenchmark on the current...
  monitor              Tails the autoscaler logs of a Ray cluster.
  rsync-down           Download specific files from a Ray cluster.
  rsync-up             Upload specific files to a Ray cluster.
  stack                Take a stack dump of all Python workers on the...
  start                Start Ray processes manually on the local machine.
  status               Print cluster status, including autoscaling info.
  stop                 Stop Ray processes manually on the local machine.
  submit               Uploads and runs a script on the specified cluster.
  symmetric-run        Command to start Ray across all nodes and execute...
  timeline             Take a Chrome tracing timeline for a Ray cluster.
  up                   Create or update a Ray cluster.

Observability:
  get      Get a state of a given resource by ID.
  list     List all states of a given resource.
  logs     Get logs based on filename (cluster) or resource...
  summary  Return the summarized information of a given...

Related Issue

Testing / Verification

  • Verified ray --help output manually on my local.
  • All formatting and linting scripts passed pre-push hooks (using setup_hooks.sh).

Fixes an issue where 'get' and 'list' APIs were mixed up with standard
commands under 'ray --help'. By implementing a custom click.Group
(RayCLI), we now strictly segregate the State CLI commands (get, list,
summary, logs) into a dedicated 'Observability:' section to improve
discoverability.

Signed-off-by: nhquana2 <[email protected]>
@nhquana2 nhquana2 requested a review from a team as a code owner April 18, 2026 16:50
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a custom RayCLI class that overrides the default command formatting to group CLI commands into 'Commands' and 'Observability' sections. The review feedback suggests expanding the list of observability-related commands to include additional diagnostic tools and refactoring the command set into a class-level constant for better code organization and idiomaticity.

Comment thread python/ray/scripts/scripts.py
Comment thread python/ray/scripts/scripts.py
@ray-gardener ray-gardener Bot added docs An issue or change related to documentation core Issues that should be addressed in Ray Core observability Issues related to the Ray Dashboard, Logging, Metrics, Tracing, and/or Profiling community-contribution Contributed by the community labels Apr 18, 2026
@nhquana2 nhquana2 closed this Apr 19, 2026
@nhquana2 nhquana2 reopened this Apr 19, 2026
Signed-off-by: nhquana2 <[email protected]>
@edoakes edoakes added the go add ONLY when ready to merge, run all tests label Apr 20, 2026
Copy link
Copy Markdown
Collaborator

@edoakes edoakes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for the contribution. Could you leave a docstring comment on the RayCLI class indicating why it exists?

I've triggered premerge CI tests

@nhquana2
Copy link
Copy Markdown
Contributor Author

nhquana2 commented Apr 20, 2026

Looks good, thanks for the contribution. Could you leave a docstring comment on the RayCLI class indicating why it exists?

I've triggered premerge CI tests

Hi @edoakes,

I’ve added the requested docstring. This is my first contribution to Ray as part of my university lab project, so I’d appreciate it if you could review and merge the changes.

I also have a couple of questions:

Thanks for your support!

@nhquana2 nhquana2 requested a review from edoakes April 20, 2026 02:29
@edoakes edoakes merged commit 1640ff6 into ray-project:master Apr 20, 2026
5 of 6 checks passed
@edoakes
Copy link
Copy Markdown
Collaborator

edoakes commented Apr 20, 2026

Thanks for the contribution @nhquana2

@nhquana2
Copy link
Copy Markdown
Contributor Author

Thanks, it was a pleasure contributing to Ray!

HLDKNotFound pushed a commit to chichic21039/ray that referenced this pull request Apr 22, 2026
…2748)

Currently, when running `ray --help`, the core State API CLI commands
(`get`, `list`, `summary`, and `logs`) are mixed alphabetically in the
general "Commands" section alongside other commands. This makes it
difficult for users to quickly identify which tools are available
without referring to Ray's documentation.

I solved the issue by constructing a custom click Group subclass
(`RayCLI`) that intercepts formatting. It groups the State API commands
correctly under the **Observability** section when calling `ray --help`.

## Implementation details
1. **Created `RayCLI` Class**: Overrides standard `click.Group`'s
`format_commands()` method to intercept and separate incoming
subcommands.
2. **Filtering State APIs**: The method scans the loaded commands for
`"list"`, `"get"`, `"summary"`, and `"logs"`.
3. **Partitioned sections**: Any matched commands are pushed into an
`Observability` dict buffer while all remaining commands are pushed into
the standard `Commands`.
4. **Integration**: Simply replaced the default `@click.group()` app
entry decorator at `scripts.py:cli` with `@click.group(cls=RayCLI)`.

### Output of `ray --help` after changes:

```text
Usage: ray [OPTIONS] COMMAND [ARGS]...

Options:
  --logging-level TEXT   The logging level threshold, choices=['debug',
                         'info', 'warning', 'error', 'critical'],
                         default='info'
  --logging-format TEXT  The logging format.
                         default="%%(asctime)s\t%%(levelname)s
                         %%(filename)s:%%(lineno)s -- %%(message)s"
  --version              Show the version and exit.
  --help                 Show this message and exit.

Commands:
  attach               Create or attach to a SSH session to a Ray cluster.
  check-open-ports     Check open ports in the local Ray cluster.
  cluster-dump         Get log data from one or more nodes.
  cpp                  Show the cpp library path and generate the bazel...
  dashboard            Port-forward a Ray cluster's dashboard to the...
  debug                Show all active breakpoints and exceptions in the...
  disable-usage-stats  Disable usage stats collection.
  down                 Tear down a Ray cluster.
  enable-usage-stats   Enable usage stats collection.
  exec                 Execute a command via SSH on a Ray cluster.
  get-auth-token       Prints the Ray authentication token to stdout.
  get-head-ip          Return the head node IP of a Ray cluster.
  get-worker-ips       Return the list of worker IPs of a Ray cluster.
  job                  Submit, stop, delete, or list Ray jobs.
  kill-actor           Kill an actor by name.
  memory               Print object references held in a Ray cluster.
  metrics
  microbenchmark       Run a local Ray microbenchmark on the current...
  monitor              Tails the autoscaler logs of a Ray cluster.
  rsync-down           Download specific files from a Ray cluster.
  rsync-up             Upload specific files to a Ray cluster.
  stack                Take a stack dump of all Python workers on the...
  start                Start Ray processes manually on the local machine.
  status               Print cluster status, including autoscaling info.
  stop                 Stop Ray processes manually on the local machine.
  submit               Uploads and runs a script on the specified cluster.
  symmetric-run        Command to start Ray across all nodes and execute...
  timeline             Take a Chrome tracing timeline for a Ray cluster.
  up                   Create or update a Ray cluster.

Observability:
  get      Get a state of a given resource by ID.
  list     List all states of a given resource.
  logs     Get logs based on filename (cluster) or resource...
  summary  Return the summarized information of a given...
```

Fixes ray-project#26376

---------

Signed-off-by: nhquana2 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community core Issues that should be addressed in Ray Core docs An issue or change related to documentation go add ONLY when ready to merge, run all tests observability Issues related to the Ray Dashboard, Logging, Metrics, Tracing, and/or Profiling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Core][State Observability] Grouping state APIs when ray --help is called.

2 participants