Skip to content

collect_editorial_package

EditorialPackageInstances

Bases: InstancePlugin

Collect all Track items selection.

Source code in client/ayon_resolve/plugins/publish/collect_editorial_package.py
 8
 9
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
class EditorialPackageInstances(pyblish.api.InstancePlugin):
    """Collect all Track items selection."""

    order = pyblish.api.CollectorOrder - 0.49
    label = "Collect Editorial Package Instances"
    families = ["editorial_pkg"]

    def process(self, instance):
        project_name = instance.context.data["projectName"]
        self.log.info(f"project: {project_name}")

        media_pool_item = instance.data["transientData"]["timeline_pool_item"]

        # Special case for versioning editorial_pkg products:
        # * instance created by creator: version up as usual
        # * instance created from loader: loaded version is added 
        #   into the instance by loader. Then version up from initial pkg
        #   to keep 'chained' version across tasks/product when possible.
        version = instance.data.get("version")
        if version is not None:
            # get version from publish data and rise it one up
            version += 1

            # make sure last version of product is higher than current
            # expected current version from publish data
            folder_entity = ayon_api.get_folder_by_path(
                project_name=project_name,
                folder_path=instance.data["folderPath"],
            )
            last_version = ayon_api.get_last_version_by_product_name(
                project_name=project_name,
                product_name=instance.data["productName"],
                folder_id=folder_entity["id"],
            )
            if last_version is not None:
                last_version = int(last_version["version"])
                if version <= last_version:
                    version = last_version + 1

            instance.data["version"] = version

        with maintain_current_timeline(media_pool_item) as timeline:
            instance.data.update(
                {
                    "mediaPoolItem": media_pool_item,
                    "item": media_pool_item,
                    "fps": timeline.GetSetting("timelineFrameRate"),
                    "frameStart": timeline.GetStartFrame(),
                    "frameEnd": timeline.GetEndFrame()
                }
            )

        # Shall the instance produce reviewable representation ?
        creator_attributes = instance.data.get("creator_attributes", {})
        reviewable = creator_attributes.pop("review", False)
        if reviewable:
            instance.data["families"].append("review")

        self.log.debug(f"Editorial Package: {instance.data}")