From 462a5b651a9360fcde34b26df51ded98699c1f38 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Mon, 14 Jan 2019 10:21:37 +0000 Subject: fw/output: add label property to Metric Add a "label" property to Metric that combines its name with its classifiers into a single string. --- doc/source/api/output.rst | 5 +++++ wa/framework/output.py | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/doc/source/api/output.rst b/doc/source/api/output.rst index 5aea51ec..34c8b1ff 100644 --- a/doc/source/api/output.rst +++ b/doc/source/api/output.rst @@ -497,6 +497,11 @@ A :class:`Metric` has the following attributes: or they may have been added by the workload to help distinguish between 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` ----------------- diff --git a/wa/framework/output.py b/wa/framework/output.py index 8ab10b67..3cf1f5ee 100644 --- a/wa/framework/output.py +++ b/wa/framework/output.py @@ -602,6 +602,12 @@ class Metric(Podable): instance._pod_version = pod_version # pylint: disable =protected-access 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, classifiers=None): super(Metric, self).__init__() -- cgit v1.2.3