Skip to content

validate_file_extension

ValidateFileExtension

Bases: HoudiniInstancePlugin

Validate the output file extension fits the output product type.

File extensions
  • Pointcache must be .abc
  • Camera must be .abc
  • VDB must be .vdb
Source code in client/ayon_houdini/plugins/publish/validate_file_extension.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
class ValidateFileExtension(plugin.HoudiniInstancePlugin):
    """Validate the output file extension fits the output product type.

    File extensions:
        - Pointcache must be .abc
        - Camera must be .abc
        - VDB must be .vdb

    """

    order = pyblish.api.ValidatorOrder
    families = ["camera", "vdbcache"]
    label = "Output File Extension"

    product_type_extensions = {
        "camera": ".abc",
        "vdbcache": ".vdb",
    }

    def process(self, instance):

        invalid = self.get_invalid(instance)
        if invalid:
            raise PublishValidationError(
                f"ROP node has incorrect file extension: {invalid[0].path()}",
                title=self.label
            )

    @classmethod
    def get_invalid(cls, instance):
        # Get expected extension
        product_type = instance.data.get("productType")
        extension = cls.product_type_extensions.get(product_type, None)
        if extension is None:
            raise PublishValidationError(
                "Unsupported product type: {}".format(product_type),
                title=cls.label)

        # Perform extension check
        node = hou.node(instance.data["instance_node"])
        output = lib.get_output_parameter(node).eval()
        _, output_extension = os.path.splitext(output)
        if output_extension != extension:
            return [node]