<commit_before>import pyblish.api


class MindbenderSubmitDeadline(pyblish.api.InstancePlugin):
    """Submit available render layers to Deadline

    Renders are submitted to a Deadline Web Service as
    supplied via the environment variable AVALON_DEADLINE

    """

    label = "Submit to Deadline"
    order = pyblish.api.IntegratorOrder
    hosts = ["maya"]
    families = ["mindbender.renderlayer"]

    def process(self, instance):
        import os
        import json
        import shutil
        import getpass

        from maya import cmds

        from avalon import api
        from avalon.vendor import requests

        deadline = api.Session.get("AVALON_DEADLINE", None)
        assert deadline, "Requires AVALON_DEADLINE"

        context = instance.context
        workspace = context.data["workspaceDir"]
        fpath = context.data["currentFile"]
        fname = os.path.basename(fpath)
        name, ext = os.path.splitext(fname)
        comment = context.data.get("comment", "")
        dirname = os.path.join(workspace, "renders", name)

        try:
            os.makedirs(dirname)
        except OSError:
            pass

        # E.g. http://192.168.0.1:8082/api/jobs
        url = deadline + "/api/jobs"

        # Documentation for keys available at:
        # https://docs.thinkboxsoftware.com
        #    /products/deadline/8.0/1_User%20Manual/manual
        #    /manual-submission.html#job-info-file-options
        payload = {
            "JobInfo": {
                # Top-level group name
                "BatchName": fname,

                # Job name, as seen in Monitor
                "Name": "%s - %s" % (fname, instance.name),
<commit_msg>added assertion similar to validate_deadline_done<commit_after>import pyblish.api


class MindbenderSubmitDeadline(pyblish.api.InstancePlugin):
    """Submit available render layers to Deadline

    Renders are submitted to a Deadline Web Service as
    supplied via the environment variable AVALON_DEADLINE

    """

    label = "Submit to Deadline"
    order = pyblish.api.IntegratorOrder
    hosts = ["maya"]
    families = ["mindbender.renderlayer"]

    def process(self, instance):
        import os
        import json
        import shutil
        import getpass

        from maya import cmds

        from avalon import api
        from avalon.vendor import requests

        assert "AVALON_DEADLINE" in api.Session, ("Environment variable "
                                                  "missing: 'AVALON_DEADLINE")
        AVALON_DEADLINE = api.Session["AVALON_DEADLINE"]

        context = instance.context
        workspace = context.data["workspaceDir"]
        fpath = context.data["currentFile"]
        fname = os.path.basename(fpath)
        name, ext = os.path.splitext(fname)
        comment = context.data.get("comment", "")
        dirname = os.path.join(workspace, "renders", name)

        try:
            os.makedirs(dirname)
        except OSError:
            pass

        # E.g. http://192.168.0.1:8082/api/jobs
        url = "{}/api/jobs?JobID=%s".format(AVALON_DEADLINE)

        # Documentation for keys available at:
        # https://docs.thinkboxsoftware.com
        #    /products/deadline/8.0/1_User%20Manual/manual
        #    /manual-submission.html#job-info-file-options
        payload = {
            "JobInfo": {
                # Top-level group name
                "BatchName": fname,

                # Job name, as seen in Monitor
                "Name": "%s - %s" % (fname, instance.name),

{'fraction_non_alphanumeric': 0.09847198641765705, 'fraction_numerical': 0.009620826259196379, 'mean_word_length': 2.0369415807560136, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '816044', 'n_tokens_mistral': 1071, 'n_tokens_neox': 1008, 'n_words': 242}