1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-02-22 12:58:36 +00:00

fw/output: add label property to Metric

Add a "label" property to Metric that combines its name with its
classifiers into a single string.
This commit is contained in:
Sergei Trofimov 2019-01-14 10:21:37 +00:00 committed by Marc Bonnici
parent 7cd7b73f58
commit 462a5b651a
2 changed files with 11 additions and 0 deletions

View File

@ -497,6 +497,11 @@ A :class:`Metric` has the following attributes:
or they may have been added by the workload to help distinguish between or they may have been added by the workload to help distinguish between
otherwise identical metrics. otherwise identical metrics.
``label``
This is a string constructed from the name and classifiers, to provide a
more unique identifier, e.g. for grouping values across iterations. The
format is in the form ``name/cassifier1=value1/classifier2=value2/...``.
:class:`Artifact` :class:`Artifact`
----------------- -----------------

View File

@ -602,6 +602,12 @@ class Metric(Podable):
instance._pod_version = pod_version # pylint: disable =protected-access instance._pod_version = pod_version # pylint: disable =protected-access
return instance return instance
@property
def label(self):
parts = ['{}={}'.format(n, v) for n, v in self.classifiers.items()]
parts.insert(0, self.name)
return '/'.join(parts)
def __init__(self, name, value, units=None, lower_is_better=False, def __init__(self, name, value, units=None, lower_is_better=False,
classifiers=None): classifiers=None):
super(Metric, self).__init__() super(Metric, self).__init__()