@@ -217,6 +217,7 @@ def test_create_basic_cluster(self, cluster_with_basic_executor, mock_k8s_client
217217 assert body ["metadata" ]["name" ] == "testuser-test-cluster-raycluster"
218218 assert body ["metadata" ]["namespace" ] == "test-namespace"
219219 assert body ["spec" ]["rayVersion" ] == "2.43.0"
220+
220221 def test_create_advanced_cluster (self , cluster_with_advanced_executor , mock_k8s_clients ):
221222 """Test creating an advanced Ray cluster with volumes and custom settings."""
222223 mock_api , _ = mock_k8s_clients
@@ -747,9 +748,11 @@ class TestKubeRayExecutorUtilityFunctions:
747748 @pytest .fixture
748749 def basic_cluster_dict (self ):
749750 """Create a basic cluster dictionary for testing."""
750- from nemo_run .core .execution .kuberay import (populate_meta ,
751- populate_ray_head ,
752- populate_worker_group )
751+ from nemo_run .core .execution .kuberay import (
752+ populate_meta ,
753+ populate_ray_head ,
754+ populate_worker_group ,
755+ )
753756
754757 cluster = {}
755758 cluster = populate_meta (cluster , "test-cluster" , "default" , {}, "2.43.0" )
@@ -863,8 +866,7 @@ def test_populate_ray_head_missing_spec(self):
863866
864867 def test_populate_ray_head_without_dashboard_host (self ):
865868 """Test populate_ray_head automatically adds dashboard-host."""
866- from nemo_run .core .execution .kuberay import (populate_meta ,
867- populate_ray_head )
869+ from nemo_run .core .execution .kuberay import populate_meta , populate_ray_head
868870
869871 cluster = populate_meta ({}, "test-cluster" , "default" , {}, "2.43.0" )
870872 ray_start_params = {}
@@ -891,8 +893,7 @@ def test_populate_ray_head_without_dashboard_host(self):
891893
892894 def test_update_worker_group_replicas_success (self , basic_cluster_dict ):
893895 """Test successfully updating worker group replicas."""
894- from nemo_run .core .execution .kuberay import \
895- update_worker_group_replicas
896+ from nemo_run .core .execution .kuberay import update_worker_group_replicas
896897
897898 cluster , success = update_worker_group_replicas (
898899 basic_cluster_dict , "workers" , max_replicas = 5 , min_replicas = 1 , replicas = 3
@@ -906,8 +907,7 @@ def test_update_worker_group_replicas_success(self, basic_cluster_dict):
906907
907908 def test_update_worker_group_replicas_not_found (self , basic_cluster_dict ):
908909 """Test updating non-existent worker group replicas."""
909- from nemo_run .core .execution .kuberay import \
910- update_worker_group_replicas
910+ from nemo_run .core .execution .kuberay import update_worker_group_replicas
911911
912912 cluster , success = update_worker_group_replicas (
913913 basic_cluster_dict , "nonexistent" , max_replicas = 5 , min_replicas = 1 , replicas = 3
@@ -917,8 +917,7 @@ def test_update_worker_group_replicas_not_found(self, basic_cluster_dict):
917917
918918 def test_update_worker_group_resources_success (self , basic_cluster_dict ):
919919 """Test successfully updating worker group resources."""
920- from nemo_run .core .execution .kuberay import \
921- update_worker_group_resources
920+ from nemo_run .core .execution .kuberay import update_worker_group_resources
922921
923922 cluster , success = update_worker_group_resources (
924923 basic_cluster_dict ,
@@ -938,8 +937,7 @@ def test_update_worker_group_resources_success(self, basic_cluster_dict):
938937
939938 def test_update_worker_group_resources_all_containers (self , basic_cluster_dict ):
940939 """Test updating resources for all containers in a worker group."""
941- from nemo_run .core .execution .kuberay import \
942- update_worker_group_resources
940+ from nemo_run .core .execution .kuberay import update_worker_group_resources
943941
944942 # Add another container to test "all_containers" functionality
945943 basic_cluster_dict ["spec" ]["workerGroupSpecs" ][0 ]["template" ]["spec" ]["containers" ].append (
@@ -968,8 +966,7 @@ def test_update_worker_group_resources_all_containers(self, basic_cluster_dict):
968966
969967 def test_update_worker_group_resources_specific_container (self , basic_cluster_dict ):
970968 """Test updating resources for a specific container."""
971- from nemo_run .core .execution .kuberay import \
972- update_worker_group_resources
969+ from nemo_run .core .execution .kuberay import update_worker_group_resources
973970
974971 # Add another container
975972 basic_cluster_dict ["spec" ]["workerGroupSpecs" ][0 ]["template" ]["spec" ]["containers" ].append (
@@ -996,8 +993,7 @@ def test_update_worker_group_resources_specific_container(self, basic_cluster_di
996993
997994 def test_update_worker_group_resources_no_containers (self ):
998995 """Test updating resources when worker group has no containers."""
999- from nemo_run .core .execution .kuberay import \
1000- update_worker_group_resources
996+ from nemo_run .core .execution .kuberay import update_worker_group_resources
1001997
1002998 cluster = {
1003999 "spec" : {
@@ -1067,8 +1063,7 @@ def test_delete_worker_group_not_found(self, basic_cluster_dict):
10671063
10681064 def test_worker_group_with_labels_and_annotations (self ):
10691065 """Test creating worker group with labels and annotations."""
1070- from nemo_run .core .execution .kuberay import (populate_meta ,
1071- populate_worker_group )
1066+ from nemo_run .core .execution .kuberay import populate_meta , populate_worker_group
10721067
10731068 cluster = populate_meta ({}, "test-cluster" , "default" , {}, "2.43.0" )
10741069 cluster ["spec" ]["workerGroupSpecs" ] = []
@@ -2189,9 +2184,7 @@ def test_kuberay_job_both_configs_fail(self):
21892184
21902185 def test_executor_load_kube_config_success (self ):
21912186 """Test successful loading of kube config for KubeRayExecutor."""
2192- with patch (
2193- "nemo_run.core.execution.kuberay.config.load_kube_config"
2194- ) as mock_load_kube :
2187+ with patch ("nemo_run.core.execution.kuberay.config.load_kube_config" ) as mock_load_kube :
21952188 with patch ("nemo_run.core.execution.kuberay.client.CustomObjectsApi" ):
21962189 with patch ("nemo_run.core.execution.kuberay.client.CoreV1Api" ):
21972190 executor = KubeRayExecutor (namespace = "test-namespace" )
@@ -2234,15 +2227,3 @@ def test_executor_both_configs_fail(self):
22342227
22352228 # Should raise the original kube config error
22362229 assert exc_info .value == kube_config_error
2237- ):
2238- with pytest .raises (Exception ) as exc_info :
2239- KubeRayExecutor (namespace = "test-namespace" )
2240-
2241- # Should raise the original kube config error
2242- assert exc_info .value == kube_config_error
2243- ):
2244- with pytest .raises (Exception ) as exc_info :
2245- KubeRayExecutor (namespace = "test-namespace" )
2246-
2247- # Should raise the original kube config error
2248- assert exc_info .value == kube_config_error
0 commit comments