Skip to content

Commit

Permalink
[Cluster launcher] Add more commands to "Useful commands" CLI output (#…
Browse files Browse the repository at this point in the history
…40160)

Updates the "useful commands" printed on ray up to add

ray down
ray get-head-ip
ray dashboard
ray job submit
Removes the "manual ssh command", because "ray attach" should be used instead.

In summary, this PR implements the conclusion of the discussion here: #34685 (comment)

This PR also fixes a bug where cluster-name was not printed in the example commands in places where it should have been. (This is stored in the variable modifiers in the code)

Related issue number
Closes #34685

---------

Signed-off-by: Archit Kulkarni <[email protected]>
Signed-off-by: Archit Kulkarni <[email protected]>
  • Loading branch information
architkulkarni committed Nov 28, 2023
1 parent 5e1c181 commit 729366b
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 29 deletions.
48 changes: 37 additions & 11 deletions python/ray/autoscaler/_private/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,22 +871,48 @@ def get_or_create_head_node(
modifiers = ""

cli_logger.newline()
with cli_logger.group("Useful commands"):
with cli_logger.group("Useful commands:"):
printable_config_file = os.path.abspath(printable_config_file)
cli_logger.print("Monitor autoscaling with")

cli_logger.print("To terminate the cluster:")
cli_logger.print(cf.bold(f" ray down {printable_config_file}{modifiers}"))
cli_logger.newline()

cli_logger.print("To retrieve the IP address of the cluster head:")
cli_logger.print(
cf.bold(" ray exec {}{} {}"),
printable_config_file,
modifiers,
quote(monitor_str),
cf.bold(f" ray get-head-ip {printable_config_file}{modifiers}")
)
cli_logger.newline()

cli_logger.print("Connect to a terminal on the cluster head:")
cli_logger.print(cf.bold(" ray attach {}{}"), printable_config_file, modifiers)
cli_logger.print(
"To port-forward the cluster's Ray Dashboard to the local machine:"
)
cli_logger.print(cf.bold(f" ray dashboard {printable_config_file}{modifiers}"))
cli_logger.newline()

remote_shell_str = updater.cmd_runner.remote_shell_command_str()
cli_logger.print("Get a remote shell to the cluster manually:")
cli_logger.print(" {}", remote_shell_str.strip())
cli_logger.print(
"To submit a job to the cluster, port-forward the "
"Ray Dashboard in another terminal and run:"
)
cli_logger.print(
cf.bold(
" ray job submit --address http:https://localhost:<dashboard-port> "
"--working-dir . -- python my_script.py"
)
)
cli_logger.newline()

cli_logger.print("To connect to a terminal on the cluster head for debugging:")
cli_logger.print(cf.bold(f" ray attach {printable_config_file}{modifiers}"))
cli_logger.newline()

cli_logger.print("To monitor autoscaling:")
cli_logger.print(
cf.bold(
f" ray exec {printable_config_file}{modifiers} {quote(monitor_str)}"
)
)
cli_logger.newline()


def _should_create_new_head(
Expand Down
25 changes: 19 additions & 6 deletions python/ray/tests/test_cli_patterns/test_ray_up.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,23 @@ Acquiring an up-to-date head node
\[7/7\] Starting the Ray runtime
New status: up-to-date

Useful commands
Monitor autoscaling with
ray exec .+ 'tail -n 100 -f /tmp/ray/session_latest/logs/monitor\*'
Connect to a terminal on the cluster head:
Useful commands:
To terminate the cluster:
ray down .+

To retrieve the IP address of the cluster head:
ray get-head-ip .+

To port-forward the cluster's Ray Dashboard to the local machine:
ray dashboard .+

To submit a job to the cluster, port-forward the Ray Dashboard in another terminal and run:
ray job submit --address .+

To connect to a terminal on the cluster head for debugging:
ray attach .+
Get a remote shell to the cluster manually:
ssh .+

To monitor autoscaling:
ray exec .+ 'tail -n 100 -f /tmp/ray/session_latest/logs/monitor\*'


25 changes: 19 additions & 6 deletions python/ray/tests/test_cli_patterns/test_ray_up_docker.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,23 @@ Acquiring an up-to-date head node
\[7/7\] Starting the Ray runtime
New status: up-to-date

Useful commands
Monitor autoscaling with
ray exec .+ 'tail -n 100 -f /tmp/ray/session_latest/logs/monitor\*'
Connect to a terminal on the cluster head:
Useful commands:
To terminate the cluster:
ray down .+

To retrieve the IP address of the cluster head:
ray get-head-ip .+

To port-forward the cluster's Ray Dashboard to the local machine:
ray dashboard .+

To submit a job to the cluster, port-forward the Ray Dashboard in another terminal and run:
ray job submit --address .+

To connect to a terminal on the cluster head for debugging:
ray attach .+
Get a remote shell to the cluster manually:
ssh .+

To monitor autoscaling:
ray exec .+ 'tail -n 100 -f /tmp/ray/session_latest/logs/monitor\*'


18 changes: 12 additions & 6 deletions python/ray/tests/test_cli_patterns/test_ray_up_record.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,16 @@
.+\.py.*AWSNodeProvider: Set tag ray-runtime-config=.+ on \['.+'\] \[LogTimer=.+\]
.+\.py.*AWSNodeProvider: Set tag ray-file-mounts-contents=.+ on \['.+'\] \[LogTimer=.+\]
.+\.py.*New status: up-to-date
.+\.py.*Useful commands
.+\.py.*Monitor autoscaling with
.+\.py.* ray exec .+ 'tail -n 100 -f .+
.+\.py.*Connect to a terminal on the cluster head:
.+\.py.*Useful commands:
.+\.py.*To terminate the cluster:
.+\.py.* ray down .+
.+\.py.*To retrieve the IP address of the cluster head:
.+\.py.* ray get-head-ip .+
.+\.py.*To port-forward the cluster's Ray Dashboard to the local machine:
.+\.py.* ray dashboard .+
.+\.py.*To submit a job to the cluster, port-forward the Ray Dashboard in another terminal and run:
.+\.py.* ray job submit --address .+
.+\.py.*To connect to a terminal on the cluster head for debugging:
.+\.py.* ray attach .+
.+\.py.*Get a remote shell to the cluster manually:
.+\.py.* ssh.+\.pem.+
.+\.py.*To monitor autoscaling:
.+\.py.* ray exec .+ 'tail -n 100 -f /tmp/ray/session_latest/logs/monitor\*'

0 comments on commit 729366b

Please sign in to comment.