diff --git a/lib/galaxy/job_metrics/instrumenters/cgroup.py b/lib/galaxy/job_metrics/instrumenters/cgroup.py index 62caef9c81dc..66da4f9389f9 100644 --- a/lib/galaxy/job_metrics/instrumenters/cgroup.py +++ b/lib/galaxy/job_metrics/instrumenters/cgroup.py @@ -114,18 +114,18 @@ class CgroupPluginFormatter(formatting.JobMetricFormatter): - def format(self, key, value): + def format(self, key: str, value: Any) -> formatting.FormattedMetric: title = TITLES.get(key, key) if key in CONVERSION: - return title, CONVERSION[key](value) + return formatting.FormattedMetric(title, CONVERSION[key](value)) elif key.endswith("_bytes"): try: - return title, nice_size(value) + return formatting.FormattedMetric(title, nice_size(value)) except ValueError: pass elif isinstance(value, (decimal.Decimal, numbers.Integral, numbers.Real)) and value == int(value): value = int(value) - return title, value + return formatting.FormattedMetric(title, str(value)) class CgroupPlugin(InstrumentPlugin): diff --git a/lib/galaxy/job_metrics/instrumenters/hostname.py b/lib/galaxy/job_metrics/instrumenters/hostname.py index 721fa1aca419..1d7ea07165b3 100644 --- a/lib/galaxy/job_metrics/instrumenters/hostname.py +++ b/lib/galaxy/job_metrics/instrumenters/hostname.py @@ -3,21 +3,14 @@ import logging from . import InstrumentPlugin -from .. import formatting log = logging.getLogger(__name__) -class HostnameFormatter(formatting.JobMetricFormatter): - def format(self, key, value): - return key, value - - class HostnamePlugin(InstrumentPlugin): """Gather hostname""" plugin_type = "hostname" - formatter = HostnameFormatter() def __init__(self, **kwargs): pass diff --git a/lib/galaxy/job_metrics/instrumenters/meminfo.py b/lib/galaxy/job_metrics/instrumenters/meminfo.py index 80e523d97308..9e1d9be1de27 100644 --- a/lib/galaxy/job_metrics/instrumenters/meminfo.py +++ b/lib/galaxy/job_metrics/instrumenters/meminfo.py @@ -1,6 +1,7 @@ """The module describes the ``meminfo`` job metrics plugin.""" import re +from typing import Any from galaxy import util from . import InstrumentPlugin @@ -14,9 +15,9 @@ class MemInfoFormatter(formatting.JobMetricFormatter): - def format(self, key, value): + def format(self, key: str, value: Any) -> formatting.FormattedMetric: title = MEMINFO_TITLES.get(key, key) - return title, util.nice_size(value * 1000) # kB = *1000, KB = *1024 - wikipedia + return formatting.FormattedMetric(title, util.nice_size(value * 1000)) # kB = *1000, KB = *1024 - wikipedia class MemInfoPlugin(InstrumentPlugin):