<commit_before>from django.utils.module_loading import module_has_submodule
from django.utils.importlib import import_module
from celery.contrib.methods import task
from django.conf import settings

not_implemented_error = 'Importer of type {type} does not implement {name}().'

class Importer(object):
    model = None

    app_label = None
    module_name = None

    def match(self, instance):
        raise NotImplementedError(
            type=not_implemented_error.format(self.__class__.__name__),
            name='match')

    def run(self, instance):
        raise NotImplementedError(
            type=not_implemented_error.format(self.__class__.__name__),
                name='process')

    @classmethod
    def from_string(cls, representation):
        # TODO: Leverage cached representations once importer.register() supports them.

        app_label = representation[0:representation.index('.')]
        module_name = representation[len(app_label)+1:]

        for application in settings.INSTALLED_APPS:
            try:
                app_found = application[application.rindex('.')+1:]
            except ValueError:
                app_found = application<commit_msg>Modified the way that celery tasks work.<commit_after>from django.utils.module_loading import module_has_submodule
from django.utils.importlib import import_module
from celery.contrib.methods import task
from django.conf import settings

not_implemented_error = 'Importer of type {type} does not implement {name}().'

class Importer(object):
    model = None

    app_label = None
    module_name = None

    def match(self, instance):
        raise NotImplementedError(
            type=not_implemented_error.format(self.__class__.__name__),
            name='match')

    @task
    def run(self, pk):
        instance = self.model.objects.get(pk=pk)

        return self.process(instance)

    def process(self, instance):
        raise NotImplementedError(
            type=not_implemented_error.format(self.__class__.__name__),
            name='process')

    @classmethod
    def from_string(cls, representation):
        # TODO: Leverage cached representations once importer.register() supports them.

        app_label = representation[0:representation.index('.')]
        module_name = representation[len(app_label)+1:]

        for application in settings.INSTALLED_APPS:
            try:
                app_found = application[application.rindex('.')+1:]
            except ValueError:
                app_found = application
{'fraction_non_alphanumeric': 0.08712871287128712, 'fraction_numerical': 0.002376237623762376, 'mean_word_length': 2.990521327014218, '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': '6470439', 'n_tokens_mistral': 682, 'n_tokens_neox': 655, 'n_words': 161}