Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing multiple : split issue and others small issues #30

Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4bebdb5
Add debug log for split comments in CollectTimelineInstances.
jakubjezek001 Oct 28, 2024
702f80a
Refactor segment attribute retrieval and track name handling,
jakubjezek001 Oct 28, 2024
99a0194
Update segment attributes retrieval to use direct attribute access.
jakubjezek001 Oct 28, 2024
4cfd58a
reverting changes
jakubjezek001 Oct 28, 2024
674d3dc
Update logger instantiation and usage in CreateShotClip class
jakubjezek001 Oct 28, 2024
43e5d06
Add debug logging for used names list in PublishableClip and set log …
jakubjezek001 Oct 28, 2024
9a5284a
Refactor widget creation method and update logger initialization.
jakubjezek001 Oct 28, 2024
5bc056a
Update debug logs for clip product name and used names list in Publis…
jakubjezek001 Oct 28, 2024
65dd64d
Refactor debug log statements in PublishableClip class
jakubjezek001 Oct 28, 2024
16d968e
Update debug logs for clip and product names in PublishableClip.
jakubjezek001 Oct 28, 2024
6e0abe5
Refactor clip product name handling logic
jakubjezek001 Oct 28, 2024
08bcb06
Refactor regex patterns and handle attribute values more efficiently.
jakubjezek001 Oct 28, 2024
b4be87b
Refactor method call in CollectTimelineInstances plugin
jakubjezek001 Oct 28, 2024
b21b439
Update client/ayon_flame/plugins/publish/collect_timeline_instances.py
jakubjezek001 Oct 29, 2024
269e185
Update client/ayon_flame/api/plugin.py
jakubjezek001 Oct 29, 2024
6f14faa
Refactor clip matching logic for vertical sync
jakubjezek001 Oct 29, 2024
00a1e8e
typo fix
jakubjezek001 Nov 7, 2024
984f079
Refactor code for handling duplicate product names.
jakubjezek001 Nov 7, 2024
f56e5ef
Refactor clip product name handling logic
jakubjezek001 Nov 7, 2024
6c060de
Refactor clip uniqueness check logic and key formation.
jakubjezek001 Nov 7, 2024
275fed8
Merge branch 'develop' into bugfix/AY-6259_14_flame-vertical-alignmen…
jakubjezek001 Nov 12, 2024
638d0ae
Remove unused Logger import and update log reference to self.log for …
jakubjezek001 Nov 12, 2024
7754b2a
Update attributes to use integer or float values where necessary.
jakubjezek001 Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/ayon_flame/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ def get_segment_attributes(segment):
"tape_name": segment.tape_name,
"source_name": segment.source_name,
"fpath": segment.file_path,
"PySegment": segment
"PySegment": segment,
}

# head and tail with forward compatibility
Expand Down
97 changes: 67 additions & 30 deletions client/ayon_flame/api/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -277,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


Expand Down Expand Up @@ -337,6 +341,7 @@ class PublishableClip:
flame.PySegment: flame api object
"""
vertical_clip_match = {}
vertical_clip_used = {}
marker_data = {}
types = {
"shot": "shot",
Expand Down Expand Up @@ -377,6 +382,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"])
Expand All @@ -385,8 +392,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"])
Expand All @@ -397,9 +409,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()

Expand Down Expand Up @@ -479,8 +489,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(
Expand Down Expand Up @@ -612,29 +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.
"""
_hero_data = deepcopy(hero_data)
_hero_data.update({"heroTrack": False})
if _in <= self.clip_in and _out >= self.clip_out:
data_product_name = hero_data["productName"]
# 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)
# 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
# assign data to return hierarchy data to tag
tag_hierarchy_data = _hero_data
break
if self.clip_in < hero_in and self.clip_out > hero_out:
jakubjezek001 marked this conversation as resolved.
Show resolved Hide resolved
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

# 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)
Expand Down
7 changes: 5 additions & 2 deletions client/ayon_flame/plugins/create/create_shot_clip.py
Original file line number Diff line number Diff line change
@@ -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__)
jakubjezek001 marked this conversation as resolved.
Show resolved Hide resolved


class CreateShotClip(ayfapi.Creator):
"""Publishable clip"""
Expand Down Expand Up @@ -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):
Expand Down
39 changes: 22 additions & 17 deletions client/ayon_flame/plugins/publish/collect_timeline_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]+)")
Comment on lines +16 to +17
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these changes are related to typo fixing.



class CollectTimelineInstances(pyblish.api.ContextPlugin):
Expand Down Expand Up @@ -209,13 +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 split.count(":") != 1:
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"]
Expand All @@ -242,36 +247,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,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these changes are related to typo fixing.

Expand Down