mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
refactored collector and validators to match new lookdata formatting
This commit is contained in:
parent
3955727092
commit
a324e5db91
5 changed files with 54 additions and 30 deletions
|
|
@ -120,8 +120,7 @@ class CollectLook(pyblish.api.InstancePlugin):
|
|||
|
||||
# Store data on the instance
|
||||
instance.data["lookData"] = {"attributes": attributes,
|
||||
"relationships": sets.values(),
|
||||
"sets": looksets}
|
||||
"relationships": sets}
|
||||
|
||||
# Collect file nodes used by shading engines (if we have any)
|
||||
files = list()
|
||||
|
|
@ -134,7 +133,7 @@ class CollectLook(pyblish.api.InstancePlugin):
|
|||
instance.data["resources"] = resources
|
||||
|
||||
# Log a warning when no relevant sets were retrieved for the look.
|
||||
if not instance.data["lookData"]["sets"]:
|
||||
if not instance.data["lookData"]["relationships"]:
|
||||
self.log.warning("No sets found for the nodes in the instance: "
|
||||
"%s" % instance[:])
|
||||
|
||||
|
|
@ -170,8 +169,7 @@ class CollectLook(pyblish.api.InstancePlugin):
|
|||
if objset in sets:
|
||||
continue
|
||||
|
||||
sets[objset] = {"name": objset,
|
||||
"uuid": lib.get_id(objset),
|
||||
sets[objset] = {"uuid": lib.get_id(objset),
|
||||
"members": list()}
|
||||
|
||||
return sets
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class ValidateLookContents(pyblish.api.InstancePlugin):
|
|||
|
||||
invalid = set()
|
||||
|
||||
attributes = ["sets", "relationships", "attributes"]
|
||||
attributes = ["relationships", "attributes"]
|
||||
lookdata = instance.data["lookData"]
|
||||
for attr in attributes:
|
||||
if attr not in lookdata:
|
||||
|
|
@ -56,8 +56,10 @@ class ValidateLookContents(pyblish.api.InstancePlugin):
|
|||
"'{}'".format(attr))
|
||||
invalid.add(instance.name)
|
||||
|
||||
if not lookdata["relationships"] or not lookdata["sets"]:
|
||||
cls.log.error("Look has no `relationship` or `sets`")
|
||||
# Validate at least one single relationship is collected
|
||||
if not lookdata["relationships"]:
|
||||
cls.log.error("Look '{}' has no `relationship` or "
|
||||
"`sets`".format(instance.name))
|
||||
invalid.add(instance.name)
|
||||
|
||||
return invalid
|
||||
|
|
@ -69,11 +71,11 @@ class ValidateLookContents(pyblish.api.InstancePlugin):
|
|||
invalid = set()
|
||||
|
||||
relationships = instance.data["lookData"]["relationships"]
|
||||
for relationship in relationships:
|
||||
look_name = relationship["name"]
|
||||
uuid = relationship["uuid"]
|
||||
for objectset, members in relationships.items():
|
||||
uuid = members["uuid"]
|
||||
if not uuid:
|
||||
cls.errors.append("{} has invalid ID ")
|
||||
look_name = members["name"]
|
||||
cls.log.error("{} has invalid ID ".format(look_name))
|
||||
invalid.add(look_name)
|
||||
|
||||
return invalid
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import maya.cmds as cmds
|
||||
|
||||
import pyblish.api
|
||||
import colorbleed.api
|
||||
import colorbleed.maya.lib as lib
|
||||
|
|
@ -37,11 +35,10 @@ class ValidateLookMembers(pyblish.api.InstancePlugin):
|
|||
|
||||
members = set()
|
||||
relationships = instance.data["lookData"]["relationships"]
|
||||
for relation in relationships:
|
||||
for relation in relationships.values():
|
||||
members.update([member['name'] for member in relation['members']])
|
||||
|
||||
invalid = [m for m in members if not lib.get_id(m)]
|
||||
if invalid:
|
||||
raise RuntimeError("Found invalid nodes.\nNo ID : "
|
||||
"{}".format(invalid))
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class ValidateNonDuplicateRelationshipMembers(pyblish.api.InstancePlugin):
|
|||
# Get all members from the sets
|
||||
members = []
|
||||
relationships = instance.data["lookData"]["relationships"]
|
||||
for relationship in relationships:
|
||||
for relationship in relationships.values():
|
||||
members.extend([i['name'] for i in relationship['members']])
|
||||
|
||||
# Ensure we don't have components but the objects
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import pprint
|
||||
from collections import defaultdict
|
||||
|
||||
import pyblish.api
|
||||
|
|
@ -17,20 +18,44 @@ class ValidateLookNodeUniqueIds(pyblish.api.InstancePlugin):
|
|||
actions = [colorbleed.api.SelectInvalidAction,
|
||||
colorbleed.api.RepairAction]
|
||||
|
||||
@staticmethod
|
||||
def get_invalid(instance):
|
||||
@classmethod
|
||||
def get_invalid(cls, instance):
|
||||
|
||||
nodes = instance.data["lookData"]["sets"]
|
||||
invalid = []
|
||||
uuids_dict = defaultdict(list)
|
||||
|
||||
# Ensure all nodes have a cbId
|
||||
id_sets = defaultdict(list)
|
||||
for node in nodes:
|
||||
unique_id = lib.get_id(node)
|
||||
if not unique_id:
|
||||
continue
|
||||
id_sets[unique_id].append(node)
|
||||
relationships = instance.data["lookData"]["relationships"]
|
||||
pprint.pprint(relationships)
|
||||
for objectset, relationship in relationships.items():
|
||||
cls.log.info("Validating lookData for '%s'" % objectset)
|
||||
# check if node has UUID and this matches with found node
|
||||
for member in relationship["members"]:
|
||||
node = member["name"]
|
||||
member_uuid = member["uuid"]
|
||||
uuid_query = lib.get_id(node)
|
||||
|
||||
invalid = [n for n in id_sets.itervalues() if len(n) > 1]
|
||||
if not member_uuid:
|
||||
cls.log.error("No UUID found for '{}'".format(node))
|
||||
invalid.append(node)
|
||||
continue
|
||||
|
||||
if uuid_query != member_uuid:
|
||||
cls.log.error("UUID in lookData does not match with "
|
||||
"queried UUID of '{}'".format(node))
|
||||
invalid.append(node)
|
||||
continue
|
||||
|
||||
# check if the uuid has already passed through the check
|
||||
# if so it means its a duplicate.
|
||||
uuids_dict[objectset].append(uuid_query)
|
||||
|
||||
for objectset, member_uuids in uuids_dict.items():
|
||||
stored = len(member_uuids)
|
||||
unique = len(set(member_uuids))
|
||||
if unique != stored:
|
||||
rel_members = relationships[objectset]["members"]
|
||||
invalid.extend([i["name"] for i in rel_members if
|
||||
i["uuid"] not in unique])
|
||||
|
||||
return invalid
|
||||
|
||||
|
|
@ -39,5 +64,7 @@ class ValidateLookNodeUniqueIds(pyblish.api.InstancePlugin):
|
|||
|
||||
invalid = self.get_invalid(instance)
|
||||
if invalid:
|
||||
raise RuntimeError("Nodes found without "
|
||||
"asset IDs: {0}".format(invalid))
|
||||
for item in invalid:
|
||||
self.log.error("Invalid node : %s" % item)
|
||||
raise RuntimeError("Nodes found without unique "
|
||||
"IDs, see records")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue