<commit_before>from waldur_mastermind.marketplace import models as marketplace_models
from waldur_mastermind.marketplace.utils import get_resource_state


def create_marketplace_resource_for_imported_cluster(sender, instance, offering=None, plan=None, **kwargs):
    resource = marketplace_models.Resource(
        project=instance.service_project_link.project,
        state=get_resource_state(instance.state),
        name=instance.name,
        scope=instance,
        created=instance.created,
        plan=plan,
        offering=offering,
    )

    resource.init_cost()
    resource.save()
    resource.init_quotas()
<commit_msg>Skip marketplace resource creation when cluster is imported directly [WAL-2768]<commit_after>from waldur_mastermind.marketplace import models as marketplace_models
from waldur_mastermind.marketplace.utils import get_resource_state


def create_marketplace_resource_for_imported_cluster(sender, instance, offering=None, plan=None, **kwargs):
    if not offering or not plan:
        # When cluster is imported directly (ie without marketplace),
        # marketplace resources are not created.
        return
    resource = marketplace_models.Resource(
        project=instance.service_project_link.project,
        state=get_resource_state(instance.state),
        name=instance.name,
        scope=instance,
        created=instance.created,
        plan=plan,
        offering=offering,
    )

    resource.init_cost()
    resource.save()
    resource.init_quotas()

{'fraction_non_alphanumeric': 0.07451763140385895, 'fraction_numerical': 0.0026613439787092482, 'mean_word_length': 3.9473684210526314, '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': '6609732', 'n_tokens_mistral': 412, 'n_tokens_neox': 400, 'n_words': 85}