From 285ad4cdb3d9282df909d71e55714341cd4146f6 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Mon, 8 Jul 2024 19:59:33 +0200 Subject: [PATCH 1/3] Ignore invalid representation ids --- ...collect_input_representations_to_versions.py | 17 +++++++++++++++++ .../publish/collect_scene_loaded_versions.py | 17 ++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/plugins/publish/collect_input_representations_to_versions.py b/client/ayon_core/plugins/publish/collect_input_representations_to_versions.py index 770f3470c6..009acba89c 100644 --- a/client/ayon_core/plugins/publish/collect_input_representations_to_versions.py +++ b/client/ayon_core/plugins/publish/collect_input_representations_to_versions.py @@ -1,7 +1,18 @@ +import uuid + import ayon_api import pyblish.api +def is_valid_uuid(value) -> bool: + """Return whether value is a valid UUID""" + try: + uuid.UUID(value) + except ValueError: + return False + return True + + class CollectInputRepresentationsToVersions(pyblish.api.ContextPlugin): """Converts collected input representations to input versions. @@ -23,6 +34,12 @@ class CollectInputRepresentationsToVersions(pyblish.api.ContextPlugin): if inst_repre: representations.update(inst_repre) + # Ignore representation ids that are not valid + representations = { + representation_id for representation_id in representations + if is_valid_uuid(representation_id) + } + repre_entities = ayon_api.get_representations( project_name=context.data["projectName"], representation_ids=representations, diff --git a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py index 1267c009e7..0a8fc93cf7 100644 --- a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py +++ b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py @@ -1,9 +1,20 @@ +import uuid + import ayon_api import pyblish.api from ayon_core.pipeline import registered_host +def is_valid_uuid(value) -> bool: + """Return whether value is a valid UUID""" + try: + uuid.UUID(value) + except ValueError: + return False + return True + + class CollectSceneLoadedVersions(pyblish.api.ContextPlugin): order = pyblish.api.CollectorOrder + 0.0001 @@ -40,6 +51,10 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin): container["representation"] for container in containers } + repre_ids = { + repre_id for repre_id in repre_ids + if is_valid_uuid(repre_id) + } project_name = context.data["projectName"] repre_entities = ayon_api.get_representations( @@ -65,7 +80,7 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin): continue # NOTE: - # may have more then one representation that are same version + # may have more than one representation that are same version version = { "container_name": con["name"], "representation_id": repre_entity["id"], From a782ede959d3689e27d06e6cc991d5d31b1a2741 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Tue, 9 Jul 2024 10:09:57 +0200 Subject: [PATCH 2/3] Use `ayon_api.utils.convert_entity_id` to validate UUID --- ...llect_input_representations_to_versions.py | 14 ++------------ .../publish/collect_scene_loaded_versions.py | 19 +++++-------------- 2 files changed, 7 insertions(+), 26 deletions(-) diff --git a/client/ayon_core/plugins/publish/collect_input_representations_to_versions.py b/client/ayon_core/plugins/publish/collect_input_representations_to_versions.py index 009acba89c..b9fe97b80b 100644 --- a/client/ayon_core/plugins/publish/collect_input_representations_to_versions.py +++ b/client/ayon_core/plugins/publish/collect_input_representations_to_versions.py @@ -1,18 +1,8 @@ -import uuid - import ayon_api +import ayon_api.utils import pyblish.api -def is_valid_uuid(value) -> bool: - """Return whether value is a valid UUID""" - try: - uuid.UUID(value) - except ValueError: - return False - return True - - class CollectInputRepresentationsToVersions(pyblish.api.ContextPlugin): """Converts collected input representations to input versions. @@ -37,7 +27,7 @@ class CollectInputRepresentationsToVersions(pyblish.api.ContextPlugin): # Ignore representation ids that are not valid representations = { representation_id for representation_id in representations - if is_valid_uuid(representation_id) + if ayon_api.utils.convert_entity_id(representation_id) } repre_entities = ayon_api.get_representations( diff --git a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py index 0a8fc93cf7..7e955302c6 100644 --- a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py +++ b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py @@ -1,20 +1,9 @@ -import uuid - import ayon_api -import pyblish.api +import ayon_api.utils from ayon_core.pipeline import registered_host -def is_valid_uuid(value) -> bool: - """Return whether value is a valid UUID""" - try: - uuid.UUID(value) - except ValueError: - return False - return True - - class CollectSceneLoadedVersions(pyblish.api.ContextPlugin): order = pyblish.api.CollectorOrder + 0.0001 @@ -51,9 +40,11 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin): container["representation"] for container in containers } + + # Ignore representation ids that are not valid repre_ids = { - repre_id for repre_id in repre_ids - if is_valid_uuid(repre_id) + representation_id for representation_id in repre_ids + if ayon_api.utils.convert_entity_id(representation_id) } project_name = context.data["projectName"] From b25e3d0db63f21d0172decb5cec580cf3fdf6d76 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Tue, 9 Jul 2024 10:12:56 +0200 Subject: [PATCH 3/3] Fix broken import --- .../ayon_core/plugins/publish/collect_scene_loaded_versions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py index 7e955302c6..1abb8e29d2 100644 --- a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py +++ b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py @@ -2,6 +2,7 @@ import ayon_api import ayon_api.utils from ayon_core.pipeline import registered_host +import pyblish.api class CollectSceneLoadedVersions(pyblish.api.ContextPlugin):