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

Unified Diff: dashboard/dashboard/add_histograms_queue.py

Issue 2879453002: [Dashboard] Get or create ancestors in add_histograms_queue (Closed)
Patch Set: fix failing unit add_point test Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | dashboard/dashboard/add_histograms_queue_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dashboard/dashboard/add_histograms_queue.py
diff --git a/dashboard/dashboard/add_histograms_queue.py b/dashboard/dashboard/add_histograms_queue.py
index 742f84f5c3ec69ba98339a665d810bd3e27c0fe1..137872196dcaa50a04a91257f7280129560549c3 100644
--- a/dashboard/dashboard/add_histograms_queue.py
+++ b/dashboard/dashboard/add_histograms_queue.py
@@ -6,13 +6,15 @@
import json
-from dashboard import add_histograms
+# TODO(eakuefner): Move these helpers so we don't have to import add_point_queue
+# directly.
+from dashboard import add_point_queue
from dashboard.common import datastore_hooks
from dashboard.common import request_handler
-from dashboard.common import utils
+from dashboard.common import stored_object
+from dashboard.models import anomaly
from dashboard.models import histogram
-
class AddHistogramsQueueHandler(request_handler.RequestHandler):
"""Request handler to process a histogram and add it to the datastore.
@@ -43,12 +45,26 @@ class AddHistogramsQueueHandler(request_handler.RequestHandler):
datastore_hooks.SetPrivilegedRequest()
data = self.request.get('data')
- data_dict = json.loads(data)
revision = int(self.request.get('revision'))
- test_key = utils.TestKey(self.request.get('test_path'))
+ test_path = self.request.get('test_path')
+
+ data_dict = json.loads(data)
guid = data_dict['guid']
+ is_diagnostic = 'type' in data_dict
- if data_dict.get('type') in add_histograms.SPARSE_DIAGNOSTIC_TYPES:
+ test_path_parts = test_path.split('/')
+ master = test_path_parts[0]
+ bot = test_path_parts[1]
+ test_name = '/'.join(test_path_parts[2:])
+ bot_whitelist = stored_object.Get(add_point_queue.BOT_WHITELIST_KEY)
+ internal_only = add_point_queue.BotInternalOnly(bot, bot_whitelist)
+ extra_args = {} if is_diagnostic else GetUnitArgs(data_dict['unit'])
+ # TDOO(eakuefner): Populate benchmark_description once it appears in
+ # diagnostics.
+ test_key = add_point_queue.GetOrCreateAncestors(
+ master, bot, test_name, internal_only, **extra_args).key
+
+ if is_diagnostic:
entity = histogram.SparseDiagnostic(
id=guid, data=data, test=test_key, start_revision=revision,
end_revision=revision)
@@ -57,3 +73,18 @@ class AddHistogramsQueueHandler(request_handler.RequestHandler):
id=guid, data=data, test=test_key, revision=revision)
entity.put()
+
+
+def GetUnitArgs(unit):
+ unit_args = {
+ 'units': unit
+ }
+ # TODO(eakuefner): Port unit system to Python and use that here
+ histogram_improvement_direction = unit.split('_')[-1]
+ if histogram_improvement_direction == 'biggerIsBetter':
+ unit_args['improvement_direction'] = anomaly.UP
+ elif histogram_improvement_direction == 'smallerIsBetter':
+ unit_args['improvement_direction'] = anomaly.DOWN
+ else:
+ unit_args['improvement_direction'] = anomaly.UNKNOWN
+ return unit_args
« no previous file with comments | « no previous file | dashboard/dashboard/add_histograms_queue_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698