Skip to content

Commit 7df7353

Browse files
Apply 'Black' formatting
1 parent 0726981 commit 7df7353

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

tests/e2e/mnist_raycluster_sdk_test.py

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,35 @@
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

@@ -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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
import random
33
import string
44

5+
56
def get_ray_image():
67
default_ray_image = "quay.io/project-codeflare/ray:latest-py39-cu118"
78
return os.getenv("RAY_IMAGE", default_ray_image)
89

910

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

0 commit comments

Comments
 (0)