@@ -125,6 +125,7 @@ class MfgInspector(object):
125
125
SCOPE_CODE_URI = 'https://www.googleapis.com/auth/glass.infra.quantum_upload'
126
126
DESTINATION_URL = ('https://clients2.google.com/factoryfactory/'
127
127
'uploads/quantum_upload/?json' )
128
+ PARAMS = ['dut_id' , 'end_time_millis' , 'start_time_millis' , 'station_id' ]
128
129
129
130
# These attributes control format of callback and what actions are undertaken
130
131
# when called. These should either be set by a subclass or via configure.
@@ -158,6 +159,7 @@ def __init__(self, user=None, keydata=None,
158
159
self .upload_result = None
159
160
160
161
self ._cached_proto = None
162
+ self ._cached_params = dict .fromkeys (self .PARAMS )
161
163
162
164
@classmethod
163
165
def from_json (cls , json_data ):
@@ -177,12 +179,19 @@ def from_json(cls, json_data):
177
179
keydata = json_data ['private_key' ],
178
180
token_uri = json_data ['token_uri' ])
179
181
182
+ def _check_cached_params (self , test_record_obj ):
183
+ """Check if all cached params equal the values in test record."""
184
+ for param in self .PARAMS :
185
+ if self ._cached_params [param ] != getattr (test_record_obj , param ):
186
+ return False
187
+ return True
188
+
180
189
def _convert (self , test_record_obj ):
181
190
"""Convert and cache a test record to a mfg-inspector proto."""
182
-
183
- if self ._cached_proto is None :
191
+ if self ._cached_proto is None or not self ._check_cached_params (test_record_obj ):
184
192
self ._cached_proto = self ._converter (test_record_obj )
185
-
193
+ for param in self .PARAMS :
194
+ self ._cached_params [param ] = getattr (test_record_obj , param )
186
195
return self ._cached_proto
187
196
188
197
def save_to_disk (self , filename_pattern = None ):
0 commit comments