mirror of
https://github.com/vale981/ray
synced 2025-03-06 10:31:39 -05:00
[client] Fix ClientBuilder for Local Clusters (#16204)
* Fix client builder * Make tests actually run in CI (required marking a few Windows tests as flaky)
This commit is contained in:
parent
51da90aa09
commit
206802b96f
2 changed files with 21 additions and 9 deletions
|
@ -119,7 +119,8 @@ class _LocalClientBuilder(ClientBuilder):
|
|||
sys.version_info[0], sys.version_info[1], sys.version_info[2]),
|
||||
ray_version=ray.__version__,
|
||||
ray_commit=ray.__commit__,
|
||||
protocol_version=None)
|
||||
protocol_version=None,
|
||||
_num_clients=1)
|
||||
|
||||
|
||||
def _split_address(address: str) -> Tuple[str, str]:
|
||||
|
|
|
@ -28,7 +28,7 @@ def test_split_address(address):
|
|||
address)
|
||||
non_url_compliant_module = f"module_test://{address}"
|
||||
assert client_builder._split_address(non_url_compliant_module) == (
|
||||
"module", address)
|
||||
"module_test", address)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
@ -44,6 +44,7 @@ def test_client(address):
|
|||
assert builder.address == address.replace("ray://", "")
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform == "win32", reason="Flaky on Windows.")
|
||||
def test_namespace():
|
||||
"""
|
||||
Most of the "checks" in this test case rely on the fact that
|
||||
|
@ -108,6 +109,7 @@ def test_connect_to_cluster(ray_start_regular_shared):
|
|||
subprocess.check_output("ray stop --force", shell=True)
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform == "win32", reason="Flaky on Windows.")
|
||||
def test_local_clusters():
|
||||
"""
|
||||
This tests the various behaviors of connecting to local clusters:
|
||||
|
@ -221,6 +223,8 @@ def test_module_lacks_client_builder():
|
|||
assert "does not have ClientBuilder" in str(exception)
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
sys.platform == "win32", reason="RC Proxy is Flaky on Windows.")
|
||||
def test_disconnect(call_ray_stop_only):
|
||||
subprocess.check_output(
|
||||
"ray start --head --ray-client-server-port=25555", shell=True)
|
||||
|
@ -254,8 +258,12 @@ def test_disconnect(call_ray_stop_only):
|
|||
ray.put(300)
|
||||
|
||||
|
||||
def test_address_resolution(ray_start_regular_shared):
|
||||
server = ray_client_server.serve("localhost:50055")
|
||||
@pytest.mark.skipif(
|
||||
sys.platform == "win32", reason="RC Proxy is Flaky on Windows.")
|
||||
def test_address_resolution(call_ray_stop_only):
|
||||
subprocess.check_output(
|
||||
"ray start --head --ray-client-server-port=50055", shell=True)
|
||||
|
||||
with ray.client("localhost:50055").connect():
|
||||
assert ray.util.client.ray.is_connected()
|
||||
|
||||
|
@ -265,12 +273,15 @@ def test_address_resolution(ray_start_regular_shared):
|
|||
# client(...) takes precedence of RAY_ADDRESS=local
|
||||
assert ray.util.client.ray.is_connected()
|
||||
|
||||
with pytest.raises(Exception):
|
||||
# This tries to call `ray.init(address="local") which
|
||||
# breaks.`
|
||||
ray.client(None).connect()
|
||||
assert ray.worker.global_worker.node.is_head()
|
||||
|
||||
finally:
|
||||
if os.environ["RAY_ADDRESS"]:
|
||||
if os.environ.get("RAY_ADDRESS"):
|
||||
del os.environ["RAY_ADDRESS"]
|
||||
|
||||
server.stop(0)
|
||||
subprocess.check_output("ray stop --force", shell=True)
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(pytest.main(["-v", __file__]))
|
||||
|
|
Loading…
Add table
Reference in a new issue