From cef0cd57a0877bc323fa5b71fa22ee08a4e39935 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Thu, 5 Jul 2018 10:40:04 +0200 Subject: [PATCH 1/5] Simplify validate transfers and improve non-verbose log readability --- colorbleed/plugins/maya/publish/validate_transfers.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/colorbleed/plugins/maya/publish/validate_transfers.py b/colorbleed/plugins/maya/publish/validate_transfers.py index 7fb50567c1..5f1f5b3f41 100644 --- a/colorbleed/plugins/maya/publish/validate_transfers.py +++ b/colorbleed/plugins/maya/publish/validate_transfers.py @@ -28,22 +28,21 @@ class ValidateTransfers(pyblish.api.InstancePlugin): for source, destination in transfers: collected[destination.lower()].add(source.lower()) - invalid = False invalid_destinations = list() for destination, sources in collected.items(): if len(sources) > 1: + invalid_destinations.append(destination) + if verbose: self.log.error("Non-unique file transfer for resources: " "{0} (sources: {1})".format(destination, sources)) - invalid = True - invalid_destinations.append(destination) - if invalid: + if invalid_destinations: if not verbose: # If not verbose then still log the resource destination as # opposed to every individual file transfer self.log.error("Non-unique file transfers to destinations: " - "%s" % invalid_destinations) + "%s" % "\n".join(invalid_destinations)) raise RuntimeError("Invalid transfers in queue.") From ca291a4757419ef94b569de833c2404afcf93322 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Thu, 5 Jul 2018 10:44:59 +0200 Subject: [PATCH 2/5] Improve readability validate_shape_render_stats --- .../publish/validate_shape_render_stats.py | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/colorbleed/plugins/maya/publish/validate_shape_render_stats.py b/colorbleed/plugins/maya/publish/validate_shape_render_stats.py index 87b716650d..9a3067badb 100644 --- a/colorbleed/plugins/maya/publish/validate_shape_render_stats.py +++ b/colorbleed/plugins/maya/publish/validate_shape_render_stats.py @@ -10,8 +10,6 @@ class ValidateShapeRenderStats(pyblish.api.Validator): order = colorbleed.api.ValidateMeshOrder hosts = ['maya'] families = ['colorbleed.model'] - category = 'model' - version = (0, 1, 0) label = 'Shape Default Render Stats' actions = [colorbleed.api.SelectInvalidAction, colorbleed.api.RepairAction] @@ -26,19 +24,17 @@ class ValidateShapeRenderStats(pyblish.api.Validator): 'doubleSided': 1, 'opposite': 0} - @staticmethod - def get_invalid(instance): + @classmethod + def get_invalid(cls, instance): # It seems the "surfaceShape" and those derived from it have # `renderStat` attributes. shapes = cmds.ls(instance, long=True, type='surfaceShape') invalid = [] for shape in shapes: - for attr, requiredValue in \ - ValidateShapeRenderStats.defaults.iteritems(): - + for attr, default_value in cls.defaults.iteritems(): if cmds.attributeQuery(attr, node=shape, exists=True): value = cmds.getAttr('{}.{}'.format(shape, attr)) - if value != requiredValue: + if value != default_value: invalid.append(shape) return invalid @@ -48,14 +44,13 @@ class ValidateShapeRenderStats(pyblish.api.Validator): invalid = self.get_invalid(instance) if invalid: - raise ValueError("Shapes with non-standard renderStats " + raise ValueError("Shapes with non-default renderStats " "found: {0}".format(invalid)) - @staticmethod - def repair(instance): - shape_render_defaults = ValidateShapeRenderStats.defaults - for shape in ValidateShapeRenderStats.get_invalid(instance): - for attr, default_value in shape_render_defaults.iteritems(): + @classmethod + def repair(cls, instance): + for shape in cls.get_invalid(instance): + for attr, default_value in cls.defaults.iteritems(): if cmds.attributeQuery(attr, node=shape, exists=True): plug = '{0}.{1}'.format(shape, attr) From bd80df60848f4c549902d8eb3fc4a75fdb4e520c Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Thu, 5 Jul 2018 12:39:58 +0200 Subject: [PATCH 3/5] Allow any_outdated to ignore invalid containers --- colorbleed/lib.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/colorbleed/lib.py b/colorbleed/lib.py index 73bd80f9ff..11184e9098 100644 --- a/colorbleed/lib.py +++ b/colorbleed/lib.py @@ -16,16 +16,14 @@ def is_latest(representation): """Return whether the representation is from latest version Args: - representation (str or io.ObjectId): The representation id. + representation (dict): The representation document from the database. Returns: bool: Whether the representation is of latest version. """ - rep = io.find_one({"_id": io.ObjectId(representation), - "type": "representation"}) - version = io.find_one({"_id": rep['parent']}) + version = io.find_one({"_id": representation['parent']}) # Get highest version under the parent highest_version = io.find_one({ @@ -49,8 +47,15 @@ def any_outdated(): if representation in checked: continue - if not is_latest(container['representation']): + representation_doc = io.find_one({"_id": io.ObjectId(representation), + "type": "representation"}, + projection={"parent": True}) + if representation_doc and not is_latest(representation_doc): return True + elif not representation_doc: + log.debug("Container '{objectName}' has an invalid " + "representation, it is missing in the " + "database".format(**container)) checked.add(representation) return False From ed8ef0f5387703e3c8a4a7c71bf1cd33c6ef6489 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Thu, 5 Jul 2018 12:47:12 +0200 Subject: [PATCH 4/5] Optimize slightly with projection --- colorbleed/lib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colorbleed/lib.py b/colorbleed/lib.py index 11184e9098..0c88b622f3 100644 --- a/colorbleed/lib.py +++ b/colorbleed/lib.py @@ -29,7 +29,7 @@ def is_latest(representation): highest_version = io.find_one({ "type": "version", "parent": version["parent"] - }, sort=[("name", -1)]) + }, sort=[("name", -1)], projection={"name": True}) if version['name'] == highest_version['name']: return True From b642d2f60b9076a40f26fd6cf8209ad55ddc71d8 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Fri, 20 Jul 2018 16:45:27 +0200 Subject: [PATCH 5/5] Fix PLN-143 # Conflicts: # colorbleed/maya/plugin.py --- colorbleed/maya/plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/colorbleed/maya/plugin.py b/colorbleed/maya/plugin.py index ff212a9e5a..0b02da5727 100644 --- a/colorbleed/maya/plugin.py +++ b/colorbleed/maya/plugin.py @@ -89,8 +89,8 @@ class ReferenceLoader(api.Loader): references = set() for ref in cmds.ls(members, exactType="reference", objectsOnly=True): - # Ignore `sharedReferenceNode` - if ref == "sharedReferenceNode": + # Ignore any `:sharedReferenceNode` + if ref.rsplit(":", 1)[-1].startswith("sharedReferenceNode"): continue references.add(ref)