<commit_before>from cartoframes.exceptions import DiscoveryException
from cartoframes.data.observatory.entity import CatalogList, is_slug_value
from .repo_client import RepoClient

try:
    from abc import ABC, abstractmethod
except ImportError:
    from abc import ABCMeta, abstractmethod
    ABC = ABCMeta('ABC', (object,), {'__slots__': ()})


class EntityRepository(ABC):

    def __init__(self, id_field, filters=[], slug_field=None):
        self.client = RepoClient()

        self.id_field = id_field
        self.allowed_filters = filters + [id_field]

        if slug_field:
            self.slug_field = slug_field
            self.allowed_filters.append(slug_field)

    def get_all(self, filters=None):
        return self._get_filtered_entities(filters)

    def get_by_id(self, id_):
        result = self._get_rows(self._get_id_filter(id_))

        if len(result) == 0:
            raise DiscoveryException('The id does not correspond with any existing entity in the catalog. '
                                     'You can check the full list of available values with get_all() method')

        data = self._map_row(result[0])
        return self._to_catalog_entity(data)

    def get_by_id_list(self, id_list):
        return self._get_filtered_entities(self._get_id_list_filters(id_list))

    def _get_filtered_entities(self, filters=None):
        cleaned_filters = self._get_filters(filters)
        rows = self._get_rows(cleaned_filters)

        if len(rows) == 0:<commit_msg>Fix test<commit_after>from cartoframes.exceptions import DiscoveryException
from cartoframes.data.observatory.entity import CatalogList, is_slug_value
from .repo_client import RepoClient

try:
    from abc import ABC, abstractmethod
except ImportError:
    from abc import ABCMeta, abstractmethod
    ABC = ABCMeta('ABC', (object,), {'__slots__': ()})


class EntityRepository(ABC):

    def __init__(self, id_field, filters=[], slug_field=None):
        self.client = RepoClient()

        self.id_field = id_field
        self.allowed_filters = filters + [id_field]
        self.slug_field = slug_field

        if slug_field:
            self.allowed_filters.append(slug_field)

    def get_all(self, filters=None):
        return self._get_filtered_entities(filters)

    def get_by_id(self, id_):
        result = self._get_rows(self._get_id_filter(id_))

        if len(result) == 0:
            raise DiscoveryException('The id does not correspond with any existing entity in the catalog. '
                                     'You can check the full list of available values with get_all() method')

        data = self._map_row(result[0])
        return self._to_catalog_entity(data)

    def get_by_id_list(self, id_list):
        return self._get_filtered_entities(self._get_id_list_filters(id_list))

    def _get_filtered_entities(self, filters=None):
        cleaned_filters = self._get_filters(filters)
        rows = self._get_rows(cleaned_filters)

        if len(rows) == 0:
{'fraction_non_alphanumeric': 0.08747913188647746, 'fraction_numerical': 0.002003338898163606, 'mean_word_length': 3.149584487534626, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5708749', 'n_tokens_mistral': 912, 'n_tokens_neox': 879, 'n_words': 212}