Repository: ray-project/ray

Issue:
[autoscaler] Usability regressions in new autoscaler output
@richardliaw we've regressed the output here, it's a minor issue but super annoying.

```
Useful commands
  Monitor autoscaling with
    ray exec example-ml.yaml 'tail -n 100 -f /tmp/ray/session_latest/logs/monitor*'
  Connect to a terminal on the cluster head
    ray attach example-ml.yaml
```

It used to print the absolute path of the yaml, so you can copy paste into any terminal. Now, the user has to navigate to the directory YAML for the command to work.


Discussion:
Also, didn't we used to print the raw SSH command if you want to use a direct shell? If we don't print that, then users will have a hard time figuring out how to get direct access if they want more custom command execution.
The first issue is fixed on master - https://github.com/ray-project/ray/commit/401195d9359b4d6641776f43706bc3ced414819e#diff-4fd45cbce68a36f9e4f5a688ac099228
If not please provide repro:
```

Useful commands
  Monitor autoscaling with
    ray exec /Users/rliaw/dev/cfgs/anyscale.yaml 'tail -n 100 -f /tmp/ray/session_latest/logs/monitor*'
  Connect to a terminal on the cluster head
    ray attach /Users/rliaw/dev/cfgs/anyscale.yaml

```
Thanks!
Actually, how about the raw SSH command?
the raw ssh command is not yet
Hm, maybe it was that when you run "ray attach etc.", it used to print the raw SSH command being executed. Can we ensure this is printed out so the commands aren't so "magic"?
Yeah - I'll add a line.

Resolving patch:
diff --git a/python/ray/autoscaler/commands.py b/python/ray/autoscaler/commands.py
--- a/python/ray/autoscaler/commands.py
+++ b/python/ray/autoscaler/commands.py
@@ -730,9 +730,13 @@ def get_or_create_head_node(config,
                 cf.bold("  ray exec {}{} {}"), config_file, modifiers,
                 quote(monitor_str))
 
-            cli_logger.print("Connect to a terminal on the cluster head")
+            cli_logger.print("Connect to a terminal on the cluster head:")
             cli_logger.print(
                 cf.bold("  ray attach {}{}"), config_file, modifiers)
+
+            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())
     finally:
         provider.cleanup()
 


Test patch:
diff --git a/python/ray/tests/test_cli.py b/python/ray/tests/test_cli.py
--- a/python/ray/tests/test_cli.py
+++ b/python/ray/tests/test_cli.py
@@ -91,21 +91,23 @@ def _debug_check_line_by_line(result, expected_lines):
     i = 0
 
     for out in output_lines:
-        print(out)
-
         if i >= len(expected_lines):
             i += 1
             print("!!!!!! Expected fewer lines")
-            print("\n".join(output_lines[i:]))
+            context = [f"CONTEXT: {line}" for line in output_lines[i - 3:i]]
+            print("\n".join(context))
+            extra = [f"-- {line}" for line in output_lines[i:]]
+            print("\n".join(extra))
             break
 
         exp = expected_lines[i]
         matched = re.fullmatch(exp + r" *", out) is not None
         if not matched:
-            print(f"!!!!!!! Expected (regex): {repr(exp)}")
+            print(f"!!! ERROR: Expected (regex): {repr(exp)}")
+            print(f"Got: {out}")
         i += 1
     if i < len(expected_lines):
-        print("!!!!!!! Expected (regex):")
+        print("!!! ERROR: Expected extra lines (regex):")
         for line in expected_lines[i:]:
 
             print(repr(line))
diff --git a/python/ray/tests/test_cli_patterns/test_ray_up.txt b/python/ray/tests/test_cli_patterns/test_ray_up.txt
--- a/python/ray/tests/test_cli_patterns/test_ray_up.txt
+++ b/python/ray/tests/test_cli_patterns/test_ray_up.txt
@@ -42,5 +42,7 @@ Acquiring an up-to-date head node
 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
+  Connect to a terminal on the cluster head:
     ray attach .+
+  Get a remote shell to the cluster manually:
+    ssh .+
diff --git a/python/ray/tests/test_cli_patterns/test_ray_up_record.txt b/python/ray/tests/test_cli_patterns/test_ray_up_record.txt
--- a/python/ray/tests/test_cli_patterns/test_ray_up_record.txt
+++ b/python/ray/tests/test_cli_patterns/test_ray_up_record.txt
@@ -71,5 +71,7 @@
 .+\.py.*Useful commands
 .+\.py.*Monitor autoscaling with
 .+\.py.*  ray exec .+ 'tail -n 100 -f .+
-.+\.py.*Connect to a terminal on the cluster head
+.+\.py.*Connect to a terminal on the cluster head:
 .+\.py.*  ray attach .+
+.+\.py.*Get a remote shell to the cluster manually:
+.+\.py.*  ssh.+\.pem.+