<commit_before>import typing as tp
import logging
import copy
import time
from abc import abstractmethod, ABCMeta
from satella.json import JSONAble
from satella.coding import for_argument


logger = logging.getLogger(__name__)

DISABLED = 1
RUNTIME = 2
DEBUG = 3
INHERIT = 4


class Metric(JSONAble):
    """
    Container for child metrics. A base metric class, as well as the default metric.

    Switch levels by setting metric.level to a proper value

    :param enable_timestamp: append timestamp of last update to the metric
    """
    CLASS_NAME = 'base'

    def reset(self) -> None:
        """
        Delete all child metrics that this metric contains.

        Also, if called on root metric, sets the runlevel to RUNTIME
        """
        from satella.instrumentation import metrics
        if self.name == '':
            metrics.metrics = {}
            metrics.level = RUNTIME
        else:
            metrics.metrics = {k: v for k, v in metrics.metrics.items() if
                               not k.startswith(self.name + '.')}
            del metrics.metrics[self.name]
        self.children = []

    def __init__(self, name, root_metric: 'Metric' = None, metric_level: str = None,
                 **kwargs):
        """When reimplementing the method, remember to pass kwargs here!"""
        logger.warning(f'Creating {self.__class__.__qualname__}')
        self.name = name
        self.root_metric = root_metric
        if metric_level is None:
            if self.name == '':
                metric_level = RUNTIME
            else:
                metric_level = INHERIT
        self._level = metric_level
        self.enable_timestamp = kwargs.get('enable_timestamp', True)
        logger.warning(f'enable timestamp is {self.enable_timestamp}')
        if self.enable_timestamp:
            self.last_updated = time.time()<commit_msg>logger remove<commit_after>import typing as tp
import logging
import copy
import time
from abc import abstractmethod, ABCMeta
from satella.json import JSONAble
from satella.coding import for_argument


logger = logging.getLogger(__name__)

DISABLED = 1
RUNTIME = 2
DEBUG = 3
INHERIT = 4


class Metric(JSONAble):
    """
    Container for child metrics. A base metric class, as well as the default metric.

    Switch levels by setting metric.level to a proper value

    :param enable_timestamp: append timestamp of last update to the metric
    """
    CLASS_NAME = 'base'

    def reset(self) -> None:
        """
        Delete all child metrics that this metric contains.

        Also, if called on root metric, sets the runlevel to RUNTIME
        """
        from satella.instrumentation import metrics
        if self.name == '':
            metrics.metrics = {}
            metrics.level = RUNTIME
        else:
            metrics.metrics = {k: v for k, v in metrics.metrics.items() if
                               not k.startswith(self.name + '.')}
            del metrics.metrics[self.name]
        self.children = []

    def __init__(self, name, root_metric: 'Metric' = None, metric_level: str = None,
                 **kwargs):
        """When reimplementing the method, remember to pass kwargs here!"""
        logger.warning(f'Creating {self.__class__.__qualname__}')
        self.name = name
        self.root_metric = root_metric
        if metric_level is None:
            if self.name == '':
                metric_level = RUNTIME
            else:
                metric_level = INHERIT
        self._level = metric_level
        self.enable_timestamp = kwargs.get('enable_timestamp', True)
        if self.enable_timestamp:
            self.last_updated = time.time()
{'fraction_non_alphanumeric': 0.08358372029500137, 'fraction_numerical': 0.002185195301830101, 'mean_word_length': 2.2292768959435625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3828986', 'n_tokens_mistral': 999, 'n_tokens_neox': 972, 'n_words': 326}