@@ -42,20 +42,9 @@ def has_bigquery(self):
42
42
def has_gcs (self ):
43
43
return GcpTarget .GCS in self .integrations
44
44
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
59
48
60
49
class KaggleKernelCredentials (credentials .Credentials ):
61
50
"""Custom Credentials used to authenticate using the Kernel's connected OAuth account.
@@ -74,16 +63,8 @@ def refresh(self, request):
74
63
self .token , self .expiry = client .get_bigquery_access_token ()
75
64
elif self .target == GcpTarget .GCS :
76
65
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 ()
87
68
except ConnectionError as e :
88
69
Log .error (f"Connection error trying to refresh access token: { e } " )
89
70
print ("There was a connection error trying to fetch the access token. "
@@ -262,12 +243,12 @@ def init_automl():
262
243
return
263
244
264
245
from kaggle_gcp import get_integrations
265
- if not get_integrations ().has_automl ():
246
+ if not get_integrations ().has_cloudai ():
266
247
return
267
248
268
249
from kaggle_secrets import GcpTarget
269
250
from kaggle_gcp import KaggleKernelCredentials
270
- kaggle_kernel_credentials = KaggleKernelCredentials (target = GcpTarget .AUTOML )
251
+ kaggle_kernel_credentials = KaggleKernelCredentials (target = GcpTarget .CLOUDAI )
271
252
272
253
# Patch the 2 GA clients: AutoMlClient and PreditionServiceClient
273
254
monkeypatch_client (automl .AutoMlClient , kaggle_kernel_credentials )
@@ -293,10 +274,10 @@ def init_translation_v2():
293
274
return translate_v2
294
275
295
276
from kaggle_gcp import get_integrations
296
- if not get_integrations ().has_translation ():
277
+ if not get_integrations ().has_cloudai ():
297
278
return translate_v2
298
279
from kaggle_secrets import GcpTarget
299
- kernel_credentials = KaggleKernelCredentials (target = GcpTarget .TRANSLATION )
280
+ kernel_credentials = KaggleKernelCredentials (target = GcpTarget .CLOUDAI )
300
281
monkeypatch_client (translate_v2 .Client , kernel_credentials )
301
282
return translate_v2
302
283
@@ -307,10 +288,10 @@ def init_translation_v3():
307
288
return translate_v3
308
289
309
290
from kaggle_gcp import get_integrations
310
- if not get_integrations ().has_translation ():
291
+ if not get_integrations ().has_cloudai ():
311
292
return translate_v3
312
293
from kaggle_secrets import GcpTarget
313
- kernel_credentials = KaggleKernelCredentials (target = GcpTarget .TRANSLATION )
294
+ kernel_credentials = KaggleKernelCredentials (target = GcpTarget .CLOUDAI )
314
295
monkeypatch_client (translate_v3 .TranslationServiceClient , kernel_credentials )
315
296
return translate_v3
316
297
@@ -320,11 +301,11 @@ def init_natural_language():
320
301
return language
321
302
322
303
from kaggle_gcp import get_integrations
323
- if not get_integrations ().has_natural_language ():
304
+ if not get_integrations ().has_cloudai ():
324
305
return language
325
306
326
307
from kaggle_secrets import GcpTarget
327
- kernel_credentials = KaggleKernelCredentials (target = GcpTarget .NATURAL_LANGUAGE )
308
+ kernel_credentials = KaggleKernelCredentials (target = GcpTarget .CLOUDAI )
328
309
monkeypatch_client (language .LanguageServiceClient , kernel_credentials )
329
310
monkeypatch_client (language .LanguageServiceAsyncClient , kernel_credentials )
330
311
return language
@@ -335,11 +316,11 @@ def init_video_intelligence():
335
316
return videointelligence
336
317
337
318
from kaggle_gcp import get_integrations
338
- if not get_integrations ().has_video_intelligence ():
319
+ if not get_integrations ().has_cloudai ():
339
320
return videointelligence
340
321
341
322
from kaggle_secrets import GcpTarget
342
- kernel_credentials = KaggleKernelCredentials (target = GcpTarget .VIDEO_INTELLIGENCE )
323
+ kernel_credentials = KaggleKernelCredentials (target = GcpTarget .CLOUDAI )
343
324
monkeypatch_client (
344
325
videointelligence .VideoIntelligenceServiceClient ,
345
326
kernel_credentials )
@@ -354,11 +335,11 @@ def init_vision():
354
335
return vision
355
336
356
337
from kaggle_gcp import get_integrations
357
- if not get_integrations ().has_vision ():
338
+ if not get_integrations ().has_cloudai ():
358
339
return vision
359
340
360
341
from kaggle_secrets import GcpTarget
361
- kernel_credentials = KaggleKernelCredentials (target = GcpTarget .VISION )
342
+ kernel_credentials = KaggleKernelCredentials (target = GcpTarget .CLOUDAI )
362
343
monkeypatch_client (vision .ImageAnnotatorClient , kernel_credentials )
363
344
monkeypatch_client (vision .ImageAnnotatorAsyncClient , kernel_credentials )
364
345
return vision
0 commit comments