<commit_before>from ..extensions import db


class BaseModel:
    """ Base class with basics methods for all the models. """

    def __init__(self, kind, **kwargs):
        self.kind = kind
        self.db = db
        self.query = self.db.client.query(kind=self.kind)
        self.data = kwargs

    def get(self, id):
        return self.db.get(self.kind, id)

    def put(self, data=None, entity_id=None):
        """ If data and id are pass means a update. """
        if data and entity_id:
            return self.db.put(self.kind, data, entity_id)
        self.id, _ = self.db.put(self.kind, self.data)

    update = put

    def fetch(self):
        """ Execute lazy query and convert obj to a list. """
        return list(self.query.fetch())<commit_msg>Update put, fetch in base model<commit_after>from ..extensions import db


class BaseModel:
    """ Base class with basics methods for all the models. """

    def __init__(self, kind, **kwargs):
        self.kind = kind
        self.db = db
        self.query = self.db.client.query(kind=self.kind)
        self.data = kwargs

    def get(self, id):
        return self.db.get(self.kind, id)

    def put(self, entity_id=None, data=None):
        """ If data and id are pass means a update. """
        if data and entity_id:
            return self.db.put(self.kind, data, entity_id)
        self.id, _ = self.db.put(self.kind, self.data)

    update = put

    def fetch(self):
        """ Execute lazy query, map results and convert obj to a list. """
        entities = map(self.db.from_datastore, self.query.fetch())
        return list(entities)
{'fraction_non_alphanumeric': 0.12128712871287128, 'fraction_numerical': 0.0, 'mean_word_length': 2.3135245901639343, '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': '1156013', 'n_tokens_mistral': 502, 'n_tokens_neox': 491, 'n_words': 153}