@@ -210,13 +210,13 @@ def from_dict(cls, data, app=None):
210
210
tflite_format = TFLiteFormat .from_dict (tflite_format_data )
211
211
model = Model (model_format = tflite_format )
212
212
model ._data = data_copy # pylint: disable=protected-access
213
- model ._app = app # pylint: disable=protected-access
213
+ model ._app = app # pylint: disable=protected-access
214
214
return model
215
215
216
216
def _update_from_dict (self , data ):
217
217
copy = Model .from_dict (data )
218
218
self .model_format = copy .model_format
219
- self ._data = copy ._data # pylint: disable=protected-access
219
+ self ._data = copy ._data # pylint: disable=protected-access
220
220
221
221
def __eq__ (self , other ):
222
222
if isinstance (other , self .__class__ ):
@@ -333,7 +333,7 @@ def model_format(self):
333
333
def model_format (self , model_format ):
334
334
if model_format is not None :
335
335
_validate_model_format (model_format )
336
- self ._model_format = model_format #Can be None
336
+ self ._model_format = model_format # Can be None
337
337
return self
338
338
339
339
def as_dict (self , for_upload = False ):
@@ -369,7 +369,7 @@ def from_dict(cls, data):
369
369
"""Create an instance of the object from a dict."""
370
370
data_copy = dict (data )
371
371
tflite_format = TFLiteFormat (model_source = cls ._init_model_source (data_copy ))
372
- tflite_format ._data = data_copy # pylint: disable=protected-access
372
+ tflite_format ._data = data_copy # pylint: disable=protected-access
373
373
return tflite_format
374
374
375
375
def __eq__ (self , other ):
@@ -401,7 +401,7 @@ def model_source(self, model_source):
401
401
if model_source is not None :
402
402
if not isinstance (model_source , TFLiteModelSource ):
403
403
raise TypeError ('Model source must be a TFLiteModelSource object.' )
404
- self ._model_source = model_source # Can be None
404
+ self ._model_source = model_source # Can be None
405
405
406
406
@property
407
407
def size_bytes (self ):
@@ -481,7 +481,7 @@ def __init__(self, gcs_tflite_uri, app=None):
481
481
482
482
def __eq__ (self , other ):
483
483
if isinstance (other , self .__class__ ):
484
- return self ._gcs_tflite_uri == other ._gcs_tflite_uri # pylint: disable=protected-access
484
+ return self ._gcs_tflite_uri == other ._gcs_tflite_uri # pylint: disable=protected-access
485
485
return False
486
486
487
487
def __ne__ (self , other ):
@@ -766,7 +766,7 @@ def _validate_display_name(display_name):
766
766
767
767
def _validate_tags (tags ):
768
768
if not isinstance (tags , list ) or not \
769
- all (isinstance (tag , str ) for tag in tags ):
769
+ all (isinstance (tag , str ) for tag in tags ):
770
770
raise TypeError ('Tags must be a list of strings.' )
771
771
if not all (_TAG_PATTERN .match (tag ) for tag in tags ):
772
772
raise ValueError ('Tag format is invalid.' )
@@ -780,6 +780,7 @@ def _validate_gcs_tflite_uri(uri):
780
780
raise ValueError ('GCS TFLite URI format is invalid.' )
781
781
return uri
782
782
783
+
783
784
def _validate_auto_ml_model (model ):
784
785
if not _AUTO_ML_MODEL_PATTERN .match (model ):
785
786
raise ValueError ('Model resource name format is invalid.' )
@@ -800,7 +801,7 @@ def _validate_list_filter(list_filter):
800
801
801
802
def _validate_page_size (page_size ):
802
803
if page_size is not None :
803
- if type (page_size ) is not int : # pylint: disable=unidiomatic-typecheck
804
+ if type (page_size ) is not int : # pylint: disable=unidiomatic-typecheck
804
805
# Specifically type() to disallow boolean which is a subtype of int
805
806
raise TypeError ('Page size must be a number or None.' )
806
807
if page_size < 1 or page_size > _MAX_PAGE_SIZE :
@@ -855,7 +856,7 @@ def _exponential_backoff(self, current_attempt, stop_time):
855
856
856
857
if stop_time is not None :
857
858
max_seconds_left = (stop_time - datetime .datetime .now ()).total_seconds ()
858
- if max_seconds_left < 1 : # allow a bit of time for rpc
859
+ if max_seconds_left < 1 : # allow a bit of time for rpc
859
860
raise exceptions .DeadlineExceededError ('Polling max time exceeded.' )
860
861
wait_time_seconds = min (wait_time_seconds , max_seconds_left - 1 )
861
862
time .sleep (wait_time_seconds )
@@ -916,7 +917,6 @@ def handle_operation(self, operation, wait_for_operation=False, max_time_seconds
916
917
# If the operation is not complete or timed out, return a (locked) model instead
917
918
return get_model (model_id ).as_dict ()
918
919
919
-
920
920
def create_model (self , model ):
921
921
_validate_model (model )
922
922
try :
0 commit comments