<commit_before>from celery import shared_task
from django.conf import settings

from waldur_mastermind.marketplace import models
from waldur_mastermind.marketplace_script import serializers, utils, PLUGIN_NAME


@shared_task(name='waldur_marketplace_script.pull_resources')
def pull_resources():
    for resource in models.Resource.objects.filter(
        offering__type=PLUGIN_NAME,
        offering__plugin_options__has_key='pull',
        state__in=[models.Resource.States.OK, models.Resource.States.ERRED]
    ):
        pull_resource.delay(resource.id)


@shared_task
def pull_resource(resource_id):
    resource = models.Resource.objects.get(id=resource_id)
    options = resource.offering.plugin_options

    serializer = serializers.OrderItemSerializer(instance=resource)
    environment = {key.upper(): str(value) for key, value in serializer.data}
    if isinstance(options.get('environ'), dict):
        environment.update(options['environ'])

    language = options['language']
    image = settings.WALDUR_MARKETPLACE_SCRIPT['DOCKER_IMAGES'].get(language)
    utils.execute_script(
        image=image,
        command=language,
        src=options['pull'],
        environment=environment
    )<commit_msg>Fix typo.<commit_after>from celery import shared_task
from django.conf import settings

from waldur_mastermind.marketplace import models
from waldur_mastermind.marketplace_script import serializers, utils, PLUGIN_NAME


@shared_task(name='waldur_marketplace_script.pull_resources')
def pull_resources():
    for resource in models.Resource.objects.filter(
        offering__type=PLUGIN_NAME,
        offering__plugin_options__has_key='pull',
        state__in=[models.Resource.States.OK, models.Resource.States.ERRED]
    ):
        pull_resource.delay(resource.id)


@shared_task
def pull_resource(resource_id):
    resource = models.Resource.objects.get(id=resource_id)
    options = resource.offering.plugin_options

    serializer = serializers.ResourceSerializer(instance=resource)
    environment = {key.upper(): str(value) for key, value in serializer.data}
    if isinstance(options.get('environ'), dict):
        environment.update(options['environ'])

    language = options['language']
    image = settings.WALDUR_MARKETPLACE_SCRIPT['DOCKER_IMAGES'].get(language)
    utils.execute_script(
        image=image,
        command=language,
        src=options['pull'],
        environment=environment
    )
{'fraction_non_alphanumeric': 0.09741060419235512, 'fraction_numerical': 0.0, 'mean_word_length': 4.544419134396355, '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': '2761183', 'n_tokens_mistral': 704, 'n_tokens_neox': 700, 'n_words': 121}