<commit_before>"""
Task:
Do fancy shit.
"""

# Import Built-Ins
import logging
import time
import json

# Import Third-Party

# Import Homebrew


log = logging.getLogger(__name__)


def time_resp(func):
    def wrapper(self, *args, **kwargs):
        sent = time.time()
        try:
            resp, pair = func(self, *args, **kwargs)
            received = time.time()
            return sent, received, resp, pair
        except ValueError:
            resp = func(self, *args, **kwargs)
            received = time.time()
            return sent, received, resp
    return wrapper


def logging(func):
    def wrapper(self, *args, **kwargs):
        log.debug("%s: Args %s, Kwargs: %s", (func.__name__, args, kwargs))
        return func(*args, **kwargs)
    return wrapper


def validate_response(func):
    def wrapper(self, *args, **kwargs):
        resp = func(*args, **kwargs)

        if resp.status_code != 200:
            raise ConnectionError("Response Code was %s" % resp.status_code)

        try:
            resp.json()
        except json.JSONDecodeError as e:
            log.error("Returned data wasn't json-seriazable - possibly wrong url? Error: %s", e)
            raise

        return resp
    return wrapper<commit_msg>updated error message on invalid json<commit_after>"""
Task:
Do fancy shit.
"""

# Import Built-Ins
import logging
import time
import json

# Import Third-Party

# Import Homebrew


log = logging.getLogger(__name__)


def time_resp(func):
    def wrapper(self, *args, **kwargs):
        sent = time.time()
        try:
            resp, pair = func(self, *args, **kwargs)
            received = time.time()
            return sent, received, resp, pair
        except ValueError:
            resp = func(self, *args, **kwargs)
            received = time.time()
            return sent, received, resp
    return wrapper


def logging(func):
    def wrapper(self, *args, **kwargs):
        log.debug("%s: Args %s, Kwargs: %s", (func.__name__, args, kwargs))
        return func(*args, **kwargs)
    return wrapper


def validate_response(func):
    def wrapper(self, *args, **kwargs):
        resp = func(*args, **kwargs)

        if resp.status_code != 200:
            raise ConnectionError("Response Code was %s" % resp.status_code)

        try:
            resp.json()
        except json.JSONDecodeError as e:
            log.error("Returned data wasn't json-seriazable - possibly invalid api endpoint? Error: %s", e)
            raise

        return resp
    return wrapper
{'fraction_non_alphanumeric': 0.11713494261970717, 'fraction_numerical': 0.002374356944994064, 'mean_word_length': 2.3045751633986926, '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': '2104283', 'n_tokens_mistral': 733, 'n_tokens_neox': 712, 'n_words': 229}