@@ -412,7 +412,7 @@ def list_all_clusters(namespace: str, print_to_console: bool = True):
412
412
"""
413
413
Returns (and prints by default) a list of all clusters in a given namespace.
414
414
"""
415
- clusters = _get_ray_clusters_in_namespace (namespace )
415
+ clusters = _get_all_ray_clusters (namespace )
416
416
if print_to_console :
417
417
pretty_print .print_clusters (clusters )
418
418
return clusters
@@ -539,17 +539,24 @@ def _ray_cluster_status(name, namespace="default") -> Optional[RayCluster]:
539
539
return None
540
540
541
541
542
- def _get_ray_clusters_in_namespace (namespace = "default" ) -> List [RayCluster ]:
542
+ def _get_all_ray_clusters (namespace : str = None ) -> List [RayCluster ]:
543
543
list_of_clusters = []
544
544
try :
545
545
config_check ()
546
546
api_instance = client .CustomObjectsApi (api_config_handler ())
547
- rcs = api_instance .list_namespaced_custom_object (
548
- group = "ray.io" ,
549
- version = "v1alpha1" ,
550
- namespace = namespace ,
551
- plural = "rayclusters" ,
552
- )
547
+ if namespace :
548
+ rcs = api_instance .list_namespaced_custom_object (
549
+ group = "ray.io" ,
550
+ version = "v1alpha1" ,
551
+ namespace = namespace ,
552
+ plural = "rayclusters" ,
553
+ )
554
+ else :
555
+ rcs = api_instance .list_cluster_custom_object (
556
+ group = "ray.io" ,
557
+ version = "v1alpha1" ,
558
+ plural = "rayclusters" ,
559
+ )
553
560
except Exception as e : # pragma: no cover
554
561
return _kube_api_error_handling (e )
555
562
@@ -558,23 +565,6 @@ def _get_ray_clusters_in_namespace(namespace="default") -> List[RayCluster]:
558
565
return list_of_clusters
559
566
560
567
561
- def _get_all_ray_clusters () -> List [RayCluster ]:
562
- list_of_clusters = []
563
- try :
564
- config_check ()
565
- api_instance = client .CustomObjectsApi (api_config_handler ())
566
- rcs = api_instance .list_cluster_custom_object (
567
- group = "ray.io" ,
568
- version = "v1alpha1" ,
569
- plural = "rayclusters" ,
570
- )
571
- except Exception as e :
572
- return _kube_api_error_handling (e )
573
- for rc in rcs ["items" ]:
574
- list_of_clusters .append (_map_to_ray_cluster (rc ))
575
- return list_of_clusters
576
-
577
-
578
568
def _get_app_wrappers (
579
569
namespace = "default" , filter = List [AppWrapperStatus ]
580
570
) -> List [AppWrapper ]:
0 commit comments