25
25
from kubernetes import config
26
26
from ray .job_submission import JobSubmissionClient
27
27
28
- from .auth import config_check , api_config_handler
28
+ from .auth import config_check , get_api_client
29
29
from ..utils import pretty_print
30
30
from ..utils .generate_yaml import (
31
31
generate_appwrapper ,
@@ -74,7 +74,7 @@ def __init__(self, config: ClusterConfiguration):
74
74
75
75
@property
76
76
def _client_headers (self ):
77
- k8_client = api_config_handler () or client . ApiClient ()
77
+ k8_client = get_api_client ()
78
78
return {
79
79
"Authorization" : k8_client .configuration .get_api_key_with_prefix (
80
80
"authorization"
@@ -89,7 +89,7 @@ def _client_verify_tls(self):
89
89
90
90
@property
91
91
def job_client (self ):
92
- k8client = api_config_handler () or client . ApiClient ()
92
+ k8client = get_api_client ()
93
93
if self ._job_submission_client :
94
94
return self ._job_submission_client
95
95
if is_openshift_cluster ():
@@ -135,7 +135,7 @@ def up(self):
135
135
136
136
try :
137
137
config_check ()
138
- api_instance = client .CustomObjectsApi (api_config_handler ())
138
+ api_instance = client .CustomObjectsApi (get_api_client ())
139
139
if self .config .appwrapper :
140
140
if self .config .write_to_file :
141
141
with open (self .app_wrapper_yaml ) as f :
@@ -162,7 +162,7 @@ def up(self):
162
162
return _kube_api_error_handling (e )
163
163
164
164
def _throw_for_no_raycluster (self ):
165
- api_instance = client .CustomObjectsApi (api_config_handler ())
165
+ api_instance = client .CustomObjectsApi (get_api_client ())
166
166
try :
167
167
api_instance .list_namespaced_custom_object (
168
168
group = "ray.io" ,
@@ -189,7 +189,7 @@ def down(self):
189
189
self ._throw_for_no_raycluster ()
190
190
try :
191
191
config_check ()
192
- api_instance = client .CustomObjectsApi (api_config_handler ())
192
+ api_instance = client .CustomObjectsApi (get_api_client ())
193
193
if self .config .appwrapper :
194
194
api_instance .delete_namespaced_custom_object (
195
195
group = "workload.codeflare.dev" ,
@@ -344,7 +344,7 @@ def cluster_dashboard_uri(self) -> str:
344
344
config_check ()
345
345
if is_openshift_cluster ():
346
346
try :
347
- api_instance = client .CustomObjectsApi (api_config_handler ())
347
+ api_instance = client .CustomObjectsApi (get_api_client ())
348
348
routes = api_instance .list_namespaced_custom_object (
349
349
group = "route.openshift.io" ,
350
350
version = "v1" ,
@@ -366,7 +366,7 @@ def cluster_dashboard_uri(self) -> str:
366
366
return f"{ protocol } ://{ route ['spec' ]['host' ]} "
367
367
else :
368
368
try :
369
- api_instance = client .NetworkingV1Api (api_config_handler ())
369
+ api_instance = client .NetworkingV1Api (get_api_client ())
370
370
ingresses = api_instance .list_namespaced_ingress (self .config .namespace )
371
371
except Exception as e : # pragma no cover
372
372
return _kube_api_error_handling (e )
@@ -546,7 +546,7 @@ def list_all_queued(
546
546
547
547
548
548
def get_current_namespace (): # pragma: no cover
549
- if api_config_handler () != None :
549
+ if get_api_client () != None :
550
550
if os .path .isfile ("/var/run/secrets/kubernetes.io/serviceaccount/namespace" ):
551
551
try :
552
552
file = open (
@@ -591,7 +591,7 @@ def get_cluster(
591
591
):
592
592
try :
593
593
config_check ()
594
- api_instance = client .CustomObjectsApi (api_config_handler ())
594
+ api_instance = client .CustomObjectsApi (get_api_client ())
595
595
rcs = api_instance .list_namespaced_custom_object (
596
596
group = "ray.io" ,
597
597
version = "v1" ,
@@ -646,7 +646,7 @@ def _create_resources(yamls, namespace: str, api_instance: client.CustomObjectsA
646
646
def _check_aw_exists (name : str , namespace : str ) -> bool :
647
647
try :
648
648
config_check ()
649
- api_instance = client .CustomObjectsApi (api_config_handler ())
649
+ api_instance = client .CustomObjectsApi (get_api_client ())
650
650
aws = api_instance .list_namespaced_custom_object (
651
651
group = "workload.codeflare.dev" ,
652
652
version = "v1beta2" ,
@@ -673,7 +673,7 @@ def _get_ingress_domain(self): # pragma: no cover
673
673
674
674
if is_openshift_cluster ():
675
675
try :
676
- api_instance = client .CustomObjectsApi (api_config_handler ())
676
+ api_instance = client .CustomObjectsApi (get_api_client ())
677
677
678
678
routes = api_instance .list_namespaced_custom_object (
679
679
group = "route.openshift.io" ,
@@ -692,7 +692,7 @@ def _get_ingress_domain(self): # pragma: no cover
692
692
domain = route ["spec" ]["host" ]
693
693
else :
694
694
try :
695
- api_client = client .NetworkingV1Api (api_config_handler ())
695
+ api_client = client .NetworkingV1Api (get_api_client ())
696
696
ingresses = api_client .list_namespaced_ingress (namespace )
697
697
except Exception as e : # pragma: no cover
698
698
return _kube_api_error_handling (e )
@@ -706,7 +706,7 @@ def _get_ingress_domain(self): # pragma: no cover
706
706
def _app_wrapper_status (name , namespace = "default" ) -> Optional [AppWrapper ]:
707
707
try :
708
708
config_check ()
709
- api_instance = client .CustomObjectsApi (api_config_handler ())
709
+ api_instance = client .CustomObjectsApi (get_api_client ())
710
710
aws = api_instance .list_namespaced_custom_object (
711
711
group = "workload.codeflare.dev" ,
712
712
version = "v1beta2" ,
@@ -725,7 +725,7 @@ def _app_wrapper_status(name, namespace="default") -> Optional[AppWrapper]:
725
725
def _ray_cluster_status (name , namespace = "default" ) -> Optional [RayCluster ]:
726
726
try :
727
727
config_check ()
728
- api_instance = client .CustomObjectsApi (api_config_handler ())
728
+ api_instance = client .CustomObjectsApi (get_api_client ())
729
729
rcs = api_instance .list_namespaced_custom_object (
730
730
group = "ray.io" ,
731
731
version = "v1" ,
@@ -747,7 +747,7 @@ def _get_ray_clusters(
747
747
list_of_clusters = []
748
748
try :
749
749
config_check ()
750
- api_instance = client .CustomObjectsApi (api_config_handler ())
750
+ api_instance = client .CustomObjectsApi (get_api_client ())
751
751
rcs = api_instance .list_namespaced_custom_object (
752
752
group = "ray.io" ,
753
753
version = "v1" ,
@@ -776,7 +776,7 @@ def _get_app_wrappers(
776
776
777
777
try :
778
778
config_check ()
779
- api_instance = client .CustomObjectsApi (api_config_handler ())
779
+ api_instance = client .CustomObjectsApi (get_api_client ())
780
780
aws = api_instance .list_namespaced_custom_object (
781
781
group = "workload.codeflare.dev" ,
782
782
version = "v1beta2" ,
@@ -805,7 +805,7 @@ def _map_to_ray_cluster(rc) -> Optional[RayCluster]:
805
805
dashboard_url = None
806
806
if is_openshift_cluster ():
807
807
try :
808
- api_instance = client .CustomObjectsApi (api_config_handler ())
808
+ api_instance = client .CustomObjectsApi (get_api_client ())
809
809
routes = api_instance .list_namespaced_custom_object (
810
810
group = "route.openshift.io" ,
811
811
version = "v1" ,
@@ -824,7 +824,7 @@ def _map_to_ray_cluster(rc) -> Optional[RayCluster]:
824
824
dashboard_url = f"{ protocol } ://{ route ['spec' ]['host' ]} "
825
825
else :
826
826
try :
827
- api_instance = client .NetworkingV1Api (api_config_handler ())
827
+ api_instance = client .NetworkingV1Api (get_api_client ())
828
828
ingresses = api_instance .list_namespaced_ingress (
829
829
rc ["metadata" ]["namespace" ]
830
830
)
0 commit comments