File tree 3 files changed +24
-1
lines changed
src/codeflare_sdk/cluster
3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,14 @@ def create_app_wrapper(self):
63
63
Called upon cluster object creation, creates an AppWrapper yaml based on
64
64
the specifications of the ClusterConfiguration.
65
65
"""
66
+
67
+ if self .config .namespace is None :
68
+ self .config .namespace = oc .get_project_name ()
69
+ if type (self .config .namespace ) is not str :
70
+ raise TypeError (
71
+ f"Namespace { self .config .namespace } is of type { type (self .config .namespace )} . Check your Kubernetes Authentication."
72
+ )
73
+
66
74
name = self .config .name
67
75
namespace = self .config .namespace
68
76
min_cpu = self .config .min_cpus
Original file line number Diff line number Diff line change 21
21
from dataclasses import dataclass , field
22
22
from .auth import Authentication
23
23
import pathlib
24
+ import openshift
24
25
25
26
dir = pathlib .Path (__file__ ).parent .parent .resolve ()
26
27
@@ -33,7 +34,7 @@ class ClusterConfiguration:
33
34
"""
34
35
35
36
name : str
36
- namespace : str = "default"
37
+ namespace : str = None
37
38
head_info : list = field (default_factory = list )
38
39
machine_types : list = field (default_factory = list ) # ["m4.xlarge", "g4dn.xlarge"]
39
40
min_cpus : int = 1
Original file line number Diff line number Diff line change @@ -240,6 +240,20 @@ def test_cluster_creation():
240
240
return cluster
241
241
242
242
243
+ def test_default_cluster_creation (mocker ):
244
+ mocker .patch ("openshift.get_project_name" , return_value = "opendatahub" )
245
+ default_config = ClusterConfiguration (
246
+ name = "unit-test-default-cluster" ,
247
+ )
248
+ cluster = Cluster (default_config )
249
+
250
+ assert cluster .app_wrapper_yaml == "unit-test-default-cluster.yaml"
251
+ assert cluster .app_wrapper_name == "unit-test-default-cluster"
252
+ assert cluster .config .namespace == "opendatahub"
253
+
254
+ return cluster
255
+
256
+
243
257
def arg_check_apply_effect (* args ):
244
258
assert args [0 ] == "apply"
245
259
assert args [1 ] == ["-f" , "unit-test-cluster.yaml" ]
You can’t perform that action at this time.
0 commit comments