Skip to content

validate_instances

ValidateInstance

Bases: InstancePlugin

Validate the instance folder is the current folder.

Source code in client/ayon_harmony/plugins/publish/validate_instances.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
class ValidateInstance(pyblish.api.InstancePlugin):
    """Validate the instance folder is the current folder."""

    label = "Validate Instance"
    hosts = ["harmony"]
    actions = [ValidateInstanceRepair]
    order = ValidateContentsOrder

    def process(self, instance):
        instance_folder_path = instance.data["folderPath"]
        current_colder_path = get_current_folder_path()
        msg = (
            "Instance folder is not the same as current folder:"
            f"\nInstance: {instance_folder_path}]"
            f"\nCurrent: {current_colder_path}"
        )

        formatting_data = {
            "found": instance_folder_path,
            "expected": current_colder_path
        }
        if instance_folder_path != current_colder_path:
            raise PublishXmlValidationError(self, msg,
                                            formatting_data=formatting_data)

ValidateInstanceRepair

Bases: Action

Repair the instance.

Source code in client/ayon_harmony/plugins/publish/validate_instances.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 ValidateInstanceRepair(pyblish.api.Action):
    """Repair the instance."""

    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)

        folder_path = get_current_folder_path()
        for instance in instances:
            data = harmony.read(instance.data["setMembers"][0])
            data["folderPath"] = folder_path
            harmony.imprint(instance.data["setMembers"][0], data)