Skip to content

Commit e8432bf

Browse files
Intuit python version for compatible Ray image
1 parent 9288016 commit e8432bf

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/codeflare_sdk/ray/cluster/generate_yaml.py

+17-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"""
1919

2020
import json
21+
import sys
2122
import typing
2223
import yaml
2324
import os
@@ -31,6 +32,11 @@
3132
)
3233
import codeflare_sdk
3334

35+
SUPPORTED_PYTHON_VERSIONS = {
36+
"3.9": "quay.io/modh/ray@sha256:0d715f92570a2997381b7cafc0e224cfa25323f18b9545acfd23bc2b71576d06",
37+
"3.11": "quay.io/modh/ray:2.35.0-py311-cu121",
38+
}
39+
3440

3541
def read_template(template):
3642
with open(template, "r") as stream:
@@ -88,9 +94,17 @@ def update_names(
8894

8995
def update_image(spec, image):
9096
containers = spec.get("containers")
91-
if image != "":
92-
for container in containers:
93-
container["image"] = image
97+
if not image:
98+
python_version = f"{sys.version_info.major}.{sys.version_info.minor}"
99+
try:
100+
if python_version in SUPPORTED_PYTHON_VERSIONS:
101+
image = SUPPORTED_PYTHON_VERSIONS[python_version]
102+
except Exception: # pragma: no cover
103+
print(
104+
f"Python version '{python_version}' is not supported. Only {', '.join(SUPPORTED_PYTHON_VERSIONS.keys())} are supported."
105+
)
106+
for container in containers:
107+
container["image"] = image
94108

95109

96110
def update_image_pull_secrets(spec, image_pull_secrets):

0 commit comments

Comments
 (0)