From 4bebdb5196ff89540820bdb44fb672d7f37f9dd5 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Mon, 28 Oct 2024 12:58:22 +0100 Subject: [PATCH 01/22] Add debug log for split comments in CollectTimelineInstances. Added a debug log statement to display the split comments for better debugging and understanding of the code flow. --- client/ayon_flame/plugins/publish/collect_timeline_instances.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/ayon_flame/plugins/publish/collect_timeline_instances.py b/client/ayon_flame/plugins/publish/collect_timeline_instances.py index dc13b93..8c33adc 100644 --- a/client/ayon_flame/plugins/publish/collect_timeline_instances.py +++ b/client/ayon_flame/plugins/publish/collect_timeline_instances.py @@ -210,6 +210,8 @@ def _get_comment_attributes(self, segment): } # search for `:` for split in self._split_comments(comment): + self.log.debug(f"__ split: {split}") + # make sure we ignore if not `:` in key if ":" not in split: continue From 702f80a09b3e864419488146a99ec14876706d06 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Mon, 28 Oct 2024 14:14:00 +0100 Subject: [PATCH 02/22] Refactor segment attribute retrieval and track name handling, add debug logs, update product names to avoid duplicity. Add used clip product names list for reference. --- client/ayon_flame/api/lib.py | 8 ++--- client/ayon_flame/api/plugin.py | 54 ++++++++++++++++++++++++--------- 2 files changed, 44 insertions(+), 18 deletions(-) diff --git a/client/ayon_flame/api/lib.py b/client/ayon_flame/api/lib.py index f455af4..a2b0526 100644 --- a/client/ayon_flame/api/lib.py +++ b/client/ayon_flame/api/lib.py @@ -538,10 +538,10 @@ def get_segment_attributes(segment): "shot_name": segment.shot_name.get_value(), "segment_name": segment.name.get_value(), "segment_comment": segment.comment.get_value(), - "tape_name": segment.tape_name, - "source_name": segment.source_name, - "fpath": segment.file_path, - "PySegment": segment + "tape_name": segment.tape_name.get_value(), + "source_name": segment.source_name.get_value(), + "fpath": segment.file_path.get_value(), + "PySegment": segment, } # head and tail with forward compatibility diff --git a/client/ayon_flame/api/plugin.py b/client/ayon_flame/api/plugin.py index fa77cee..491bcde 100644 --- a/client/ayon_flame/api/plugin.py +++ b/client/ayon_flame/api/plugin.py @@ -3,6 +3,7 @@ import shutil from copy import deepcopy from xml.etree import ElementTree as ET +from pprint import pformat import qargparse from qtpy import QtCore, QtWidgets @@ -337,6 +338,7 @@ class PublishableClip: flame.PySegment: flame api object """ vertical_clip_match = {} + vertical_clip_used = {} marker_data = {} types = { "shot": "shot", @@ -377,6 +379,8 @@ def __init__(self, segment, **kwargs): self.sequence_name = str(sequence_name).replace(" ", "_") self.clip_data = flib.get_segment_attributes(segment) + self.log.debug(f"clip_data: {pformat(self.clip_data)}") + # segment (clip) main attributes self.cs_name = self.clip_data["segment_name"] self.cs_index = int(self.clip_data["segment"]) @@ -385,8 +389,13 @@ def __init__(self, segment, **kwargs): # get track name and index self.track_index = int(self.clip_data["track"]) track_name = self.clip_data["track_name"] - self.track_name = str(track_name).replace(" ", "_").replace( - "*", "noname{}".format(self.track_index)) + self.track_name = ( + # make sure no space and other special characters are in track name + # default track name is `*` + str(track_name) + .replace(" ", "_") + .replace("*", f"noname{self.track_index}") + ) if kwargs.get("basicProductData"): self.marker_data.update(kwargs["basicProductData"]) @@ -397,9 +406,7 @@ def __init__(self, segment, **kwargs): # adding ui inputs if any self.ui_inputs = kwargs.get("ui_inputs", {}) - self.log.info("Inside of plugin: {}".format( - self.marker_data - )) + self.log.info(f"Inside of plugin: {self.marker_data}") # populate default data before we get other attributes self._populate_segment_default_data() @@ -479,8 +486,7 @@ def _populate_attributes(self): # define ui inputs if non gui mode was used self.shot_num = self.cs_index - self.log.debug( - "____ self.shot_num: {}".format(self.shot_num)) + self.log.debug(f"____ self.shot_num: {self.shot_num}") # ui_inputs data or default values if gui was not used self.rename = self.ui_inputs.get( @@ -621,19 +627,39 @@ def _convert_to_marker_data(self): `tag_hierarchy_data` will be set only once for every clip which is not hero clip. """ - _hero_data = deepcopy(hero_data) - _hero_data.update({"heroTrack": False}) + _distrib_data = deepcopy(hero_data) + _distrib_data.update({"heroTrack": False}) if _in <= self.clip_in and _out >= self.clip_out: data_product_name = hero_data["productName"] + used_names_list = self.vertical_clip_used.setdefault( + data_product_name, []) + + clip_product_name = self.product_name # add track index in case duplicity of names in hero data - if self.product_name in data_product_name: - _hero_data["productName"] = self.product_name + str( - self.track_index) + # INFO: this is for case where hero clip product name + # is the same as current clip product name + if clip_product_name in data_product_name: + clip_product_name = ( + f"{clip_product_name}{self.track_index}") + _distrib_data["productName"] = clip_product_name + + # in case track clip product name had been already used + # then add product name with clip index + if clip_product_name in used_names_list: + clip_product_name = ( + f"{clip_product_name}{self.cs_index}" + ) + _distrib_data["productName"] = clip_product_name + # in case track name and product name is the same then add if self.base_product_name == self.track_name: - _hero_data["productName"] = self.product_name + _distrib_data["productName"] = self.product_name + # assign data to return hierarchy data to tag - tag_hierarchy_data = _hero_data + tag_hierarchy_data = _distrib_data + + # add used product name to used list to avoid duplicity + used_names_list.append(clip_product_name) break # add data to return data dict From 99a0194c9dfe177db6a4e676620090a6f14dcdab Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Mon, 28 Oct 2024 14:16:14 +0100 Subject: [PATCH 03/22] Update segment attributes retrieval to use direct attribute access. - Simplified accessing tape_name attribute directly instead of using get_value() method. --- client/ayon_flame/api/lib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_flame/api/lib.py b/client/ayon_flame/api/lib.py index a2b0526..c48dced 100644 --- a/client/ayon_flame/api/lib.py +++ b/client/ayon_flame/api/lib.py @@ -538,7 +538,7 @@ def get_segment_attributes(segment): "shot_name": segment.shot_name.get_value(), "segment_name": segment.name.get_value(), "segment_comment": segment.comment.get_value(), - "tape_name": segment.tape_name.get_value(), + "tape_name": segment.tape_name, "source_name": segment.source_name.get_value(), "fpath": segment.file_path.get_value(), "PySegment": segment, From 4cfd58af7ff7a954f0991050ac6a31ba6ce46c90 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Mon, 28 Oct 2024 14:17:42 +0100 Subject: [PATCH 04/22] reverting changes --- client/ayon_flame/api/lib.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/ayon_flame/api/lib.py b/client/ayon_flame/api/lib.py index c48dced..d14d9ea 100644 --- a/client/ayon_flame/api/lib.py +++ b/client/ayon_flame/api/lib.py @@ -539,8 +539,8 @@ def get_segment_attributes(segment): "segment_name": segment.name.get_value(), "segment_comment": segment.comment.get_value(), "tape_name": segment.tape_name, - "source_name": segment.source_name.get_value(), - "fpath": segment.file_path.get_value(), + "source_name": segment.source_name, + "fpath": segment.file_path, "PySegment": segment, } From 674d3dce19a8df24dac54f89d1fe980d531be1fd Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Mon, 28 Oct 2024 14:27:27 +0100 Subject: [PATCH 05/22] Update logger instantiation and usage in CreateShotClip class - Updated logger instantiation to use Logger.get_logger(__name__) - Replaced self.log with log for consistency and clarity --- client/ayon_flame/plugins/create/create_shot_clip.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/client/ayon_flame/plugins/create/create_shot_clip.py b/client/ayon_flame/plugins/create/create_shot_clip.py index cb65ea5..83c77a1 100644 --- a/client/ayon_flame/plugins/create/create_shot_clip.py +++ b/client/ayon_flame/plugins/create/create_shot_clip.py @@ -1,6 +1,9 @@ from copy import deepcopy +from ayon_core.lib import Logger import ayon_flame.api as ayfapi +log = Logger.get_logger(__name__) + class CreateShotClip(ayfapi.Creator): """Publishable clip""" @@ -59,10 +62,10 @@ def process(self): sorted_selected_segments.extend(unsorted_selected_segments) kwargs = { - "log": self.log, + "log": log, "ui_inputs": results_back, "basicProductData": self.data, - "productType": self.data["productType"] + "productType": self.data["productType"], } for i, segment in enumerate(sorted_selected_segments): From 43e5d0637304abcab9c817ed4ad811b4803623b6 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Mon, 28 Oct 2024 14:37:31 +0100 Subject: [PATCH 06/22] Add debug logging for used names list in PublishableClip and set log level to DEBUG in CreateShotClip - Added debug logging statement for used_names_list in PublishableClip class - Changed the logger setup to use Python's built-in logging module with DEBUG level in CreateShotClip class --- client/ayon_flame/api/plugin.py | 4 +++- client/ayon_flame/plugins/create/create_shot_clip.py | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/client/ayon_flame/api/plugin.py b/client/ayon_flame/api/plugin.py index 491bcde..e4222ae 100644 --- a/client/ayon_flame/api/plugin.py +++ b/client/ayon_flame/api/plugin.py @@ -633,7 +633,9 @@ def _convert_to_marker_data(self): data_product_name = hero_data["productName"] used_names_list = self.vertical_clip_used.setdefault( data_product_name, []) - + self.log.debug( + f"used_names_list: {used_names_list}" + ) clip_product_name = self.product_name # add track index in case duplicity of names in hero data # INFO: this is for case where hero clip product name diff --git a/client/ayon_flame/plugins/create/create_shot_clip.py b/client/ayon_flame/plugins/create/create_shot_clip.py index 83c77a1..c035d54 100644 --- a/client/ayon_flame/plugins/create/create_shot_clip.py +++ b/client/ayon_flame/plugins/create/create_shot_clip.py @@ -1,8 +1,10 @@ +import logging from copy import deepcopy -from ayon_core.lib import Logger import ayon_flame.api as ayfapi -log = Logger.get_logger(__name__) +log = logging.getLogger(__name__) +# debug level +log.setLevel(logging.DEBUG) class CreateShotClip(ayfapi.Creator): From 9a5284abd57a0790bc581172c928b43fd08c6b44 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Mon, 28 Oct 2024 14:57:03 +0100 Subject: [PATCH 07/22] Refactor widget creation method and update logger initialization. - Refactored widget creation method parameters order for clarity. - Updated logger initialization to use custom Logger class. --- client/ayon_flame/api/plugin.py | 7 +++++-- client/ayon_flame/plugins/create/create_shot_clip.py | 6 ++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/client/ayon_flame/api/plugin.py b/client/ayon_flame/api/plugin.py index e4222ae..a834fbc 100644 --- a/client/ayon_flame/api/plugin.py +++ b/client/ayon_flame/api/plugin.py @@ -278,8 +278,11 @@ def populate_widgets(self, data, content_layout=None): elif v["type"] == "QSpinBox": data[k]["value"] = self.create_row( content_layout, "QSpinBox", v["label"], - setValue=v["value"], setMinimum=0, - setMaximum=100000, setToolTip=tool_tip) + setMaximum=100000, + setMinimum=0, + setValue=v["value"], + setToolTip=tool_tip, + ) return data diff --git a/client/ayon_flame/plugins/create/create_shot_clip.py b/client/ayon_flame/plugins/create/create_shot_clip.py index c035d54..83c77a1 100644 --- a/client/ayon_flame/plugins/create/create_shot_clip.py +++ b/client/ayon_flame/plugins/create/create_shot_clip.py @@ -1,10 +1,8 @@ -import logging from copy import deepcopy +from ayon_core.lib import Logger import ayon_flame.api as ayfapi -log = logging.getLogger(__name__) -# debug level -log.setLevel(logging.DEBUG) +log = Logger.get_logger(__name__) class CreateShotClip(ayfapi.Creator): From 5bc056afa1213ac03792ed60a727c5200be8cb96 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Mon, 28 Oct 2024 15:15:24 +0100 Subject: [PATCH 08/22] Update debug logs for clip product name and used names list in PublishableClip. --- client/ayon_flame/api/plugin.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/ayon_flame/api/plugin.py b/client/ayon_flame/api/plugin.py index a834fbc..103f0e4 100644 --- a/client/ayon_flame/api/plugin.py +++ b/client/ayon_flame/api/plugin.py @@ -637,9 +637,12 @@ def _convert_to_marker_data(self): used_names_list = self.vertical_clip_used.setdefault( data_product_name, []) self.log.debug( - f"used_names_list: {used_names_list}" + f">> used_names_list: {used_names_list}" ) clip_product_name = self.product_name + self.log.debug( + f">> clip_product_name: {clip_product_name}" + ) # add track index in case duplicity of names in hero data # INFO: this is for case where hero clip product name # is the same as current clip product name From 65dd64d653c39530511abe7441b90d167128c252 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Mon, 28 Oct 2024 15:16:18 +0100 Subject: [PATCH 09/22] Refactor debug log statements in PublishableClip class - Refactored debug log statements for clip_product_name - Updated logging to include track index and clip index when needed --- client/ayon_flame/api/plugin.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/ayon_flame/api/plugin.py b/client/ayon_flame/api/plugin.py index 103f0e4..675a756 100644 --- a/client/ayon_flame/api/plugin.py +++ b/client/ayon_flame/api/plugin.py @@ -641,8 +641,8 @@ def _convert_to_marker_data(self): ) clip_product_name = self.product_name self.log.debug( - f">> clip_product_name: {clip_product_name}" - ) + f">> clip_product_name: {clip_product_name}") + # add track index in case duplicity of names in hero data # INFO: this is for case where hero clip product name # is the same as current clip product name @@ -651,6 +651,8 @@ def _convert_to_marker_data(self): f"{clip_product_name}{self.track_index}") _distrib_data["productName"] = clip_product_name + self.log.debug( + f">> clip_product_name: {clip_product_name}") # in case track clip product name had been already used # then add product name with clip index if clip_product_name in used_names_list: From 16d968ee7b85c4b398ccb7b51cbad714477411c6 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Mon, 28 Oct 2024 15:21:29 +0100 Subject: [PATCH 10/22] Update debug logs for clip and product names in PublishableClip. - Added debug logs for clip_product_name, self.base_product_name, and self.track_name to provide more visibility during processing. --- client/ayon_flame/api/plugin.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client/ayon_flame/api/plugin.py b/client/ayon_flame/api/plugin.py index 675a756..b28b147 100644 --- a/client/ayon_flame/api/plugin.py +++ b/client/ayon_flame/api/plugin.py @@ -661,6 +661,14 @@ def _convert_to_marker_data(self): ) _distrib_data["productName"] = clip_product_name + self.log.debug( + f">> clip_product_name: {clip_product_name}") + + self.log.debug( + f">> self.base_product_name: {self.base_product_name}" + ) + self.log.debug( + f">> self.track_name: {self.track_name}") # in case track name and product name is the same then add if self.base_product_name == self.track_name: _distrib_data["productName"] = self.product_name From 6e0abe569dada755d065afef78f8d7f494658aa1 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Mon, 28 Oct 2024 15:29:04 +0100 Subject: [PATCH 11/22] Refactor clip product name handling logic - Update how clip product names are generated and handled in the code to improve clarity and consistency. --- client/ayon_flame/api/plugin.py | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/client/ayon_flame/api/plugin.py b/client/ayon_flame/api/plugin.py index b28b147..18b9a83 100644 --- a/client/ayon_flame/api/plugin.py +++ b/client/ayon_flame/api/plugin.py @@ -643,36 +643,27 @@ def _convert_to_marker_data(self): self.log.debug( f">> clip_product_name: {clip_product_name}") + # in case track name and product name is the same then add + if self.base_product_name == self.track_name: + clip_product_name = self.product_name + # add track index in case duplicity of names in hero data # INFO: this is for case where hero clip product name # is the same as current clip product name if clip_product_name in data_product_name: clip_product_name = ( f"{clip_product_name}{self.track_index}") - _distrib_data["productName"] = clip_product_name - self.log.debug( - f">> clip_product_name: {clip_product_name}") # in case track clip product name had been already used # then add product name with clip index if clip_product_name in used_names_list: clip_product_name = ( f"{clip_product_name}{self.cs_index}" ) - _distrib_data["productName"] = clip_product_name self.log.debug( f">> clip_product_name: {clip_product_name}") - - self.log.debug( - f">> self.base_product_name: {self.base_product_name}" - ) - self.log.debug( - f">> self.track_name: {self.track_name}") - # in case track name and product name is the same then add - if self.base_product_name == self.track_name: - _distrib_data["productName"] = self.product_name - + _distrib_data["productName"] = clip_product_name # assign data to return hierarchy data to tag tag_hierarchy_data = _distrib_data From 08bcb062e2e232686c36bc6d6573c14a80a4ad75 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Mon, 28 Oct 2024 16:30:11 +0100 Subject: [PATCH 12/22] Refactor regex patterns and handle attribute values more efficiently. - Updated variable names for clarity - Improved handling of attribute values based on type - Enhanced regex pattern usage for better matching --- .../publish/collect_timeline_instances.py | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/client/ayon_flame/plugins/publish/collect_timeline_instances.py b/client/ayon_flame/plugins/publish/collect_timeline_instances.py index 8c33adc..d4aaeda 100644 --- a/client/ayon_flame/plugins/publish/collect_timeline_instances.py +++ b/client/ayon_flame/plugins/publish/collect_timeline_instances.py @@ -13,8 +13,8 @@ from pprint import pformat # constatns -NUM_PATERN = re.compile(r"([0-9\.]+)") -TXT_PATERN = re.compile(r"([a-zA-Z]+)") +NUM_PATTERN = re.compile(r"([0-9\.]+)") +TXT_PATTERN = re.compile(r"([a-zA-Z]+)") class CollectTimelineInstances(pyblish.api.ContextPlugin): @@ -209,11 +209,18 @@ def _get_comment_attributes(self, segment): "pixelRatio": 1.00} } # search for `:` + # INFO: clip based overrides needs to have specific format + # `key: value` separated `,` or `;`. This is for cases where we + # need to override resolution, aspect ratio, etc. per clip. for split in self._split_comments(comment): self.log.debug(f"__ split: {split}") # make sure we ignore if not `:` in key - if ":" not in split: + # of if there is more than one `:` in key + if ( + ":" not in split + or split.count(":") > 1 + ): continue self._get_xml_preset_attrs( @@ -244,36 +251,36 @@ def _get_xml_preset_attrs(self, attributes, split): continue # get pattern defined by type - pattern = TXT_PATERN + pattern = TXT_PATTERN if a_type in ("number", "float"): - pattern = NUM_PATERN + pattern = NUM_PATTERN - res_goup = pattern.findall(value) + res_group = pattern.findall(value) # raise if nothing is found as it is not correctly defined - if not res_goup: + if not res_group: raise ValueError(( "Value for `{}` attribute is not " "set correctly: `{}`").format(a_name, split)) if "string" in a_type: - _value = res_goup[0] + _value = res_group[0] if "float" in a_type: - _value = float(res_goup[0]) + _value = float(res_group[0]) if "number" in a_type: - _value = int(res_goup[0]) + _value = int(res_group[0]) attributes["xml_overrides"][a_name] = _value # condition for resolution in key if "resolution" in key.lower(): - res_goup = NUM_PATERN.findall(value) - # check if axpect was also defined + res_group = NUM_PATTERN.findall(value) + # check if aspect was also defined # 1920x1080x1.5 - aspect = res_goup[2] if len(res_goup) > 2 else 1 + aspect = res_group[2] if len(res_group) > 2 else 1 - width = int(res_goup[0]) - height = int(res_goup[1]) + width = int(res_group[0]) + height = int(res_group[1]) pixel_ratio = float(aspect) attributes["xml_overrides"].update({ "width": width, From b4be87b5f28f0db22cb66423d34d4ce1059b9d7f Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Mon, 28 Oct 2024 16:51:52 +0100 Subject: [PATCH 13/22] Refactor method call in CollectTimelineInstances plugin Simplified a method call by removing unnecessary line breaks. --- .../ayon_flame/plugins/publish/collect_timeline_instances.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client/ayon_flame/plugins/publish/collect_timeline_instances.py b/client/ayon_flame/plugins/publish/collect_timeline_instances.py index d4aaeda..a380d17 100644 --- a/client/ayon_flame/plugins/publish/collect_timeline_instances.py +++ b/client/ayon_flame/plugins/publish/collect_timeline_instances.py @@ -223,8 +223,7 @@ def _get_comment_attributes(self, segment): ): continue - self._get_xml_preset_attrs( - attributes, split) + self._get_xml_preset_attrs(attributes, split) # add xml overrides resolution to instance data xml_overrides = attributes["xml_overrides"] From b21b43962953871adfb6467e128cbf1db80412a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Je=C5=BEek?= Date: Tue, 29 Oct 2024 10:15:11 +0100 Subject: [PATCH 14/22] Update client/ayon_flame/plugins/publish/collect_timeline_instances.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- .../ayon_flame/plugins/publish/collect_timeline_instances.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/client/ayon_flame/plugins/publish/collect_timeline_instances.py b/client/ayon_flame/plugins/publish/collect_timeline_instances.py index a380d17..a871baa 100644 --- a/client/ayon_flame/plugins/publish/collect_timeline_instances.py +++ b/client/ayon_flame/plugins/publish/collect_timeline_instances.py @@ -217,10 +217,7 @@ def _get_comment_attributes(self, segment): # make sure we ignore if not `:` in key # of if there is more than one `:` in key - if ( - ":" not in split - or split.count(":") > 1 - ): + if split.count(":") != 1: continue self._get_xml_preset_attrs(attributes, split) From 269e18511911a59b3f303f325d5961c56f746893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Je=C5=BEek?= Date: Tue, 29 Oct 2024 10:17:19 +0100 Subject: [PATCH 15/22] Update client/ayon_flame/api/plugin.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_flame/api/plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/ayon_flame/api/plugin.py b/client/ayon_flame/api/plugin.py index 18b9a83..08862d6 100644 --- a/client/ayon_flame/api/plugin.py +++ b/client/ayon_flame/api/plugin.py @@ -630,9 +630,9 @@ def _convert_to_marker_data(self): `tag_hierarchy_data` will be set only once for every clip which is not hero clip. """ - _distrib_data = deepcopy(hero_data) - _distrib_data.update({"heroTrack": False}) if _in <= self.clip_in and _out >= self.clip_out: + _distrib_data = deepcopy(hero_data) + _distrib_data["heroTrack"] = False data_product_name = hero_data["productName"] used_names_list = self.vertical_clip_used.setdefault( data_product_name, []) From 6f14faa81562d0d1074476a635b845301ef2ff10 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Tue, 29 Oct 2024 11:03:10 +0100 Subject: [PATCH 16/22] Refactor clip matching logic for vertical sync - Refactored the loop to handle clip frame range comparisons more efficiently. - Improved handling of product names and indices for track clips. --- client/ayon_flame/api/plugin.py | 94 +++++++++++++++++---------------- 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/client/ayon_flame/api/plugin.py b/client/ayon_flame/api/plugin.py index 08862d6..71254d3 100644 --- a/client/ayon_flame/api/plugin.py +++ b/client/ayon_flame/api/plugin.py @@ -621,55 +621,57 @@ def _convert_to_marker_data(self): if not hero_track and self.vertical_sync: # driving layer is set as negative match - for (_in, _out), hero_data in self.vertical_clip_match.items(): - """ - Since only one instance of hero clip is expected in - `self.vertical_clip_match`, this will loop only once - until none hero clip will be matched with hero clip. + for (hero_in, hero_out), hero_data in self.vertical_clip_match.items(): # noqa + """ Iterate over all clips in vertical sync match - `tag_hierarchy_data` will be set only once for every - clip which is not hero clip. + If clip frame range is outside of hero clip frame range + then skip this clip and do not add to hierarchical shared + metadata to them. """ - if _in <= self.clip_in and _out >= self.clip_out: - _distrib_data = deepcopy(hero_data) - _distrib_data["heroTrack"] = False - data_product_name = hero_data["productName"] - used_names_list = self.vertical_clip_used.setdefault( - data_product_name, []) - self.log.debug( - f">> used_names_list: {used_names_list}" - ) + if self.clip_in < hero_in and self.clip_out > hero_out: + continue + + _distrib_data = deepcopy(hero_data) + _distrib_data["heroTrack"] = False + data_product_name = hero_data["productName"] + + # get used names list for duplicity check + used_names_list = self.vertical_clip_used.setdefault( + data_product_name, []) + self.log.debug( + f">> used_names_list: {used_names_list}" + ) + clip_product_name = self.product_name + self.log.debug( + f">> clip_product_name: {clip_product_name}") + + # in case track name and product name is the same then add + if self.base_product_name == self.track_name: clip_product_name = self.product_name - self.log.debug( - f">> clip_product_name: {clip_product_name}") - - # in case track name and product name is the same then add - if self.base_product_name == self.track_name: - clip_product_name = self.product_name - - # add track index in case duplicity of names in hero data - # INFO: this is for case where hero clip product name - # is the same as current clip product name - if clip_product_name in data_product_name: - clip_product_name = ( - f"{clip_product_name}{self.track_index}") - - # in case track clip product name had been already used - # then add product name with clip index - if clip_product_name in used_names_list: - clip_product_name = ( - f"{clip_product_name}{self.cs_index}" - ) - - self.log.debug( - f">> clip_product_name: {clip_product_name}") - _distrib_data["productName"] = clip_product_name - # assign data to return hierarchy data to tag - tag_hierarchy_data = _distrib_data - - # add used product name to used list to avoid duplicity - used_names_list.append(clip_product_name) - break + + # add track index in case duplicity of names in hero data + # INFO: this is for case where hero clip product name + # is the same as current clip product name + if clip_product_name in data_product_name: + clip_product_name = ( + f"{clip_product_name}{self.track_index}") + + # in case track clip product name had been already used + # then add product name with clip index + if clip_product_name in used_names_list: + clip_product_name = ( + f"{clip_product_name}{self.cs_index}" + ) + + self.log.debug( + f">> clip_product_name: {clip_product_name}") + _distrib_data["productName"] = clip_product_name + # assign data to return hierarchy data to tag + tag_hierarchy_data = _distrib_data + + # add used product name to used list to avoid duplicity + used_names_list.append(clip_product_name) + break # add data to return data dict self.marker_data.update(tag_hierarchy_data) From 00a1e8ec4de41a30f49c15739b69e78a24378c93 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Thu, 7 Nov 2024 11:21:48 +0100 Subject: [PATCH 17/22] typo fix --- client/ayon_flame/hooks/pre_flame_setup.py | 2 +- client/ayon_flame/hooks/pre_opentimelineio_install.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/ayon_flame/hooks/pre_flame_setup.py b/client/ayon_flame/hooks/pre_flame_setup.py index bbb7244..5eddd7a 100644 --- a/client/ayon_flame/hooks/pre_flame_setup.py +++ b/client/ayon_flame/hooks/pre_flame_setup.py @@ -44,7 +44,7 @@ def execute(self): self.flame_python_exe = _env["AYON_FLAME_PYTHON_EXEC"] # add it to data for other hooks - self.data["fusion_python_executable"] = self.flame_python_exe + self.data["flame_python_executable"] = self.flame_python_exe self.flame_pythonpath = _env["AYON_FLAME_PYTHONPATH"] diff --git a/client/ayon_flame/hooks/pre_opentimelineio_install.py b/client/ayon_flame/hooks/pre_opentimelineio_install.py index ed292c7..7d6b55d 100644 --- a/client/ayon_flame/hooks/pre_opentimelineio_install.py +++ b/client/ayon_flame/hooks/pre_opentimelineio_install.py @@ -30,7 +30,7 @@ def execute(self): def inner_execute(self): self.log.debug("Check for OpenTimelineIO installation.") - flame_py_exe = self.data.get("fusion_python_executable") + flame_py_exe = self.data.get("flame_python_executable") if not flame_py_exe: self.log.warning("Flame python executable not found.") return From 984f07908ebf13950379ef2b3927656171b53ec4 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Thu, 7 Nov 2024 11:36:19 +0100 Subject: [PATCH 18/22] Refactor code for handling duplicate product names. - Adjusted condition to check for exact match instead of inclusion. --- client/ayon_flame/api/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_flame/api/plugin.py b/client/ayon_flame/api/plugin.py index 71254d3..807f2cd 100644 --- a/client/ayon_flame/api/plugin.py +++ b/client/ayon_flame/api/plugin.py @@ -652,7 +652,7 @@ def _convert_to_marker_data(self): # add track index in case duplicity of names in hero data # INFO: this is for case where hero clip product name # is the same as current clip product name - if clip_product_name in data_product_name: + if clip_product_name == data_product_name: clip_product_name = ( f"{clip_product_name}{self.track_index}") From f56e5ef41ea99b57404de8adb693caaf3da8fbf4 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Thu, 7 Nov 2024 11:50:26 +0100 Subject: [PATCH 19/22] Refactor clip product name handling logic - Refactored how clip product names are generated and validated to avoid duplicates. --- client/ayon_flame/api/plugin.py | 10 +++++++++- .../plugins/publish/collect_timeline_otio.py | 1 - 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/client/ayon_flame/api/plugin.py b/client/ayon_flame/api/plugin.py index 807f2cd..178a027 100644 --- a/client/ayon_flame/api/plugin.py +++ b/client/ayon_flame/api/plugin.py @@ -659,9 +659,17 @@ def _convert_to_marker_data(self): # in case track clip product name had been already used # then add product name with clip index if clip_product_name in used_names_list: - clip_product_name = ( + _clip_product_name = ( f"{clip_product_name}{self.cs_index}" ) + # just in case lets validate if new name is not used + # in case the track_index is the same as clip_index + if _clip_product_name in used_names_list: + _clip_product_name = ( + f"{clip_product_name}" + f"{self.track_index}{self.cs_index}" + ) + clip_product_name = _clip_product_name self.log.debug( f">> clip_product_name: {clip_product_name}") diff --git a/client/ayon_flame/plugins/publish/collect_timeline_otio.py b/client/ayon_flame/plugins/publish/collect_timeline_otio.py index 0ede8cb..4307cd8 100644 --- a/client/ayon_flame/plugins/publish/collect_timeline_otio.py +++ b/client/ayon_flame/plugins/publish/collect_timeline_otio.py @@ -22,7 +22,6 @@ def process(self, context): with ayfapi.maintained_segment_selection(sequence) as selected_seg: otio_timeline = flame_export.create_otio_timeline(sequence) - # update context with main project attributes timeline_data = { "flameProject": project, From 6c060de4746c405ada477555a95c5eb2e329ea6a Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Thu, 7 Nov 2024 15:28:52 +0100 Subject: [PATCH 20/22] Refactor clip uniqueness check logic and key formation. - Adjusted condition for clip inclusion - Added new key formation for clip uniqueness - Updated the list used for duplicity check --- client/ayon_flame/api/plugin.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/client/ayon_flame/api/plugin.py b/client/ayon_flame/api/plugin.py index 178a027..f5223df 100644 --- a/client/ayon_flame/api/plugin.py +++ b/client/ayon_flame/api/plugin.py @@ -628,16 +628,20 @@ def _convert_to_marker_data(self): then skip this clip and do not add to hierarchical shared metadata to them. """ - if self.clip_in < hero_in and self.clip_out > hero_out: + + if self.clip_in < hero_in or self.clip_out > hero_out: continue _distrib_data = deepcopy(hero_data) _distrib_data["heroTrack"] = False + # form used clip unique key data_product_name = hero_data["productName"] + new_clip_name = hero_data["newClipName"] # get used names list for duplicity check used_names_list = self.vertical_clip_used.setdefault( - data_product_name, []) + f"{new_clip_name}{data_product_name}", [] + ) self.log.debug( f">> used_names_list: {used_names_list}" ) From 638d0ae396b0217d78c8628148f683893ddb728d Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Tue, 12 Nov 2024 13:55:29 +0100 Subject: [PATCH 21/22] Remove unused Logger import and update log reference to self.log for consistency. - Removed unused Logger import - Updated log reference to self.log --- client/ayon_flame/plugins/create/create_shot_clip.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/client/ayon_flame/plugins/create/create_shot_clip.py b/client/ayon_flame/plugins/create/create_shot_clip.py index 83c77a1..df558bf 100644 --- a/client/ayon_flame/plugins/create/create_shot_clip.py +++ b/client/ayon_flame/plugins/create/create_shot_clip.py @@ -1,9 +1,6 @@ from copy import deepcopy -from ayon_core.lib import Logger import ayon_flame.api as ayfapi -log = Logger.get_logger(__name__) - class CreateShotClip(ayfapi.Creator): """Publishable clip""" @@ -62,7 +59,7 @@ def process(self): sorted_selected_segments.extend(unsorted_selected_segments) kwargs = { - "log": log, + "log": self.log, "ui_inputs": results_back, "basicProductData": self.data, "productType": self.data["productType"], From 7754b2a1ab7caa52f3ded26428ab2b6869d4193b Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Wed, 13 Nov 2024 14:12:33 +0100 Subject: [PATCH 22/22] Update attributes to use integer or float values where necessary. - Convert width, height, and pixel aspect ratio values to integers or floats as appropriate in multiple files. --- client/ayon_flame/api/lib.py | 8 ++++---- client/ayon_flame/otio/flame_export.py | 2 +- .../plugins/publish/collect_timeline_instances.py | 14 +++++++++++++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/client/ayon_flame/api/lib.py b/client/ayon_flame/api/lib.py index d14d9ea..195cde8 100644 --- a/client/ayon_flame/api/lib.py +++ b/client/ayon_flame/api/lib.py @@ -1154,17 +1154,17 @@ def _get_resolution_info_from_origin(self, xml_data): for out_feed in out_track.iter("feed"): # width out_feed_width_obj = out_feed.find("storageFormat/width") - self.width = self._get_typed_value(out_feed_width_obj) + self.width = int(self._get_typed_value(out_feed_width_obj)) # height out_feed_height_obj = out_feed.find("storageFormat/height") - self.height = self._get_typed_value(out_feed_height_obj) + self.height = int(self._get_typed_value(out_feed_height_obj)) # pixel aspect ratio out_feed_pixel_aspect_obj = out_feed.find( "storageFormat/pixelRatio") - self.pixel_aspect = self._get_typed_value( - out_feed_pixel_aspect_obj) + self.pixel_aspect = float( + self._get_typed_value(out_feed_pixel_aspect_obj)) break except Exception as msg: self.log.warning(msg) diff --git a/client/ayon_flame/otio/flame_export.py b/client/ayon_flame/otio/flame_export.py index 4e874bc..a4bc188 100644 --- a/client/ayon_flame/otio/flame_export.py +++ b/client/ayon_flame/otio/flame_export.py @@ -423,7 +423,7 @@ def _create_otio_timeline(sequence): metadata.update({ "ayon.timeline.width": int(sequence.width), "ayon.timeline.height": int(sequence.height), - "ayon.timeline.pixelAspect": 1 + "ayon.timeline.pixelAspect": float(1) }) rt_start_time = create_otio_rational_time( diff --git a/client/ayon_flame/plugins/publish/collect_timeline_instances.py b/client/ayon_flame/plugins/publish/collect_timeline_instances.py index a871baa..c43531c 100644 --- a/client/ayon_flame/plugins/publish/collect_timeline_instances.py +++ b/client/ayon_flame/plugins/publish/collect_timeline_instances.py @@ -234,6 +234,18 @@ def _get_comment_attributes(self, segment): return attributes def _get_xml_preset_attrs(self, attributes, split): + """Helper function to get xml preset attributes from comments + + Example of comment: + `resolution:1920x1080;pixelRatio:1.5` + + Args: + attributes (dict): attributes dict to update + split (str): string to split + + Returns: + None + """ # split to key and value key, value = split.split(":") @@ -273,7 +285,7 @@ def _get_xml_preset_attrs(self, attributes, split): res_group = NUM_PATTERN.findall(value) # check if aspect was also defined # 1920x1080x1.5 - aspect = res_group[2] if len(res_group) > 2 else 1 + aspect = res_group[2] if len(res_group) > 2 else float(1) width = int(res_group[0]) height = int(res_group[1])