<commit_before>import blaze as bz

from sqlalchemy import select
import json

import os
from weakref import WeakKeyDictionary


class LazyAttr(object):
    def __init__(self, get):
        self._get = get
        self._cache = WeakKeyDictionary()

    def __get__(self, instance, owner):
        if instance is None:
            return self
        try:
            return self._cache[instance]
        except KeyError:
            self._cache[instance] = val = self._get(instance)
            return val


def load(target_info_path=None, config=None):
    class _blaze_loader(object):
        target_infos = _load_infos_from_json(target_info_path=target_info_path)
        locals_ = locals()

        for name, target_info in target_infos.iteritems():
            @LazyAttr
            def _lazyattr(self, _name=name, _target_info=target_info, 
                          config=config):
                target = _target_info.get('target')
                table = _target_info.get('table')
                schema = _target_info.get('schema', None)
                datashape = _target_info.get('datashape', None)
                columns = _target_info.get('columns', None)

                try:
                    bz_data = _add_blaze_data(_name,
                                              target,
                                              table=table,
                                              schema=schema,<commit_msg>refactor attr class<commit_after>import blaze as bz

from sqlalchemy import select
import json

import os


class LazyAttr(object):
    def __init__(self, get):
        self._get = get
        self._cache = {}

    def __get__(self, instance, owner):
        if instance is None:
            return self
        try:
            return self._cache[instance]
        except KeyError:
            val = self._get(instance)
            self._cache[instance] = val

            return val


def load(target_info_path=None, config=None):
    class _blaze_loader(object):
        target_infos = _load_infos_from_json(target_info_path=target_info_path)
        locals_ = locals()

        for name, target_info in target_infos.iteritems():
            @LazyAttr
            def _lazyattr(self, _name=name, _target_info=target_info, 
                          config=config):
                target = _target_info.get('target')
                table = _target_info.get('table')
                schema = _target_info.get('schema', None)
                datashape = _target_info.get('datashape', None)
                columns = _target_info.get('columns', None)

                try:
                    bz_data = _add_blaze_data(_name,
                                              target,
                                              table=table,
                                              schema=schema,
{'fraction_non_alphanumeric': 0.07627118644067797, 'fraction_numerical': 0.0, 'mean_word_length': 1.573115349682107, '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': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4910605', 'n_tokens_mistral': 753, 'n_tokens_neox': 721, 'n_words': 165}