From 1e026d8fcb10e053615b1795edc5157600935e32 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Thu, 1 Aug 2024 15:50:45 +0200 Subject: [PATCH] Refactor config data retrieval logic in colorspace module - Removed redundant folder info handling - Added fallback mechanism for missing folder info --- client/ayon_core/pipeline/colorspace.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/client/ayon_core/pipeline/colorspace.py b/client/ayon_core/pipeline/colorspace.py index 106d43d55a..57a36286db 100644 --- a/client/ayon_core/pipeline/colorspace.py +++ b/client/ayon_core/pipeline/colorspace.py @@ -788,12 +788,6 @@ def _get_global_config_data( # TODO decide if this is the right name for representation repre_name = "ocioconfig" - folder_info = template_data.get("folder") - if not folder_info: - log.warning("Folder info is missing.") - return None - folder_path = folder_info["path"] - # Backward compatibility for old projects # TODO remove in future 0.4.5 onwards product_name = profile.get("product_name") @@ -809,6 +803,23 @@ def _get_global_config_data( product_name = published_product_data["product_name"] fallback_data = published_product_data["fallback"] + folder_info = template_data.get("folder") + if not folder_info: + log.warning("Folder info is missing.") + + # TODO: this fallback should be required after backward compatibility + # is removed + if fallback_data: + log.info("Using fallback data for ocio config path.") + # in case no product was found we need to use fallback + fallback_type = fallback_data["type"] + return _get_config_path_from_profile_data( + fallback_data, fallback_type, template_data + ) + return None + + folder_path = folder_info["path"] + if folder_id is None: folder_entity = ayon_api.get_folder_by_path( project_name, folder_path, fields={"id"} @@ -827,6 +838,7 @@ def _get_global_config_data( fields={"id", "name"} ) } + if not product_entities_by_name: # TODO: make this required in future 0.4.5 onwards if fallback_data: @@ -874,6 +886,7 @@ def _get_global_config_data( path = get_representation_path_with_anatomy(repre_entity, anatomy) template = repre_entity["attrib"]["template"] + return { "path": path, "template": template,