<commit_before>import contextlib
import haystack
from django.apps import apps as kpi_apps
from django.db import models
from django.conf import settings
from django.core import exceptions

def update_object_in_search_index(obj):
    '''
    If a search index exists for the type of `obj`, update it. Otherwise, do
    nothing
    '''
    try:
        index = haystack.connections['default'].get_unified_index().get_index(
            type(obj))
    except haystack.exceptions.NotHandled:
        # There's nothing to update because this type of object is not indexed
        return
    index.update_object(obj)


class SignalProcessor(haystack.signals.BaseSignalProcessor):
    """
    Allows for observing when saves/deletes fire & automatically updates the
    search engine appropriately.
    """
    def __init__(self, *args, **kwargs):
        self.signal_models = []<commit_msg>Log warning when object has no search index<commit_after>import contextlib
import haystack
import logging
from django.apps import apps as kpi_apps
from django.db import models
from django.conf import settings
from django.core import exceptions

def update_object_in_search_index(obj):
    '''
    If a search index exists for the type of `obj`, update it. Otherwise, do
    nothing
    '''
    try:
        index = haystack.connections['default'].get_unified_index().get_index(
            type(obj))
    except haystack.exceptions.NotHandled:
        # There's nothing to update because this type of object is not indexed
        logging.warning(
            'No search index for type {}'.format(type(obj)), exc_info=True)
        return
    index.update_object(obj)


class SignalProcessor(haystack.signals.BaseSignalProcessor):
    """
    Allows for observing when saves/deletes fire & automatically updates the
    search engine appropriately.
    """
    def __init__(self, *args, **kwargs):
        self.signal_models = []
{'fraction_non_alphanumeric': 0.08054393305439331, 'fraction_numerical': 0.0, 'mean_word_length': 3.4078341013824884, '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': '314671', 'n_tokens_mistral': 523, 'n_tokens_neox': 504, 'n_words': 173}