Add --worker-port-list option to ray start (#11481)

This commit is contained in:
Edward Oakes
2020-10-21 14:46:45 -05:00
committed by GitHub
parent da2d3fbcfc
commit 5d7f271e7d
11 changed files with 76 additions and 10 deletions
+19
View File
@@ -41,6 +41,9 @@ class RayParams:
on. If not set or set to 0, random ports will be chosen.
max_worker_port (int): The highest port number that workers will bind
on. If set, min_worker_port must also be set.
worker_port_list (str): An explicit list of ports to be used for
workers (comma-separated). Overrides min_worker_port and
max_worker_port.
object_ref_seed (int): Used to seed the deterministic generation of
object refs. The same value can be used across multiple runs of the
same job in order to generate the object refs in a consistent
@@ -116,6 +119,7 @@ class RayParams:
raylet_ip_address=None,
min_worker_port=None,
max_worker_port=None,
worker_port_list=None,
object_ref_seed=None,
driver_mode=None,
redirect_worker_output=None,
@@ -163,6 +167,7 @@ class RayParams:
self.raylet_ip_address = raylet_ip_address
self.min_worker_port = min_worker_port
self.max_worker_port = max_worker_port
self.worker_port_list = worker_port_list
self.driver_mode = driver_mode
self.redirect_worker_output = redirect_worker_output
self.redirect_output = redirect_output
@@ -252,6 +257,20 @@ class RayParams:
self._check_usage()
def _check_usage(self):
if self.worker_port_list is not None:
for port_str in self.worker_port_list.split(","):
try:
port = int(port_str)
except ValueError as e:
raise ValueError(
"worker_port_list must be a comma-separated " +
"list of integers: {}".format(e)) from None
if port < 1024 or port > 65535:
raise ValueError(
"Ports in worker_port_list must be "
"between 1024 and 65535. Got: {}".format(port))
# Used primarily for testing.
if os.environ.get("RAY_USE_RANDOM_PORTS", False):
if self.min_worker_port is None and self.min_worker_port is None: