Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(786)

Side by Side Diff: appengine/swarming/message_conversion.py

Issue 1925343002: swarming: IsolatedOperation -> OperationStats (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@master
Patch Set: update comment Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « appengine/swarming/handlers_bot.py ('k') | appengine/swarming/server/task_result.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The LUCI Authors. All rights reserved. 1 # Copyright 2015 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed by the Apache v2.0 license that can be 2 # Use of this source code is governed by the Apache v2.0 license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """This module facilitates conversion from dictionaries to ProtoRPC messages. 5 """This module facilitates conversion from dictionaries to ProtoRPC messages.
6 6
7 Given a dictionary whose keys' names and values' types comport with the 7 Given a dictionary whose keys' names and values' types comport with the
8 fields defined for a protorpc.messages.Message subclass, this module tries to 8 fields defined for a protorpc.messages.Message subclass, this module tries to
9 generate a Message instance that corresponds to the provided dictionary. The 9 generate a Message instance that corresponds to the provided dictionary. The
10 "normal" use case is for ndb.Models which need to be represented as a 10 "normal" use case is for ndb.Models which need to be represented as a
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 """ 169 """
170 outputs_ref = ( 170 outputs_ref = (
171 _ndb_to_rpc(swarming_rpcs.FilesRef, entity.outputs_ref) 171 _ndb_to_rpc(swarming_rpcs.FilesRef, entity.outputs_ref)
172 if entity.outputs_ref else None) 172 if entity.outputs_ref else None)
173 performance_stats = None 173 performance_stats = None
174 if send_stats and entity.performance_stats.is_valid: 174 if send_stats and entity.performance_stats.is_valid:
175 performance_stats = _ndb_to_rpc( 175 performance_stats = _ndb_to_rpc(
176 swarming_rpcs.PerformanceStats, 176 swarming_rpcs.PerformanceStats,
177 entity.performance_stats, 177 entity.performance_stats,
178 isolated_download=_ndb_to_rpc( 178 isolated_download=_ndb_to_rpc(
179 swarming_rpcs.IsolatedOperation, 179 swarming_rpcs.OperationStats,
180 entity.performance_stats.isolated_download), 180 entity.performance_stats.isolated_download),
181 isolated_upload=_ndb_to_rpc( 181 isolated_upload=_ndb_to_rpc(
182 swarming_rpcs.IsolatedOperation, 182 swarming_rpcs.OperationStats,
183 entity.performance_stats.isolated_upload)) 183 entity.performance_stats.isolated_upload))
184 kwargs = { 184 kwargs = {
185 'bot_dimensions': _string_list_pairs_from_dict(entity.bot_dimensions or {}), 185 'bot_dimensions': _string_list_pairs_from_dict(entity.bot_dimensions or {}),
186 'performance_stats': performance_stats, 186 'performance_stats': performance_stats,
187 'outputs_ref': outputs_ref, 187 'outputs_ref': outputs_ref,
188 'state': swarming_rpcs.StateField(entity.state), 188 'state': swarming_rpcs.StateField(entity.state),
189 } 189 }
190 if entity.__class__ is task_result.TaskRunResult: 190 if entity.__class__ is task_result.TaskRunResult:
191 kwargs['costs_usd'] = [] 191 kwargs['costs_usd'] = []
192 if entity.cost_usd is not None: 192 if entity.cost_usd is not None:
193 kwargs['costs_usd'].append(entity.cost_usd) 193 kwargs['costs_usd'].append(entity.cost_usd)
194 kwargs['properties_hash'] = None 194 kwargs['properties_hash'] = None
195 kwargs['tags'] = [] 195 kwargs['tags'] = []
196 kwargs['user'] = None 196 kwargs['user'] = None
197 else: 197 else:
198 assert entity.__class__ is task_result.TaskResultSummary, entity 198 assert entity.__class__ is task_result.TaskResultSummary, entity
199 kwargs['properties_hash'] = ( 199 kwargs['properties_hash'] = (
200 entity.properties_hash.encode('hex') 200 entity.properties_hash.encode('hex')
201 if entity.properties_hash else None) 201 if entity.properties_hash else None)
202 return _ndb_to_rpc(swarming_rpcs.TaskResult, entity, **kwargs) 202 return _ndb_to_rpc(swarming_rpcs.TaskResult, entity, **kwargs)
OLDNEW
« no previous file with comments | « appengine/swarming/handlers_bot.py ('k') | appengine/swarming/server/task_result.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698