From 8bab51063a13f4c67e8f086f71f208e7f733341f Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Wed, 21 Feb 2024 07:45:08 -0500 Subject: [PATCH] More explicit typing for JobMetricFormatter implementations --- lib/galaxy/job_metrics/instrumenters/hostname.py | 5 +++-- lib/galaxy/job_metrics/instrumenters/meminfo.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/galaxy/job_metrics/instrumenters/hostname.py b/lib/galaxy/job_metrics/instrumenters/hostname.py index 721fa1aca419..d4d01402a879 100644 --- a/lib/galaxy/job_metrics/instrumenters/hostname.py +++ b/lib/galaxy/job_metrics/instrumenters/hostname.py @@ -1,6 +1,7 @@ """The module describes the ``hostname`` job metrics plugin.""" import logging +from typing import Any from . import InstrumentPlugin from .. import formatting @@ -9,8 +10,8 @@ class HostnameFormatter(formatting.JobMetricFormatter): - def format(self, key, value): - return key, value + def format(self, key: str, value: Any): + return formatting.FormattedMetric(key, value) class HostnamePlugin(InstrumentPlugin): diff --git a/lib/galaxy/job_metrics/instrumenters/meminfo.py b/lib/galaxy/job_metrics/instrumenters/meminfo.py index 80e523d97308..a6ec359e730a 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): 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):