Warning

This document is for an old release of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.

Source code for galaxy.job_metrics.instrumenters.hostname

"""The module describes the ``hostname`` job metrics plugin."""
import logging

from . import InstrumentPlugin
from .. import formatting

log = logging.getLogger(__name__)


class HostnameFormatter(formatting.JobMetricFormatter):
    def format(self, key, value):
        return key, value


[docs]class HostnamePlugin(InstrumentPlugin): """Gather hostname""" plugin_type = "hostname" formatter = HostnameFormatter()
[docs] def __init__(self, **kwargs): pass
[docs] def pre_execute_instrument(self, job_directory): return f"hostname -f > '{self.__instrument_hostname_path(job_directory)}'"
[docs] def job_properties(self, job_id, job_directory): with open(self.__instrument_hostname_path(job_directory)) as f: return {"hostname": f.read().strip()}
def __instrument_hostname_path(self, job_directory): return self._instrument_file_path(job_directory, "hostname")
__all__ = ("HostnamePlugin",)