Warning

This document is for an in-development version 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

"""This module describes the abstract interface for :class:`InstrumentPlugin`.

These are responsible for collecting and formatting a coherent set of metrics.
"""
import os.path
from abc import (
    ABCMeta,
    abstractmethod
)


from .. import formatting

INSTRUMENT_FILE_PREFIX = "__instrument"


[docs]class InstrumentPlugin(metaclass=ABCMeta): """Describes how to instrument job scripts and retrieve collected metrics.""" formatter = formatting.JobMetricFormatter() @property @abstractmethod def plugin_type(self): """ Short string providing labelling this plugin """
[docs] def pre_execute_instrument(self, job_directory): """ Optionally return one or more commands to instrument job. These commands will be executed on the compute server prior to the job running. """ return None
[docs] def post_execute_instrument(self, job_directory): """ Optionally return one or more commands to instrument job. These commands will be executed on the compute server after the tool defined command is ran. """ return None
[docs] @abstractmethod def job_properties(self, job_id, job_directory): """ Collect properties for this plugin from specified job directory. This method will run on the Galaxy server and can assume files created in job_directory with pre_execute_instrument and post_execute_instrument are available. """
def _instrument_file_name(self, name): """ Provide a common pattern for naming files used by instrumentation plugins - to ease their staging out of remote job directories. """ return "{}_{}_{}".format(INSTRUMENT_FILE_PREFIX, self.plugin_type, name) def _instrument_file_path(self, job_directory, name): return os.path.join(job_directory, self._instrument_file_name(name))