From c5ae30d1d4167aa7ef0f7a08f83fee6cc085f036 Mon Sep 17 00:00:00 2001 From: Philipp Moritz Date: Fri, 8 Jan 2021 18:31:32 -0800 Subject: [PATCH] Do not give an error if both `RAY_ADDRESS` and `address` is specified on initialization (#13305) * Finalize handling of RAY_ADDRESS * lint --- python/ray/worker.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/python/ray/worker.py b/python/ray/worker.py index 4086831ea..5212d522c 100644 --- a/python/ray/worker.py +++ b/python/ray/worker.py @@ -523,7 +523,7 @@ def init( 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(). + cluster with ray.init() or ray.init(address="auto"). Args: address (str): The address of the Ray cluster to connect to. If @@ -532,7 +532,9 @@ def init( It will also kill these processes when Python exits. If the driver is running on a node in a Ray cluster, using `auto` as the value tells the driver to detect the the cluster, removing the need to - specify a specific node address. + specify a specific node address. If the environment variable + `RAY_ADDRESS` is defined and the address is None or "auto", Ray + will set `address` to `RAY_ADDRESS`. num_cpus (int): Number of CPUs the user wishes to assign to each raylet. By default, this is set based on virtual cores. num_gpus (int): Number of GPUs the user wishes to assign to each @@ -634,13 +636,6 @@ def init( if "RAY_ADDRESS" in os.environ: if 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.") # Convert hostnames to numerical IP address. if _node_ip_address is not None: