<commit_before>from celery import Celery

app = Celery('tasks', broker='amqp://localhost', backend='redis://localhost')
app.conf.task_send_sent_event = True
app.conf.task_serializer = 'pickle'  # to be able to demo all internal compiler goodies.
app.conf.accept_content = ['pickle']


@app.task(bind=True, max_retries=3)
def function_test(self, retries, **kwargs):
    if retries > self.request.retries:
        raise self.retry(countdown=2)
    return 'this is the result'


@app.task
def function_aggregate(*args, **kwargs):
    return dict(input=args, extra=kwargs)<commit_msg>fix example worker to support canvas workflow tasks<commit_after>from celery import Celery

app = Celery('tasks', broker='amqp://localhost', backend='redis://localhost')
app.conf.task_send_sent_event = True
app.conf.task_serializer = 'pickle'  # to be able to demo all internal compiler goodies.
app.conf.accept_content = ['pickle', 'json']  # apparently canvas workflow are always json.


@app.task(bind=True, max_retries=3)
def function_test(self, retries, **kwargs):
    if retries > self.request.retries:
        raise self.retry(countdown=2)
    return 'this is the result'


@app.task
def function_aggregate(*args, **kwargs):
    return dict(input=args, extra=kwargs)
{'fraction_non_alphanumeric': 0.12689545091779728, 'fraction_numerical': 0.0031923383878691143, 'mean_word_length': 5.147058823529412, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2251792', 'n_tokens_mistral': 404, 'n_tokens_neox': 394, 'n_words': 105}