Use RAY_ADDRESS to connect to an existing Ray cluster if present (#7977)

This commit is contained in:
Philipp Moritz
2020-04-27 09:59:37 -07:00
committed by GitHub
parent a77b19e4f2
commit d7da25eee1
4 changed files with 49 additions and 11 deletions
+15
View File
@@ -565,6 +565,10 @@ def init(address=None,
ray.init(address="123.45.67.89:6379")
You can also define an environment variable called `RAY_ADDRESS` in
the same format as the `address` parameter to connect to an existing
cluster with ray.init().
Args:
address (str): The address of the Ray cluster to connect to. If
this address is not provided, then this command will start Redis,
@@ -672,6 +676,17 @@ def init(address=None,
raise DeprecationWarning("The redis_address argument is deprecated. "
"Please use address instead.")
if "RAY_ADDRESS" in os.environ:
if redis_address is None and (address is None or address == "auto"):
address = os.environ["RAY_ADDRESS"]
else:
raise RuntimeError(
"Cannot use both the RAY_ADDRESS environment variable and "
"the address argument of ray.init simultaneously. If you "
"use RAY_ADDRESS to connect to a specific Ray cluster, "
"please call ray.init() or ray.init(address=\"auto\") on the "
"driver.")
if redis_address is not None or address is not None:
redis_address, _, _ = services.validate_redis_address(
address, redis_address)