diff --git a/python/ray/autoscaler/_private/command_runner.py b/python/ray/autoscaler/_private/command_runner.py index 3dd0b3d38..f328d4fd6 100644 --- a/python/ray/autoscaler/_private/command_runner.py +++ b/python/ray/autoscaler/_private/command_runner.py @@ -598,7 +598,8 @@ class DockerCommandRunner(CommandRunnerInterface): shutdown_after_run=False, ): if run_env == "auto": - run_env = "host" if cmd.find("docker") == 0 else "docker" + run_env = "host" if (not bool(cmd) + or cmd.find("docker") == 0) else "docker" if environment_variables: cmd = _with_environment_variables(cmd, environment_variables) diff --git a/python/ray/tests/test_cli.py b/python/ray/tests/test_cli.py index 1f940674a..57bf61419 100644 --- a/python/ray/tests/test_cli.py +++ b/python/ray/tests/test_cli.py @@ -319,6 +319,30 @@ def test_ray_attach(configure_lang, configure_aws, _unlink_test_ssh_key): _check_output_via_pattern("test_ray_attach.txt", result) +@pytest.mark.skipif( + sys.platform == "darwin" and "travis" in os.environ.get("USER", ""), + reason=("Mac builds don't provide proper locale support")) +@mock_ec2 +@mock_iam +def test_ray_dashboard(configure_lang, configure_aws, _unlink_test_ssh_key): + def commands_mock(command, stdin): + # TODO(maximsmol): this is a hack since stdout=sys.stdout + # doesn't work with the mock for some reason + print("ubuntu@ip-.+:~$ exit") + return PopenBehaviour(stdout="ubuntu@ip-.+:~$ exit") + + with _setup_popen_mock(commands_mock): + runner = CliRunner() + result = runner.invoke(scripts.up, [ + DEFAULT_TEST_CONFIG_PATH, "--no-config-cache", "-y", + "--log-style=pretty", "--log-color", "False" + ]) + _die_on_error(result) + + result = runner.invoke(scripts.dashboard, [DEFAULT_TEST_CONFIG_PATH]) + _check_output_via_pattern("test_ray_dashboard.txt", result) + + @pytest.mark.skipif( sys.platform == "darwin" and "travis" in os.environ.get("USER", ""), reason=("Mac builds don't provide proper locale support")) diff --git a/python/ray/tests/test_cli_patterns/test_ray_dashboard.txt b/python/ray/tests/test_cli_patterns/test_ray_dashboard.txt new file mode 100644 index 000000000..3f7aaf070 --- /dev/null +++ b/python/ray/tests/test_cli_patterns/test_ray_dashboard.txt @@ -0,0 +1,7 @@ +Attempting to establish dashboard locally at localhost:8265 connected to remote port 8265 +Loaded cached provider configuration +If you experience issues with the cloud provider, try re-running the command with --no-config-cache. +Fetched IP: .+ +Forwarding ports +ubuntu@ip-.+:~\$ exit +Successfully established connection.