<commit_before>import os
import sys
import functools
import traceback


# Oh god why isn't there a standard package for this.
def make_logger(c, enabled=lambda: True):
    def inner(msg, args=()):
        if enabled():
            fmt = "[%s] %s" % (c, msg)
            # Cope gracefully with printf style invocations
            print(fmt % args)
    return inner


def fatal(msg):
    make_logger("!")(msg)
    sys.exit(1)
debug = make_logger("*", lambda: os.getenv("DEBUG"))
info = make_logger("+")


def catch_exceptions_and_retry(func):
    @functools.wraps(func)
    def inner(*args, **kwargs):
        exc = None
        for i in range(3):
            try:
                return func(*args, **kwargs)
            except Exception as e:
                exc = e
                info("Caught exception: %s, continuing" % (repr(e)))<commit_msg>Actually have that warn handler<commit_after>import os
import sys
import functools
import traceback


# Oh god why isn't there a standard package for this.
def make_logger(c, enabled=lambda: True):
    def inner(msg, args=()):
        if enabled():
            fmt = "[%s] %s" % (c, msg)
            # Cope gracefully with printf style invocations
            print(fmt % args)
    return inner


def fatal(msg):
    make_logger("!")(msg)
    sys.exit(1)
debug = make_logger("*", lambda: os.getenv("DEBUG"))
info = make_logger("+")
warn = make_logger("!")


def catch_exceptions_and_retry(func):
    @functools.wraps(func)
    def inner(*args, **kwargs):
        exc = None
        for i in range(3):
            try:
                return func(*args, **kwargs)
            except Exception as e:
                exc = e
                info("Caught exception: %s, continuing" % (repr(e)))
{'fraction_non_alphanumeric': 0.1277330264672037, 'fraction_numerical': 0.0023014959723820483, 'mean_word_length': 2.37015503875969, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5181123', 'n_tokens_mistral': 545, 'n_tokens_neox': 529, 'n_words': 163}