1010
1111import logging
1212from openshift .dynamic import DynamicClient
13- from openshift .dynamic .exceptions import NotFoundError , ResourceNotFoundError , UnauthorizedError
13+ from openshift .dynamic .exceptions import (
14+ NotFoundError ,
15+ ResourceNotFoundError ,
16+ UnauthorizedError ,
17+ )
1418
1519from .ocp import listInstances
1620from .olm import getSubscription
@@ -53,7 +57,9 @@ def verifyAiServiceInstance(dynClient: DynamicClient, instanceId: str) -> bool:
5357 or authorization fails.
5458 """
5559 try :
56- aiserviceAPI = dynClient .resources .get (api_version = "aiservice.ibm.com/v1" , kind = "AIServiceApp" )
60+ aiserviceAPI = dynClient .resources .get (
61+ api_version = "aiservice.ibm.com/v1" , kind = "AIServiceApp"
62+ )
5763 aiserviceAPI .get (name = instanceId , namespace = f"aiservice-{ instanceId } " )
5864 return True
5965 except NotFoundError :
@@ -64,7 +70,9 @@ def verifyAiServiceInstance(dynClient: DynamicClient, instanceId: str) -> bool:
6470 print ("RESOURCE NOT FOUND" )
6571 return False
6672 except UnauthorizedError as e :
67- logger .error (f"Error: Unable to verify AI Service instance due to failed authorization: { e } " )
73+ logger .error (
74+ f"Error: Unable to verify AI Service instance due to failed authorization: { e } "
75+ )
6876 return False
6977
7078
@@ -85,7 +93,9 @@ def listAiServiceTenantInstances(dynClient: DynamicClient) -> list:
8593 return listInstances (dynClient , "aiservice.ibm.com/v1" , "AIServiceTenant" )
8694
8795
88- def verifyAiServiceTenantInstance (dynClient : DynamicClient , instanceId : str , tenantId : str ) -> bool :
96+ def verifyAiServiceTenantInstance (
97+ dynClient : DynamicClient , instanceId : str , tenantId : str
98+ ) -> bool :
8999 """
90100 Verify that a specific AI Service Tenant exists in the cluster.
91101
@@ -104,8 +114,13 @@ def verifyAiServiceTenantInstance(dynClient: DynamicClient, instanceId: str, ten
104114 or authorization fails.
105115 """
106116 try :
107- aiserviceTenantAPI = dynClient .resources .get (api_version = "aiservice.ibm.com/v1" , kind = "AIServiceTenant" )
108- aiserviceTenantAPI .get (name = f"aiservice-{ instanceId } -{ tenantId } " , namespace = f"aiservice-{ instanceId } " )
117+ aiserviceTenantAPI = dynClient .resources .get (
118+ api_version = "aiservice.ibm.com/v1" , kind = "AIServiceTenant"
119+ )
120+ aiserviceTenantAPI .get (
121+ name = f"aiservice-{ instanceId } -{ tenantId } " ,
122+ namespace = f"aiservice-{ instanceId } " ,
123+ )
109124 return True
110125 except NotFoundError :
111126 print ("NOT FOUND" )
@@ -115,7 +130,9 @@ def verifyAiServiceTenantInstance(dynClient: DynamicClient, instanceId: str, ten
115130 print ("RESOURCE NOT FOUND" )
116131 return False
117132 except UnauthorizedError as e :
118- logger .error (f"Error: Unable to verify AI Service Tenant due to failed authorization: { e } " )
133+ logger .error (
134+ f"Error: Unable to verify AI Service Tenant due to failed authorization: { e } "
135+ )
119136 return False
120137
121138
@@ -134,7 +151,9 @@ def getAiserviceChannel(dynClient: DynamicClient, instanceId: str) -> str | None
134151 str: The channel name (e.g., "v1.0", "stable") if the subscription exists,
135152 None if the subscription is not found.
136153 """
137- aiserviceSubscription = getSubscription (dynClient , f"aiservice-{ instanceId } " , "ibm-aiservice" )
154+ aiserviceSubscription = getSubscription (
155+ dynClient , f"aiservice-{ instanceId } " , "ibm-aiservice"
156+ )
138157 if aiserviceSubscription is None :
139158 return None
140159 else :
0 commit comments