aboutsummaryrefslogtreecommitdiff
path: root/catapult/telemetry/telemetry/value/summarizable.py
blob: 9cfcf46f9c2419224946eb0f2b1085aa4f948b45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

from telemetry import value as value_module
from telemetry.value import (improvement_direction
                             as improvement_direction_module)


class SummarizableValue(value_module.Value):
  def __init__(self, page, name, units, important, description, tir_label,
               improvement_direction, grouping_keys):
    """A summarizable value result from a test."""
    super(SummarizableValue, self).__init__(
        page, name, units, important, description, tir_label, grouping_keys)
# TODO(eakuefner): uncomment this assert after Telemetry clients are fixed.
# Note: Telemetry unittests satisfy this assert.
#    assert improvement_direction_module.IsValid(improvement_direction)
    self._improvement_direction = improvement_direction

  @property
  def improvement_direction(self):
    return self._improvement_direction

  def AsDict(self):
    d = super(SummarizableValue, self).AsDict()
    if improvement_direction_module.IsValid(self.improvement_direction):
      d['improvement_direction'] = self.improvement_direction
    return d

  @staticmethod
  def GetJSONTypeName():
    return 'summarizable'

  def AsDictWithoutBaseClassEntries(self):
    d = super(SummarizableValue, self).AsDictWithoutBaseClassEntries()
    if 'improvement_direction' in d:
      del d['improvement_direction']
    return d

  def GetBuildbotDataType(self, output_context):
    """Returns the buildbot's equivalent data_type.

    This should be one of the values accepted by perf_tests_results_helper.py.
    """
    raise NotImplementedError()

  def GetBuildbotValue(self):
    """Returns the buildbot's equivalent value."""
    raise NotImplementedError()

  @classmethod
  def MergeLikeValuesFromSamePage(cls, values):
    raise NotImplementedError()

  @classmethod
  def MergeLikeValuesFromDifferentPages(cls, values):
    raise NotImplementedError()

  def GetRepresentativeNumber(self):
    """Gets a single scalar value that best-represents this value.

    Returns None if not possible.
    """
    raise NotImplementedError()

  def GetRepresentativeString(self):
    """Gets a string value that best-represents this value.

    Returns None if not possible.
    """
    raise NotImplementedError()