Exemplo n.º 1
0
    def __init__(self, metrics_params=[]):
        """
        Init the class, adding metrics_params to the
        stuff to compute if a list of metrics parameters (dictionaries) is passed.
        Metrics parameters are checked for correctness, an assertion error will interrupt
        the program if any incorrectness is met.

        :param metrics_params: List of metrics, each metric is a dictionary mapping params of
            the metric to a value, as in the json config file.
        :type metrics_params: list
        """
        Config._process_metrics(metrics_params)
        self._metrics = metrics_params
Exemplo n.º 2
0
 def add(self, input):
     """
     Adds more metrics to the task, the input can be of:
     - a _Task class or any class extending it
     - a dict containing metric params, or a list of those
     :param input: a _Task class or a class inheriting from it, a list of metrics params or a single metric param
     :type input dict/list/Task
     :return: Returns a reference to this instance of _Task, for chaining.
     """
     if type(input) is list:
         Config._process_metrics(input)
         self._metrics.extend(input)
     elif type(input) is dict:
         Config._process_metrics([input])
         self._metrics.append(input)
     elif isinstance(input, _Task):
         # metrics should already have been processed, no need to check here
         self._metrics.extend(input._metrics)
     else:
         "Input must be either a list of dicts, a dict or another Task instance"
         exit()
     return self