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

Side by Side Diff: appengine/swarming/server/task_result.py

Issue 2043853002: Complete CIPD integration (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@run-isolated-cipd
Patch Set: rebased and nit Created 4 years, 6 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
OLDNEW
1 # Copyright 2014 The LUCI Authors. All rights reserved. 1 # Copyright 2014 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 """Task execution result models. 5 """Task execution result models.
6 6
7 This module doesn't do the scheduling itself. It only describes the entities to 7 This module doesn't do the scheduling itself. It only describes the entities to
8 store tasks results. 8 store tasks results.
9 9
10 - TaskResultSummary represents the overall result for the TaskRequest taking in 10 - TaskResultSummary represents the overall result for the TaskRequest taking in
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 278
279 Parent is TaskRunResult. Key id is 1. 279 Parent is TaskRunResult. Key id is 1.
280 280
281 Data from the client who uploaded the initial data is not tracked here, since 281 Data from the client who uploaded the initial data is not tracked here, since
282 it is generally operating on data that is used across multiple different 282 it is generally operating on data that is used across multiple different
283 tasks. 283 tasks.
284 284
285 This entity only exist for isolated tasks. For "raw command task", this entity 285 This entity only exist for isolated tasks. For "raw command task", this entity
286 is not stored, since there's nothing to note. 286 is not stored, since there's nothing to note.
287 """ 287 """
288 # Miscellaneous overhead in second, in addition to the overhead from 288 # Miscellaneous overhead in seconds, in addition to the overhead from
289 # isolated_download.duration and isolated_upload.duration. 289 # package_installation.duration, isolated_download.duration and
290 # isolated_upload.duration
290 bot_overhead = ndb.FloatProperty(indexed=False) 291 bot_overhead = ndb.FloatProperty(indexed=False)
292 # Results installing CIPD packages before the task.
293 package_installation = ndb.LocalStructuredProperty(OperationStats)
291 # Runtime dependencies download operation before the task. 294 # Runtime dependencies download operation before the task.
292 isolated_download = ndb.LocalStructuredProperty(OperationStats) 295 isolated_download = ndb.LocalStructuredProperty(OperationStats)
293 # Results uploading operation after the task. 296 # Results uploading operation after the task.
294 isolated_upload = ndb.LocalStructuredProperty(OperationStats) 297 isolated_upload = ndb.LocalStructuredProperty(OperationStats)
295 298
296 @property 299 @property
297 def is_valid(self): 300 def is_valid(self):
298 return self.bot_overhead is not None 301 return self.bot_overhead is not None
299 302
300 def _pre_put_hook(self): 303 def _pre_put_hook(self):
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 439
437 Returns an empty instance if none is available. 440 Returns an empty instance if none is available.
438 """ 441 """
439 # Keeps a cache. It's still paying the full latency cost of a DB fetch. 442 # Keeps a cache. It's still paying the full latency cost of a DB fetch.
440 if not hasattr(self, '_performance_stats_cache'): 443 if not hasattr(self, '_performance_stats_cache'):
441 key = None if self.deduped_from else self.performance_stats_key 444 key = None if self.deduped_from else self.performance_stats_key
442 # pylint: disable=attribute-defined-outside-init 445 # pylint: disable=attribute-defined-outside-init
443 stats = (key.get() if key else None) or PerformanceStats() 446 stats = (key.get() if key else None) or PerformanceStats()
444 stats.isolated_download = stats.isolated_download or OperationStats() 447 stats.isolated_download = stats.isolated_download or OperationStats()
445 stats.isolated_upload = stats.isolated_upload or OperationStats() 448 stats.isolated_upload = stats.isolated_upload or OperationStats()
449 stats.package_installation = (
450 stats.package_installation or OperationStats())
446 self._performance_stats_cache = stats 451 self._performance_stats_cache = stats
447 return self._performance_stats_cache 452 return self._performance_stats_cache
448 453
449 @property 454 @property
455 def overhead_package_installation(self):
456 """Returns the overhead from package installation in timedelta."""
457 perf = self.performance_stats
458 if perf.package_installation.duration is not None:
459 return datetime.timedelta(seconds=perf.package_installation.duration)
460
461 @property
450 def overhead_isolated_inputs(self): 462 def overhead_isolated_inputs(self):
451 """Returns the overhead from isolated setup in timedelta.""" 463 """Returns the overhead from isolated setup in timedelta."""
452 perf = self.performance_stats 464 perf = self.performance_stats
453 if perf.isolated_download.duration is not None: 465 if perf.isolated_download.duration is not None:
454 return datetime.timedelta(seconds=perf.isolated_download.duration) 466 return datetime.timedelta(seconds=perf.isolated_download.duration)
455 467
456 @property 468 @property
457 def overhead_isolated_outputs(self): 469 def overhead_isolated_outputs(self):
458 """Returns the overhead from isolated results upload in timedelta.""" 470 """Returns the overhead from isolated results upload in timedelta."""
459 perf = self.performance_stats 471 perf = self.performance_stats
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 if tags: 1146 if tags:
1135 # Add TaskResultSummary indexes if desired. 1147 # Add TaskResultSummary indexes if desired.
1136 if sort != 'created_ts': 1148 if sort != 'created_ts':
1137 raise ValueError( 1149 raise ValueError(
1138 'Add needed indexes for sort:%s and tags if desired' % sort) 1150 'Add needed indexes for sort:%s and tags if desired' % sort)
1139 tags_filter = TaskResultSummary.tags == tags[0] 1151 tags_filter = TaskResultSummary.tags == tags[0]
1140 for tag in tags[1:]: 1152 for tag in tags[1:]:
1141 tags_filter = ndb.AND(tags_filter, TaskResultSummary.tags == tag) 1153 tags_filter = ndb.AND(tags_filter, TaskResultSummary.tags == tag)
1142 query = query.filter(tags_filter) 1154 query = query.filter(tags_filter)
1143 return _filter_query(TaskResultSummary, query, start, end, sort, state) 1155 return _filter_query(TaskResultSummary, query, start, end, sort, state)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698