Skip to content

Commit 8ccd7d4

Browse files
Adding ray port range to the free port checker (#997)
Signed-off-by: Abhinav Garg <abhinavg@stanford.edu> Co-authored-by: Sarah Yurick <53962159+sarahyurick@users.noreply.github.com>
1 parent 4264120 commit 8ccd7d4

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

nemo_curator/core/client.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,3 @@ def stop(self) -> None:
135135
logger.info(msg)
136136
# Clear the process to prevent double execution (atexit handler)
137137
self.ray_process = None
138-
139-
140-
if __name__ == "__main__":
141-
client = RayClient()
142-
client.start()
143-
import time
144-
145-
time.sleep(10) # Wait for ray to start
146-
client.stop()

nemo_curator/core/constants.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
DEFAULT_RAY_TEMP_DIR = "/tmp/ray" # noqa: S108
1818
DEFAULT_RAY_METRICS_PORT = 8080
1919
DEFAULT_RAY_DASHBOARD_HOST = "127.0.0.1"
20-
DEFAULT_RAY_CLIENT_SERVER_PORT = 20001
20+
DEFAULT_RAY_CLIENT_SERVER_PORT = 10001
2121
DEFAULT_RAY_AUTOSCALER_METRIC_PORT = 44217
2222
DEFAULT_RAY_DASHBOARD_METRIC_PORT = 44227
23+
24+
# We cannot use a free port between 10000 and 19999 as it is used by Ray.
25+
DEFAULT_RAY_MIN_WORKER_PORT = 10002
26+
DEFAULT_RAY_MAX_WORKER_PORT = 19999

nemo_curator/core/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
from nemo_curator.core.constants import (
2424
DEFAULT_RAY_AUTOSCALER_METRIC_PORT,
2525
DEFAULT_RAY_DASHBOARD_METRIC_PORT,
26+
DEFAULT_RAY_MAX_WORKER_PORT,
27+
DEFAULT_RAY_MIN_WORKER_PORT,
2628
)
2729

2830
if TYPE_CHECKING:
@@ -35,6 +37,8 @@ def get_free_port(start_port: int, get_next_free_port: bool = True) -> int:
3537
Else, it will raise an error if the free port is not equal to start_port.
3638
"""
3739
for port in range(start_port, 65535):
40+
if port >= DEFAULT_RAY_MIN_WORKER_PORT and port <= DEFAULT_RAY_MAX_WORKER_PORT:
41+
continue
3842
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
3943
# SO_REUSEADDR to avoid TIME_WAIT issues on some OSes
4044
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

0 commit comments

Comments
 (0)