From 5c2aedc7d97d94ee3ea09d20d1f06046602a76ca Mon Sep 17 00:00:00 2001 From: Ian Rodney Date: Tue, 26 Jan 2021 10:29:42 -0800 Subject: [PATCH] [CLI] Fix Ray Status with ENV Variable set (#13707) --- python/ray/_private/services.py | 2 +- python/ray/tests/test_cli.py | 19 +++++++++++++++++++ .../test_cli_patterns/test_ray_status.txt | 12 ++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 python/ray/tests/test_cli_patterns/test_ray_status.txt diff --git a/python/ray/_private/services.py b/python/ray/_private/services.py index c9ea996f9..435c16d4e 100644 --- a/python/ray/_private/services.py +++ b/python/ray/_private/services.py @@ -216,7 +216,7 @@ def get_ray_address_to_use_or_die(): A string to pass into `ray.init(address=...)` """ if "RAY_ADDRESS" in os.environ: - return "auto" # Avoid conflict with RAY_ADDRESS env var + return os.environ.get("RAY_ADDRESS") return find_redis_address_or_die() diff --git a/python/ray/tests/test_cli.py b/python/ray/tests/test_cli.py index 57bf61419..a6f1b1989 100644 --- a/python/ray/tests/test_cli.py +++ b/python/ray/tests/test_cli.py @@ -415,5 +415,24 @@ def test_ray_submit(configure_lang, configure_aws, _unlink_test_ssh_key): _check_output_via_pattern("test_ray_submit.txt", result) +def test_ray_status(): + import ray + address = ray.init().get("redis_address") + runner = CliRunner() + result = runner.invoke(scripts.status, []) + _check_output_via_pattern("test_ray_status.txt", result) + + result_arg = runner.invoke(scripts.status, ["--address", address]) + _check_output_via_pattern("test_ray_status.txt", result_arg) + + # Try to check status with RAY_ADDRESS set + os.environ["RAY_ADDRESS"] = address + result_env = runner.invoke(scripts.status) + _check_output_via_pattern("test_ray_status.txt", result_env) + + result_env_arg = runner.invoke(scripts.status, ["--address", address]) + _check_output_via_pattern("test_ray_status.txt", result_env_arg) + + if __name__ == "__main__": sys.exit(pytest.main(["-v", __file__])) diff --git a/python/ray/tests/test_cli_patterns/test_ray_status.txt b/python/ray/tests/test_cli_patterns/test_ray_status.txt new file mode 100644 index 000000000..7169c5f0f --- /dev/null +++ b/python/ray/tests/test_cli_patterns/test_ray_status.txt @@ -0,0 +1,12 @@ +======== Cluster status: .+ +Node status +------------------------------------------------------------ + + +Resources +------------------------------------------------------------ +Usage: + + +Demands: + \(no resource demands\)