Repository: ynput/OpenPype
Issue: Maya: Redshift Validate Render Settings for Cryptomatte reports invalid file format

 **Describe the bug**

The code [here](https://github.com/pypeclub/OpenPype/blob/2eab1574eebac97cfd943b2510288f97c7eac857/openpype/hosts/maya/plugins/publish/validate_rendersettings.py#L190-L195) is to validate the extensions/file formats of the AOVs are consistent with the global render file format set.

The Redshift Cryptomatte AOV uses a custom `Cryptomatte (EXR)` file format and thus will always differ from e.g. the global `OpenEXR` file format.

The "repair" method does allow the user to repair and pass the validator. However, Redshift will still enforce the Cryptomatte (EXR) and after repair will actually spew out Maya errors whenever you select the Cryptomatte AOV with the Attribute Editor visible - this is due to that particular AOV not havingt he `OpenEXR` file format entry available.

**To Reproduce**
Steps to reproduce the behavior:
1. Create a render scene with Redshift
2. Add Cryptomatte AOV
3. Check the errors, perform a repair
4. See the issue described above.

**Expected behavior**

Should just allow the Cryptomatte (EXR) file format to be set for cryptomatte AOVs. 

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
 - OS: Windows
 - Host: Maya 2022 py3 Redshift 3.5.03

[cuID:2hz0tnq]

Changed files:
openpype/hosts/maya/plugins/publish/validate_rendersettings.py

diff --git a/openpype/hosts/maya/plugins/publish/validate_rendersettings.py b/openpype/hosts/maya/plugins/publish/validate_rendersettings.py
index 1dab3274a0..bfb72c7012 100644
--- a/openpype/hosts/maya/plugins/publish/validate_rendersettings.py
+++ b/openpype/hosts/maya/plugins/publish/validate_rendersettings.py
@@ -10,6 +10,12 @@ import openpype.api
 from openpype.hosts.maya.api import lib
 
 
+def get_redshift_image_format_labels():
+    """Return nice labels for Redshift image formats."""
+    var = "$g_redshiftImageFormatLabels"
+    return mel.eval("{0}={0}".format(var))
+
+
 class ValidateRenderSettings(pyblish.api.InstancePlugin):
     """Validates the global render settings
 
@@ -102,8 +108,9 @@ class ValidateRenderSettings(pyblish.api.InstancePlugin):
 
         # Get the node attributes for current renderer
         attrs = lib.RENDER_ATTRS.get(renderer, lib.RENDER_ATTRS['default'])
+        # Prefix attribute can return None when a value was never set
         prefix = lib.get_attr_in_layer(cls.ImagePrefixes[renderer],
-                                       layer=layer)
+                                       layer=layer) or ""
         padding = lib.get_attr_in_layer("{node}.{padding}".format(**attrs),
                                         layer=layer)
 
@@ -180,18 +187,22 @@ class ValidateRenderSettings(pyblish.api.InstancePlugin):
                         redshift_AOV_prefix
                     ))
                     invalid = True
-                # get aov format
-                aov_ext = cmds.getAttr(
-                    "{}.fileFormat".format(aov), asString=True)
-
-                default_ext = cmds.getAttr(
-                    "redshiftOptions.imageFormat", asString=True)
-
-                if default_ext != aov_ext:
-                    cls.log.error(("AOV file format is not the same "
-                                   "as the one set globally "
-                                   "{} != {}").format(default_ext,
-                                                      aov_ext))
+
+                # check aov file format
+                aov_ext = cmds.getAttr("{}.fileFormat".format(aov))
+                default_ext = cmds.getAttr("redshiftOptions.imageFormat")
+                aov_type = cmds.getAttr("{}.aovType".format(aov))
+                if aov_type == "Cryptomatte":
+                    # redshift Cryptomatte AOV always uses "Cryptomatte (EXR)"
+                    # so we ignore validating file format for it.
+                    pass
+
+                elif default_ext != aov_ext:
+                    labels = get_redshift_image_format_labels()
+                    cls.log.error(
+                        "AOV file format {} does not match global file format "
+                        "{}".format(labels[aov_ext], labels[default_ext])
+                    )
                     invalid = True
 
         if renderer == "renderman":
@@ -291,6 +302,9 @@ class ValidateRenderSettings(pyblish.api.InstancePlugin):
             default = lib.RENDER_ATTRS['default']
             render_attrs = lib.RENDER_ATTRS.get(renderer, default)
 
+            # Repair animation must be enabled
+            cmds.setAttr("defaultRenderGlobals.animation", True)
+
             # Repair prefix
             if renderer != "renderman":
                 node = render_attrs["node"]
@@ -323,8 +337,7 @@ class ValidateRenderSettings(pyblish.api.InstancePlugin):
                 cmds.optionMenuGrp("vrayRenderElementSeparator",
                                    v=instance.data.get("aovSeparator", "_"))
                 cmds.setAttr(
-                    "{}.fileNameRenderElementSeparator".format(
-                        node),
+                    "{}.fileNameRenderElementSeparator".format(node),
                     instance.data.get("aovSeparator", "_"),
                     type="string"
                 )