Skip to content

validate_rendered_frames

ValidateRenderedFrames

Bases: InstancePlugin

Validates file output.

Source code in client/ayon_nuke/plugins/publish/validate_rendered_frames.py
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
class ValidateRenderedFrames(pyblish.api.InstancePlugin):
    """ Validates file output. """

    order = pyblish.api.ValidatorOrder + 0.1
    families = ["render", "prerender", "still"]

    label = "Validate rendered frame"
    hosts = ["nuke", "nukestudio"]
    actions = [RepairCollectionActionToLocal, RepairCollectionActionToFarm]

    settings_category = "nuke"

    def process(self, instance):
        node = instance.data["transientData"]["node"]

        f_data = {
            "node_name": node.name()
        }

        for repre in instance.data["representations"]:

            if not repre.get("files"):
                msg = ("no frames were collected, "
                       "you need to render them.\n"
                       "Check properties of write node (group) and"
                       "select 'Local' option in 'Publish' dropdown.")
                self.log.error(msg)
                raise PublishXmlValidationError(
                    self, msg, formatting_data=f_data)

            if isinstance(repre["files"], str):
                return

            collections, remainder = clique.assemble(repre["files"])
            self.log.debug("collections: {}".format(str(collections)))
            self.log.debug("remainder: {}".format(str(remainder)))

            collection = collections[0]

            f_start_h = instance.data["frameStartHandle"]
            f_end_h = instance.data["frameEndHandle"]

            frame_length = int(f_end_h - f_start_h + 1)

            if frame_length != 1:
                if len(collections) != 1:
                    msg = "There are multiple collections in the folder"
                    self.log.error(msg)
                    raise PublishXmlValidationError(
                        self, msg, formatting_data=f_data)

                if not collection.is_contiguous():
                    msg = "Some frames appear to be missing"
                    self.log.error(msg)
                    raise PublishXmlValidationError(
                        self, msg, formatting_data=f_data)

            collected_frames_len = len(collection.indexes)
            coll_start = min(collection.indexes)
            coll_end = max(collection.indexes)

            self.log.debug("frame_length: {}".format(frame_length))
            self.log.debug("collected_frames_len: {}".format(
                collected_frames_len))
            self.log.debug("f_start_h-f_end_h: {}-{}".format(
                f_start_h, f_end_h))
            self.log.debug(
                "coll_start-coll_end: {}-{}".format(coll_start, coll_end))

            self.log.debug(
                "len(collection.indexes): {}".format(collected_frames_len)
            )

            if ("slate" in instance.data["families"]) \
                    and (frame_length != collected_frames_len):
                collected_frames_len -= 1
                f_start_h += 1

            if (
                collected_frames_len != frame_length
                and coll_start <= f_start_h
                and coll_end >= f_end_h
            ):
                raise PublishXmlValidationError(
                    self, (
                        "{} missing frames. Use repair to "
                        "render all frames"
                    ).format(__name__), formatting_data=f_data
                )

            instance.data["collection"] = collection

            return