@@ -94,7 +94,6 @@ def log_create_complete(
94
94
resource (proto.Message):
95
95
AI Platform Resourc proto.Message
96
96
variable_name (str): Name of variable to use for code snippet
97
-
98
97
"""
99
98
self ._logger .info (f"{ cls .__name__ } created. Resource name: { resource .name } " )
100
99
self ._logger .info (f"To use this { cls .__name__ } in another session:" )
@@ -181,7 +180,8 @@ def _raise_future_exception(self):
181
180
raise self ._exception
182
181
183
182
def _complete_future (self , future : futures .Future ):
184
- """Checks for exception of future and removes the pointer if it's still latest.
183
+ """Checks for exception of future and removes the pointer if it's still
184
+ latest.
185
185
186
186
Args:
187
187
future (futures.Future): Required. A future to complete.
@@ -215,13 +215,14 @@ def wait(self):
215
215
216
216
@property
217
217
def _latest_future (self ) -> Optional [futures .Future ]:
218
- """Get the latest future if it exists"""
218
+ """Get the latest future if it exists. """
219
219
with self .__latest_future_lock :
220
220
return self .__latest_future
221
221
222
222
@_latest_future .setter
223
223
def _latest_future (self , future : Optional [futures .Future ]):
224
- """Optionally set the latest future and add a complete_future callback."""
224
+ """Optionally set the latest future and add a complete_future
225
+ callback."""
225
226
with self .__latest_future_lock :
226
227
self .__latest_future = future
227
228
if future :
@@ -260,7 +261,8 @@ def wait_for_dependencies_and_invoke(
260
261
kwargs : Dict [str , Any ],
261
262
internal_callbacks : Iterable [Callable [[Any ], Any ]],
262
263
) -> Any :
263
- """Wrapper method to wait on any dependencies before submitting method.
264
+ """Wrapper method to wait on any dependencies before submitting
265
+ method.
264
266
265
267
Args:
266
268
deps (Sequence[futures.Future]):
@@ -272,7 +274,6 @@ def wait_for_dependencies_and_invoke(
272
274
Required. The keyword arguments to call the method with.
273
275
internal_callbacks: (Callable[[Any], Any]):
274
276
Callbacks that take the result of method.
275
-
276
277
"""
277
278
278
279
for future in set (deps ):
@@ -342,12 +343,14 @@ def wait_for_dependencies_and_invoke(
342
343
@classmethod
343
344
@abc .abstractmethod
344
345
def _empty_constructor (cls ) -> "FutureManager" :
345
- """Should construct object with all non FutureManager attributes as None"""
346
+ """Should construct object with all non FutureManager attributes as
347
+ None."""
346
348
pass
347
349
348
350
@abc .abstractmethod
349
351
def _sync_object_with_future_result (self , result : "FutureManager" ):
350
- """Should sync the object from _empty_constructor with result of future."""
352
+ """Should sync the object from _empty_constructor with result of
353
+ future."""
351
354
352
355
def __repr__ (self ) -> str :
353
356
if self ._exception :
@@ -375,7 +378,8 @@ class AiPlatformResourceNoun(metaclass=abc.ABCMeta):
375
378
@classmethod
376
379
@abc .abstractmethod
377
380
def client_class (cls ) -> Type [utils .AiPlatformServiceClientWithOverride ]:
378
- """Client class required to interact with resource with optional overrides."""
381
+ """Client class required to interact with resource with optional
382
+ overrides."""
379
383
pass
380
384
381
385
@property
@@ -388,7 +392,8 @@ def _is_client_prediction_client(cls) -> bool:
388
392
@property
389
393
@abc .abstractmethod
390
394
def _getter_method (cls ) -> str :
391
- """Name of getter method of client class for retrieving the resource."""
395
+ """Name of getter method of client class for retrieving the
396
+ resource."""
392
397
pass
393
398
394
399
@property
@@ -400,7 +405,7 @@ def _delete_method(cls) -> str:
400
405
@property
401
406
@abc .abstractmethod
402
407
def _resource_noun (cls ) -> str :
403
- """Resource noun"""
408
+ """Resource noun. """
404
409
pass
405
410
406
411
def __init__ (
@@ -547,7 +552,8 @@ def optional_sync(
547
552
return_input_arg : Optional [str ] = None ,
548
553
bind_future_to_self : bool = True ,
549
554
):
550
- """Decorator for AiPlatformResourceNounWithFutureManager with optional sync support.
555
+ """Decorator for AiPlatformResourceNounWithFutureManager with optional sync
556
+ support.
551
557
552
558
Methods with this decorator should include a "sync" argument that defaults to
553
559
True. If called with sync=False this decorator will launch the method as a
@@ -681,7 +687,8 @@ def wrapper(*args, **kwargs):
681
687
682
688
683
689
class AiPlatformResourceNounWithFutureManager (AiPlatformResourceNoun , FutureManager ):
684
- """Allows optional asynchronous calls to this AI Platform Resource Nouns."""
690
+ """Allows optional asynchronous calls to this AI Platform Resource
691
+ Nouns."""
685
692
686
693
def __init__ (
687
694
self ,
@@ -816,7 +823,8 @@ def _list(
816
823
credentials : Optional [auth_credentials .Credentials ] = None ,
817
824
) -> List [AiPlatformResourceNoun ]:
818
825
"""Private method to list all instances of this AI Platform Resource,
819
- takes a `cls_filter` arg to filter to a particular SDK resource subclass.
826
+ takes a `cls_filter` arg to filter to a particular SDK resource
827
+ subclass.
820
828
821
829
Args:
822
830
cls_filter (Callable[[proto.Message], bool]):
@@ -884,8 +892,9 @@ def _list_with_local_order(
884
892
credentials : Optional [auth_credentials .Credentials ] = None ,
885
893
) -> List [AiPlatformResourceNoun ]:
886
894
"""Private method to list all instances of this AI Platform Resource,
887
- takes a `cls_filter` arg to filter to a particular SDK resource subclass.
888
- Provides client-side sorting when a list API doesn't support `order_by`.
895
+ takes a `cls_filter` arg to filter to a particular SDK resource
896
+ subclass. Provides client-side sorting when a list API doesn't support
897
+ `order_by`.
889
898
890
899
Args:
891
900
cls_filter (Callable[[proto.Message], bool]):
@@ -986,7 +995,8 @@ def list(
986
995
987
996
@optional_sync ()
988
997
def delete (self , sync : bool = True ) -> None :
989
- """Deletes this AI Platform resource. WARNING: This deletion is permament.
998
+ """Deletes this AI Platform resource. WARNING: This deletion is
999
+ permament.
990
1000
991
1001
Args:
992
1002
sync (bool):
0 commit comments