[cli][ray] ray start should error by default if there's already an instance running (#10826)

This commit is contained in:
Keqiu Hu
2020-09-24 08:29:59 -07:00
committed by GitHub
parent 842861b4fc
commit 46a560e876
6 changed files with 64 additions and 36 deletions
+2 -3
View File
@@ -178,9 +178,8 @@ def ray_start_object_store_memory(request):
@pytest.fixture
def call_ray_start(request):
parameter = getattr(
request, "param",
"ray start --head --num-cpus=1 --min-worker-port=0 --max-worker-port=0"
)
request, "param", "ray start --head --num-cpus=1 --min-worker-port=0 "
"--max-worker-port=0 --port 0")
command_args = parameter.split(" ")
out = ray.utils.decode(
subprocess.check_output(command_args, stderr=subprocess.STDOUT))
+3 -3
View File
@@ -158,9 +158,9 @@ DEFAULT_TEST_CONFIG_PATH = str(
reason=("Mac builds don't provide proper locale support"))
def test_ray_start(configure_lang):
runner = CliRunner()
result = runner.invoke(
scripts.start,
["--head", "--log-style=pretty", "--log-color", "False"])
result = runner.invoke(scripts.start, [
"--head", "--log-style=pretty", "--log-color", "False", "--port", "0"
])
_die_on_error(runner.invoke(scripts.stop))
_check_output_via_pattern("test_ray_start.txt", result)
+21 -18
View File
@@ -301,7 +301,7 @@ ray.get([a.log.remote(), f.remote()])
@pytest.mark.parametrize(
"call_ray_start", [
"ray start --head --num-cpus=1 --num-gpus=1 " +
"--min-worker-port=0 --max-worker-port=0"
"--min-worker-port=0 --max-worker-port=0 --port 0"
],
indirect=True)
def test_drivers_release_resources(call_ray_start):
@@ -369,26 +369,24 @@ print("success")
def test_calling_start_ray_head(call_ray_stop_only):
# Test that we can call ray start with various command line
# parameters. TODO(rkn): This test only tests the --head code path. We
# should also test the non-head node code path.
# Test starting Ray with no arguments.
check_call_ray(["start", "--head"])
check_call_ray(["stop"])
# Test starting Ray with a redis port specified.
check_call_ray(["start", "--head"])
check_call_ray(["start", "--head", "--port", "0"])
check_call_ray(["stop"])
# Test starting Ray with a node IP address specified.
check_call_ray(["start", "--head", "--node-ip-address", "127.0.0.1"])
check_call_ray(
["start", "--head", "--node-ip-address", "127.0.0.1", "--port", "0"])
check_call_ray(["stop"])
# Test starting Ray with a system config parameter set.
check_call_ray([
"start", "--head", "--system-config",
"{\"metrics_report_interval_ms\":100}"
"{\"metrics_report_interval_ms\":100}", "--port", "0"
])
check_call_ray(["stop"])
@@ -396,45 +394,49 @@ def test_calling_start_ray_head(call_ray_stop_only):
# specified.
check_call_ray([
"start", "--head", "--object-manager-port", "12345",
"--node-manager-port", "54321"
"--node-manager-port", "54321", "--port", "0"
])
check_call_ray(["stop"])
# Test starting Ray with the worker port range specified.
check_call_ray([
"start", "--head", "--min-worker-port", "50000", "--max-worker-port",
"51000"
"51000", "--port", "0"
])
check_call_ray(["stop"])
# Test starting Ray with the number of CPUs specified.
check_call_ray(["start", "--head", "--num-cpus", "2"])
check_call_ray(["start", "--head", "--num-cpus", "2", "--port", "0"])
check_call_ray(["stop"])
# Test starting Ray with the number of GPUs specified.
check_call_ray(["start", "--head", "--num-gpus", "100"])
check_call_ray(["start", "--head", "--num-gpus", "100", "--port", "0"])
check_call_ray(["stop"])
# Test starting Ray with redis shard ports specified.
check_call_ray(
["start", "--head", "--redis-shard-ports", "6380,6381,6382"])
check_call_ray([
"start", "--head", "--redis-shard-ports", "6380,6381,6382", "--port",
"0"
])
check_call_ray(["stop"])
# Test starting Ray with all arguments specified.
check_call_ray([
"start", "--head", "--redis-shard-ports", "6380,6381,6382",
"--object-manager-port", "12345", "--num-cpus", "2", "--num-gpus", "0",
"--resources", "{\"Custom\": 1}"
"--resources", "{\"Custom\": 1}", "--port", "0"
])
check_call_ray(["stop"])
# Test starting Ray with invalid arguments.
with pytest.raises(subprocess.CalledProcessError):
check_call_ray(["start", "--head", "--address", "127.0.0.1:6379"])
check_call_ray(
["start", "--head", "--address", "127.0.0.1:6379", "--port", "0"])
check_call_ray(["stop"])
# Test --block. Killing a child process should cause the command to exit.
blocked = subprocess.Popen(["ray", "start", "--head", "--block"])
blocked = subprocess.Popen(
["ray", "start", "--head", "--block", "--port", "0"])
wait_for_children_of_pid(blocked.pid, num_children=7, timeout=30)
@@ -447,7 +449,8 @@ def test_calling_start_ray_head(call_ray_stop_only):
assert blocked.returncode != 0, "ray start shouldn't return 0 on bad exit"
# Test --block. Killing the command should clean up all child processes.
blocked = subprocess.Popen(["ray", "start", "--head", "--block"])
blocked = subprocess.Popen(
["ray", "start", "--head", "--block", "--port", "0"])
blocked.poll()
assert blocked.returncode is None
+1 -1
View File
@@ -42,7 +42,7 @@ def test_tempdir_commandline():
shutil.rmtree(ray.utils.get_ray_temp_dir(), ignore_errors=True)
check_call_ray([
"start", "--head", "--temp-dir=" + os.path.join(
ray.utils.get_user_temp_dir(), "i_am_a_temp_dir2")
ray.utils.get_user_temp_dir(), "i_am_a_temp_dir2"), "--port", "0"
])
assert os.path.exists(
os.path.join(ray.utils.get_user_temp_dir(),