Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding path validator for non-maya nodes #4271

Merged
merged 12 commits into from
Jan 25, 2023
51 changes: 51 additions & 0 deletions openpype/hosts/maya/plugins/publish/validate_path_for_plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import os
BigRoy marked this conversation as resolved.
Show resolved Hide resolved

from maya import cmds

import pyblish.api

from openpype.pipeline.publish import ValidateContentsOrder


class ValidatePathForPlugin(pyblish.api.InstancePlugin):
"""
Ensure Paths in Non-Maya Nodes(from plugins
such as Yeti, AbcExport) are correct
"""

order = ValidateContentsOrder
hosts = ['maya']
families = ["workfile"]
label = "Non-existent Paths in Non-Maya Nodes"
BigRoy marked this conversation as resolved.
Show resolved Hide resolved

def get_invalid(self, instance):
invalid = list()

# get the project setting
validate_path = (
instance.context.data["project_settings"]["maya"]["publish"]
)
file_attr = validate_path["ValidatePathForPlugin"]["attribute"]
if file_attr:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd try to push for less indentation and change this to:

if not file_attr:
    return []

# get the nodes and file attributes
for node, attr in file_attr.items():
# check the related nodes
targets = cmds.ls(type=node)

for target in targets:
# get the filepath
file_attr = "{}.{}".format(target, attr)
filepath = cmds.getAttr(file_attr)

if filepath and not os.path.exists(filepath):
self.log.error("File {0} not exists".format(filepath)) # noqa
invalid.append(target)

return invalid

def process(self, instance):
"""Process all directories Set as Filenames in Non-Maya Nodes"""
invalid = self.get_invalid(instance)
if invalid:
raise RuntimeError("Non-existent Path "
"found: {0}".format(invalid))
96 changes: 77 additions & 19 deletions openpype/settings/defaults/project_settings/maya.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,24 +158,6 @@
"Main"
]
},
"CreateMultiverseUsd": {
"enabled": true,
"defaults": [
"Main"
]
},
"CreateMultiverseUsdComp": {
"enabled": true,
"defaults": [
"Main"
]
},
"CreateMultiverseUsdOver": {
"enabled": true,
"defaults": [
"Main"
]
},
"CreateAss": {
"enabled": true,
"defaults": [
Expand All @@ -196,6 +178,24 @@
"maskColor_manager": false,
"maskOperator": false
},
"CreateMultiverseUsd": {
"enabled": true,
"defaults": [
"Main"
]
},
"CreateMultiverseUsdComp": {
"enabled": true,
"defaults": [
"Main"
]
},
"CreateMultiverseUsdOver": {
"enabled": true,
"defaults": [
"Main"
]
},
"CreateAssembly": {
"enabled": true,
"defaults": [
Expand Down Expand Up @@ -337,6 +337,64 @@
"families": [
"rig"
]
},
"ValidatePathForPlugin": {
"enabled": true,
"optional": false,
"active": true,
"attribute": {
"AlembicNode": "abc_File",
BigRoy marked this conversation as resolved.
Show resolved Hide resolved
"VRayProxy": "fileName",
"RenderManArchive": "filename",
"pgYetiMaya": "cacheFileName",
"aiStandIn": "dso",
"RedshiftSprite": "tex0",
"RedshiftBokeh": "dofBokehImage",
"RedshiftCameraMap": "tex0",
"RedshiftEnvironment": "tex0",
"RedshiftEnvironment": "tex1",
"RedshiftEnvironment": "tex2",
"RedshiftDomeLight": "tex0",
"RedshiftDomeLight": "tex1",
"RedshiftIESLight": "profile",
"RedshiftLightGobo": "tex0",
"RedshiftNormalMap": "tex0",
"RedshiftProxyMesh": "fileName",
"RedshiftVolumeShape": "fileName",
"VRayTexGLSL": "fileName",
"VRayMtlGLSL": "fileName",
"VRayVRmatMtl": "fileName",
"VRayPtex": "ptexFile",
"VRayLightIESShape": "iesFile",
"VRayMesh": "fileName2",
"VRayMesh": "overrideFileName",
"VRayMesh": "alembicLayersFileName",
"VRayMesh": "materialAssignmentsFile",
"VRayMtlOSL": "fileName",
"VRayTexOSL": "fileName",
"VRayTexOCIO": "ocioConfigFile",
"VRaySettingsNode": "causticsFile2",
"VRaySettingsNode": "causticsAutoSaveFile2",
"VRaySettingsNode": "lc_fileName",
"VRaySettingsNode": "lc_autoSaveFile",
"VRaySettingsNode": "imap_fileName2",
"VRaySettingsNode": "imap_autoSaveFile2",
"VRaySettingsNode": "pmap_file2",
"VRaySettingsNode": "pmap_autoSaveFile2",
"VRayScannedMtl": "file",
"VRayScene": "FilePath",
"VRayScene": "parameterOverrideFilePath",
"VRayMtlMDL": "filename",
"VRaySimbiont": "file",
"dlOpenVDBShape": "filename",
"pgYetiMayaShape": "cfn",
"pgYetiMayaShape": "ofn",
"pgYetiMayaShape": "labf",
"pgYetiMayaShape": "trf",
"pgYetiMayaShape": "liveABCFilename",
"gpuCache": "cacheFileName"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing indentation for attributes entries.

}

},
"ValidateRenderSettings": {
"arnold_render_attributes": [],
Expand Down Expand Up @@ -1040,4 +1098,4 @@
"ValidateNoAnimation": false
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,41 @@
}
]
},
{
"type": "dict",
"collapsible": true,
"checkbox_key": "enabled",
"key": "ValidatePathForPlugin",
"label": "Non-existent Paths in Non-Maya Nodes",
"is_group": true,
"children": [
{
"type": "boolean",
"key": "enabled",
"label": "Enabled"
},
{
"type": "boolean",
"key": "optional",
"label": "Optional"
},
{
"type": "boolean",
"key": "active",
"label": "Active"
},
{
"type": "dict-modifiable",
"collapsible": true,
"key": "attribute",
"label": "File Attribute",
"use_label_wrap": true,
"object_type": {
"type": "text"
}
}
]
},
{
"type": "dict",
"collapsible": true,
Expand Down