<commit_before>import inspect


class TaskFactory:
    """Utility class for reducing boilerplate code
    """

    def __init__(self, task_class, product_class, dag):
        self.task_class = task_class
        self.product_class = product_class
        self.dag = dag

    def make(self, task_arg, product_arg, name=None, params=None):
        # FIXME: only works for python callables
        # maybe each task class should implement a get_name method?
        if name is None:
            mod = inspect.getmodule(task_arg).__name__
            name = f'{mod}.{task_arg.__name__}'

        return self.task_class(task_arg,
                               product=self.product_class(product_arg),
                               dag=self.dag,
                               name=name,
                               params=params)<commit_msg>TaskFactory now assigns a default name to the task based on product.name<commit_after>class TaskFactory:
    """Utility class for reducing boilerplate code
    """

    def __init__(self, task_class, product_class, dag):
        self.task_class = task_class
        self.product_class = product_class
        self.dag = dag

    def make(self, task_arg, product_arg, name=None, params=None):
        product = self.product_class(product_arg)

        if name is None:
            name = product.name

        return self.task_class(task_arg,
                               product=product,
                               dag=self.dag,
                               name=name,
                               params=params)
{'fraction_non_alphanumeric': 0.07421625079974409, 'fraction_numerical': 0.0, 'mean_word_length': 1.7632508833922262, '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': '1447130', 'n_tokens_mistral': 410, 'n_tokens_neox': 398, 'n_words': 105}