@@ -42,20 +42,9 @@ def has_bigquery(self):
4242 def has_gcs (self ):
4343 return GcpTarget .GCS in self .integrations
4444
45- def has_automl (self ):
46- return GcpTarget .AUTOML in self .integrations
47-
48- def has_translation (self ):
49- return GcpTarget .TRANSLATION in self .integrations
50-
51- def has_natural_language (self ):
52- return GcpTarget .NATURAL_LANGUAGE in self .integrations
53-
54- def has_video_intelligence (self ):
55- return GcpTarget .VIDEO_INTELLIGENCE in self .integrations
56-
57- def has_vision (self ):
58- return GcpTarget .VISION in self .integrations
45+ def has_cloudai (self ):
46+ return GcpTarget .CLOUDAI in self .integrations or \
47+ GcpTarget .AUTOML in self .integrations
5948
6049class KaggleKernelCredentials (credentials .Credentials ):
6150 """Custom Credentials used to authenticate using the Kernel's connected OAuth account.
@@ -74,16 +63,8 @@ def refresh(self, request):
7463 self .token , self .expiry = client .get_bigquery_access_token ()
7564 elif self .target == GcpTarget .GCS :
7665 self .token , self .expiry = client ._get_gcs_access_token ()
77- elif self .target == GcpTarget .AUTOML :
78- self .token , self .expiry = client ._get_automl_access_token ()
79- elif self .target == GcpTarget .TRANSLATION :
80- self .token , self .expiry = client ._get_translation_access_token ()
81- elif self .target == GcpTarget .NATURAL_LANGUAGE :
82- self .token , self .expiry = client ._get_natural_language_access_token ()
83- elif self .target == GcpTarget .VIDEO_INTELLIGENCE :
84- self .token , self .expiry = client ._get_video_intelligence_access_token ()
85- elif self .target == GcpTarget .VISION :
86- self .token , self .expiry = client ._get_vision_access_token ()
66+ elif self .target == GcpTarget .CLOUDAI :
67+ self .token , self .expiry = client ._get_cloudai_access_token ()
8768 except ConnectionError as e :
8869 Log .error (f"Connection error trying to refresh access token: { e } " )
8970 print ("There was a connection error trying to fetch the access token. "
@@ -262,12 +243,12 @@ def init_automl():
262243 return
263244
264245 from kaggle_gcp import get_integrations
265- if not get_integrations ().has_automl ():
246+ if not get_integrations ().has_cloudai ():
266247 return
267248
268249 from kaggle_secrets import GcpTarget
269250 from kaggle_gcp import KaggleKernelCredentials
270- kaggle_kernel_credentials = KaggleKernelCredentials (target = GcpTarget .AUTOML )
251+ kaggle_kernel_credentials = KaggleKernelCredentials (target = GcpTarget .CLOUDAI )
271252
272253 # Patch the 2 GA clients: AutoMlClient and PreditionServiceClient
273254 monkeypatch_client (automl .AutoMlClient , kaggle_kernel_credentials )
@@ -293,10 +274,10 @@ def init_translation_v2():
293274 return translate_v2
294275
295276 from kaggle_gcp import get_integrations
296- if not get_integrations ().has_translation ():
277+ if not get_integrations ().has_cloudai ():
297278 return translate_v2
298279 from kaggle_secrets import GcpTarget
299- kernel_credentials = KaggleKernelCredentials (target = GcpTarget .TRANSLATION )
280+ kernel_credentials = KaggleKernelCredentials (target = GcpTarget .CLOUDAI )
300281 monkeypatch_client (translate_v2 .Client , kernel_credentials )
301282 return translate_v2
302283
@@ -307,10 +288,10 @@ def init_translation_v3():
307288 return translate_v3
308289
309290 from kaggle_gcp import get_integrations
310- if not get_integrations ().has_translation ():
291+ if not get_integrations ().has_cloudai ():
311292 return translate_v3
312293 from kaggle_secrets import GcpTarget
313- kernel_credentials = KaggleKernelCredentials (target = GcpTarget .TRANSLATION )
294+ kernel_credentials = KaggleKernelCredentials (target = GcpTarget .CLOUDAI )
314295 monkeypatch_client (translate_v3 .TranslationServiceClient , kernel_credentials )
315296 return translate_v3
316297
@@ -320,11 +301,11 @@ def init_natural_language():
320301 return language
321302
322303 from kaggle_gcp import get_integrations
323- if not get_integrations ().has_natural_language ():
304+ if not get_integrations ().has_cloudai ():
324305 return language
325306
326307 from kaggle_secrets import GcpTarget
327- kernel_credentials = KaggleKernelCredentials (target = GcpTarget .NATURAL_LANGUAGE )
308+ kernel_credentials = KaggleKernelCredentials (target = GcpTarget .CLOUDAI )
328309 monkeypatch_client (language .LanguageServiceClient , kernel_credentials )
329310 monkeypatch_client (language .LanguageServiceAsyncClient , kernel_credentials )
330311 return language
@@ -335,11 +316,11 @@ def init_video_intelligence():
335316 return videointelligence
336317
337318 from kaggle_gcp import get_integrations
338- if not get_integrations ().has_video_intelligence ():
319+ if not get_integrations ().has_cloudai ():
339320 return videointelligence
340321
341322 from kaggle_secrets import GcpTarget
342- kernel_credentials = KaggleKernelCredentials (target = GcpTarget .VIDEO_INTELLIGENCE )
323+ kernel_credentials = KaggleKernelCredentials (target = GcpTarget .CLOUDAI )
343324 monkeypatch_client (
344325 videointelligence .VideoIntelligenceServiceClient ,
345326 kernel_credentials )
@@ -354,11 +335,11 @@ def init_vision():
354335 return vision
355336
356337 from kaggle_gcp import get_integrations
357- if not get_integrations ().has_vision ():
338+ if not get_integrations ().has_cloudai ():
358339 return vision
359340
360341 from kaggle_secrets import GcpTarget
361- kernel_credentials = KaggleKernelCredentials (target = GcpTarget .VISION )
342+ kernel_credentials = KaggleKernelCredentials (target = GcpTarget .CLOUDAI )
362343 monkeypatch_client (vision .ImageAnnotatorClient , kernel_credentials )
363344 monkeypatch_client (vision .ImageAnnotatorAsyncClient , kernel_credentials )
364345 return vision
0 commit comments