(
        self, metric_name: str, time_start: arrow.Arrow, time_end: arrow.Arrow, smoothing: int = 5,
    )
return (
            latest_non_zero_values[0][0],
            latest_non_zero_values[-1][0],
            sum([float(val) for __, val in latest_non_zero_values]) / len(latest_non_zero_values),
        )
Compute some smoothed-out historical metrics metadata

        :param metric_name: the metadata metric to query
        :param time_start: the beginning of the historical time window to query
        :param time_end: the end of the historical time window to query
        :param smoothing: take this many non-zero metric values and average them together
        :returns: the start and end times over which the average was taken, and smoothed-out metric value during this
            time period; or None, if no historical data exists
Compute some smoothed-out historical metrics metadata
Compute some smoothed - out historical metrics metadata
def _get_smoothed_non_zero_metadata(
        self, metric_name: str, time_start: arrow.Arrow, time_end: arrow.Arrow, smoothing: int = 5,
    ) -> Optional[Tuple[int, int, float]]:
        """ Compute some smoothed-out historical metrics metadata

        :param metric_name: the metadata metric to query
        :param time_start: the beginning of the historical time window to query
        :param time_end: the end of the historical time window to query
        :param smoothing: take this many non-zero metric values and average them together
        :returns: the start and end times over which the average was taken, and smoothed-out metric value during this
            time period; or None, if no historical data exists
        """
        metrics = self.metrics_client.get_metric_values(
            metric_name,
            METADATA,
            time_start,
            time_end,
            extra_dimensions=get_cluster_dimensions(self.cluster, self.pool, self.scheduler),
        )[metric_name]
        latest_non_zero_values = [(ts, val) for ts, val in metrics if val > 0][-smoothing:]
        if not latest_non_zero_values:
            return None
        return (
            latest_non_zero_values[0][0],
            latest_non_zero_values[-1][0],
            sum([float(val) for __, val in latest_non_zero_values]) / len(latest_non_zero_values),
        )
def _get_smoothed_non_zero_metadata ( self , metric_name : str , time_start : arrow . Arrow , time_end : arrow . Arrow , smoothing : int = 5 , ) -> Optional [ Tuple [ int , int , float ] ] : metrics = self . metrics_client . get_metric_values ( metric_name , METADATA , time_start , time_end , extra_dimensions = get_cluster_dimensions ( self . cluster , self . pool , self . scheduler ) , ) [ metric_name ] latest_non_zero_values = [ ( ts , val ) for ts , val in metrics if val > 0 ] [ - smoothing : ] if not latest_non_zero_values : return None return ( latest_non_zero_values [ 0 ] [ 0 ] , latest_non_zero_values [ - 1 ] [ 0 ] , sum ( [ float ( val ) for __ , val in latest_non_zero_values ] ) / len ( latest_non_zero_values ) , )