Skip to content

Commit b8caf9c

Browse files
Env var for custom Ray Image
1 parent 8e29291 commit b8caf9c

File tree

4 files changed

+39
-21
lines changed

4 files changed

+39
-21
lines changed

.github/workflows/e2e_tests.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ jobs:
104104
105105
set -euo pipefail
106106
pip install poetry
107-
poetry config virtualenvs.create false
108107
poetry lock --no-update
109108
poetry install --with test,docs
110109
poetry run pytest -v -s ./tests/e2e/mnist_raycluster_sdk_test.py --json-report --json-report-file=${CODEFLARE_TEST_OUTPUT_DIR}/pytest_report.json 2>&1 | tee ${CODEFLARE_TEST_OUTPUT_DIR}/pytest.log

poetry.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/e2e/mnist_raycluster_sdk_test.py

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,46 @@
1414

1515
import pytest
1616

17-
from support import random_choice
17+
from support import random_choice, get_ray_image
1818

1919
# Creates a Ray cluster, and trains the MNIST dataset using the CodeFlare SDK.
2020
# Asserts creation of AppWrapper, RayCluster, and successful completion of the training job.
2121
# Covers successfull installation of CodeFlare-SDK
2222

23+
2324
class TestMNISTRayClusterSDK:
2425
def setup_method(self):
2526
# Load the kube config from the environment or Kube config file.
2627
config.load_kube_config()
2728

2829
# Initialize Kubernetes client
2930
self.api_instance = client.CoreV1Api()
30-
self.custom_api = kubernetes.client.CustomObjectsApi(self.api_instance.api_client)
31+
self.custom_api = kubernetes.client.CustomObjectsApi(
32+
self.api_instance.api_client
33+
)
3134

3235
def teardown_method(self):
33-
if hasattr(self, 'namespace'):
36+
if hasattr(self, "namespace"):
3437
self.api_instance.delete_namespace(self.namespace)
35-
if hasattr(self, 'configmap'):
36-
self.api_instance.delete_namespaced_config_map(self.configmap.metadata.name, self.namespace)
38+
if hasattr(self, "configmap"):
39+
self.api_instance.delete_namespaced_config_map(
40+
self.configmap.metadata.name, self.namespace
41+
)
3742

3843
def test_mnist_ray_cluster_sdk(self):
3944
self.create_test_namespace()
4045
self.run_mnist_raycluster_sdk()
4146

4247
def create_test_namespace(self):
4348
self.namespace = f"test-ns-{random_choice()}"
44-
namespace_body = client.V1Namespace(metadata=client.V1ObjectMeta(name=self.namespace))
49+
namespace_body = client.V1Namespace(
50+
metadata=client.V1ObjectMeta(name=self.namespace)
51+
)
4552
self.api_instance.create_namespace(namespace_body)
4653
return self.namespace
4754

4855
def run_mnist_raycluster_sdk(self):
49-
ray_image = "quay.io/project-codeflare/ray:latest-py39-cu118"
56+
ray_image = get_ray_image()
5057
host = os.getenv("CLUSTER_HOSTNAME")
5158

5259
ingress_options = {}
@@ -61,7 +68,7 @@ def run_mnist_raycluster_sdk(self):
6168
"host": host,
6269
"annotations": {
6370
"nginx.ingress.kubernetes.io/proxy-body-size": "100M",
64-
}
71+
},
6572
},
6673
]
6774
}
@@ -127,17 +134,29 @@ def run_mnist_raycluster_sdk(self):
127134
# Assertions
128135
def assert_appwrapper_exists(self):
129136
try:
130-
self.custom_api.get_namespaced_custom_object("workload.codeflare.dev", "v1beta1", self.namespace, "appwrappers", "mnist")
131-
print(f"AppWrapper 'mnist' has been created in the namespace: '{self.namespace}'")
137+
self.custom_api.get_namespaced_custom_object(
138+
"workload.codeflare.dev",
139+
"v1beta1",
140+
self.namespace,
141+
"appwrappers",
142+
"mnist",
143+
)
144+
print(
145+
f"AppWrapper 'mnist' has been created in the namespace: '{self.namespace}'"
146+
)
132147
assert True
133148
except Exception as e:
134149
print(f"AppWrapper 'mnist' has not been created. Error: {e}")
135150
assert False
136151

137152
def assert_raycluster_exists(self):
138153
try:
139-
self.custom_api.get_namespaced_custom_object("ray.io", "v1", self.namespace, "rayclusters", "mnist")
140-
print(f"RayCluster 'mnist' created successfully in the namespace: '{self.namespace}'")
154+
self.custom_api.get_namespaced_custom_object(
155+
"ray.io", "v1", self.namespace, "rayclusters", "mnist"
156+
)
157+
print(
158+
f"RayCluster 'mnist' created successfully in the namespace: '{self.namespace}'"
159+
)
141160
assert True
142161
except Exception as e:
143162
print(f"RayCluster 'mnist' has not been created. Error: {e}")

tests/e2e/support.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1+
import os
12
import random
23
import string
34

4-
def read_file(file_name):
5-
try:
6-
with open(file_name, 'rb') as file:
7-
return file.read()
8-
except IOError as e:
9-
raise e
5+
6+
def get_ray_image():
7+
default_ray_image = "quay.io/project-codeflare/ray:latest-py39-cu118"
8+
return os.getenv("RAY_IMAGE", default_ray_image)
109

1110

12-
alphabet = string.ascii_lowercase + string.digits
1311
def random_choice():
14-
return ''.join(random.choices(alphabet, k=5))
12+
alphabet = string.ascii_lowercase + string.digits
13+
return "".join(random.choices(alphabet, k=5))

0 commit comments

Comments
 (0)