Skip to content

collect_local_render_instances

CollectLocalRenderInstances

Bases: MayaInstancePlugin

Collect instances for local render.

Source code in client/ayon_maya/plugins/publish/collect_local_render_instances.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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
class CollectLocalRenderInstances(plugin.MayaInstancePlugin):
    """Collect instances for local render.
    """
    order = pyblish.api.CollectorOrder + 0.31
    families = ["renderlayer"]

    label = "Collect local render instances"

    transfer_keys = {
        "creator_attributes",
        "publish_attributes"
        "transientData"
    }

    def process(self, instance):
        if instance.data.get("farm"):
            self.log.debug("Render on farm is enabled. "
                           "Skipping local render collecting.")
            return

        self.log.debug("Expected files for local render: %s",
                       instance.data.get("expectedFiles"))

        # Use same logic as how instances get created for farm submissions
        skeleton = create_skeleton_instance(
            instance,
            # TODO: These should be fixed in core to just allow the default
            #  None to work
            families_transfer=[],
            instance_transfer={},
        )
        for key in self.transfer_keys:
            if key in instance.data:
                skeleton[key] = instance.data[key]

        aov_instances = create_instances_for_aov(
            instance=instance,
            skeleton=skeleton,
            aov_filter={"maya": [".*"]},  # allow all as reviewables
            skip_integration_repre_list=[],
            do_not_add_review=False,
        )

        # Create instances for each AOV
        context = instance.context
        anatomy = context.data["anatomy"]

        render_target = instance.data.get("creator_attributes", {}).get(
            "render_target", "local"
        )

        # Add the instances directly to the current publish context
        for aov_instance_data in aov_instances:
            # The `create_instances_for_aov` makes some paths rootless paths,
            # like the "stagingDir" for each representation which we will make
            # absolute again.
            for repre in aov_instance_data["representations"]:
                repre["stagingDir"] = anatomy.fill_root(repre["stagingDir"])

            aov_instance = context.create_instance(
                aov_instance_data["productName"]
            )
            aov_instance.data.update(aov_instance_data)
            aov_instance.data["families"] = [f"render.{render_target}"]

            # Pass on 'review' family
            if "review" in aov_instance_data["families"]:
                aov_instance.data["families"].append("review")

        # Skip integrating original render instance.
        # We are not removing it because it's used to trigger the render.
        instance.data["integrate"] = False