Skip to content

Commit 34be7e2

Browse files
committed
adding conditions to act as head node or from worker node
1 parent eb4901a commit 34be7e2

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

‎modules/api/ray.py‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@
1111
#ray.init("ray://localhost:10001")
1212

1313

14-
if "RAY_DOCKER" in os.environ:
15-
ray.init(
16-
dashboard_host=os.environ.get("RAY_DASHBOARD_HOST", "0.0.0.0"),
17-
dashboard_port=int(os.environ.get("RAY_DASHBOARD_PORT", 8265))
18-
)
19-
else:
20-
ray.init()
21-
2214

2315
def ray_only():
2416
serve.shutdown()
@@ -37,3 +29,18 @@ def ray_only():
3729
print("Done setting up replicas! Now accepting requests...")
3830
while True:
3931
time.sleep(1000)
32+
33+
34+
if __name__ == "__main__":
35+
36+
if "RAY_DOCKER" in os.environ:
37+
ray.init(
38+
dashboard_host=os.environ.get("RAY_DASHBOARD_HOST", "0.0.0.0"),
39+
dashboard_port=int(os.environ.get("RAY_DASHBOARD_PORT", 8265))
40+
)
41+
elif "RAY_HEAD_ADDRESS" in os.environ:
42+
ray.init(os.environ.get("RAY_HEAD_ADDRESS", ""))
43+
elif "RAY_SERVE_ONLY" in os.environ:
44+
ray_only()
45+
else:
46+
ray.init()

0 commit comments

Comments
 (0)