Skip to content

validate_instances

ValidateInstance

Bases: InstancePlugin, OptionalPyblishPluginMixin

Validate the instance folder is the current folder.

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

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

    def process(self, instance):
        if not self.is_active(instance.data):
            return

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

        formatting_data = {
            "found": instance_folder_path,
            "expected": current_folder_path
        }
        if instance_folder_path != current_folder_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
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
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"]:
            instance = result["instance"]
            if (
                result["error"] is not None
                and instance is not None
                and instance not in failed
            ):
                failed.append(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)