Skip to content

validate_instance_folder

ValidateInstanceFolder

Bases: InstancePlugin

Validate the instance folder is the current selected context folder.

As it might happen that multiple worfiles are opened at same time, switching between them would mess with selected context. (From Launcher or Ftrack).

In that case outputs might be output under wrong folder!

Repair action will use Context folder value (from Workfiles or Launcher) Closing and reopening with Workfiles will refresh Context value.

Source code in client/ayon_aftereffects/plugins/publish/validate_instance_folder.py
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
class ValidateInstanceFolder(pyblish.api.InstancePlugin):
    """Validate the instance folder is the current selected context folder.

        As it might happen that multiple worfiles are opened at same time,
        switching between them would mess with selected context. (From Launcher
        or Ftrack).

        In that case outputs might be output under wrong folder!

        Repair action will use Context folder value (from Workfiles or Launcher)
        Closing and reopening with Workfiles will refresh  Context value.
    """

    label = "Validate Instance Folder"
    hosts = ["aftereffects"]
    actions = [ValidateInstanceFolderRepair]
    order = ValidateContentsOrder

    def process(self, instance):
        instance_folder = instance.data["folderPath"]
        current_folder = get_current_folder_path()

        if instance_folder != current_folder:
            raise PublishXmlValidationError(self, (
                f"Instance folder {instance_folder} is not the same "
                f"as current context {current_folder}."
            ))

ValidateInstanceFolderRepair

Bases: Action

Repair the instance folder with value from Context.

Source code in client/ayon_aftereffects/plugins/publish/validate_instance_folder.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class ValidateInstanceFolderRepair(pyblish.api.Action):
    """Repair the instance folder with value from Context."""

    label = "Repair"
    icon = "wrench"
    on = "failed"

    def process(self, context, plugin):

        # Get the errored instances
        failed = []
        for result in context.data["results"]:
            if (result["error"] is not None and result["instance"] is not None
                    and result["instance"] not in failed):
                failed.append(result["instance"])

        # Apply pyblish.logic to get the instances for the plug-in
        instances = pyblish.api.instances_by_plugin(failed, plugin)
        stub = get_stub()
        for instance in instances:
            data = stub.read(instance[0])

            data["folderPath"] = get_current_folder_path()
            stub.imprint(instance[0].instance_id, data)