-
Notifications
You must be signed in to change notification settings - Fork 0
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
Convert Flame creators to new publisher #33
base: develop
Are you sure you want to change the base?
Conversation
005ed37
to
86f3c66
Compare
|
||
attr_defs = instance.creator_attributes.attr_defs | ||
|
||
if "review" not in changes: | ||
continue | ||
|
||
review_value = changes["review"] | ||
reviewable_source = next( | ||
attr_def | ||
for attr_def in attr_defs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attr_defs = instance.creator_attributes.attr_defs | |
if "review" not in changes: | |
continue | |
review_value = changes["review"] | |
reviewable_source = next( | |
attr_def | |
for attr_def in attr_defs | |
if "review" not in changes: | |
continue | |
attr_defs = instance.creator_attributes.attr_defs | |
review_value = changes["review"] | |
reviewable_source = next( | |
attr_def | |
for attr_def in attr_defs |
label="Review Track", | ||
tooltip=("Selecting source from review tracks."), | ||
items=gui_tracks, | ||
disabled=not current_review, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
disabled=not current_review, | |
enabled=current_review, |
for attr_def in attr_defs | ||
if attr_def.key == "reviewTrack" | ||
) | ||
reviewable_source.disabled = not review_value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewable_source.disabled = not review_value | |
reviewable_source.enabled = review_value |
def create(self, subset_name, instance_data, pre_create_data): | ||
super(CreateShotClip, self).create(subset_name, | ||
instance_data, | ||
pre_create_data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def create(self, subset_name, instance_data, pre_create_data): | |
super(CreateShotClip, self).create(subset_name, | |
instance_data, | |
pre_create_data) | |
def create(self, product_name, instance_data, pre_create_data): | |
super().create( | |
product_name, | |
instance_data, | |
pre_create_data) |
audio_clips = [] | ||
for audio_track in self.sequence.audio_tracks: | ||
audio_clips.append(audio_track.segments) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
audio_clips = [] | |
for audio_track in self.sequence.audio_tracks: | |
audio_clips.append(audio_track.segments) | |
audio_clips = [ | |
audio_track.segments | |
for audio_track in self.sequence.audio_tracks | |
] |
sorted_selected_segments = list() | ||
unsorted_selected_segments = list() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already defined below
sorted_selected_segments = list() | |
unsorted_selected_segments = list() |
for idx, segment in enumerate(sorted_selected_segments): | ||
|
||
clip_index = str(uuid.uuid4()) | ||
segment_instance_data = instance_data.copy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.copy()
on dictionary is the same as dict(instance_data)
which does not create copy of value objects (e.g. lists or nested dictionaries)
segment_instance_data = instance_data.copy() | |
segment_instance_data = copy.deepcopy(instance_data) |
prev_instances = [ | ||
inst for inst_id, inst | ||
in self.create_context.instances_by_id.items() | ||
if inst_id == inst_data["instance_id"] | ||
] | ||
creator.remove_instances(prev_instances) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prev_instances = [ | |
inst for inst_id, inst | |
in self.create_context.instances_by_id.items() | |
if inst_id == inst_data["instance_id"] | |
] | |
creator.remove_instances(prev_instances) | |
prev_instance = self.create_context.instances_by_id.get( | |
inst_data["instance_id"] | |
) | |
if prev_instance is not None: | |
creator.remove_instances([prev_instance]) |
"label": ( | ||
f"{shot_folder_path} shot" | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"label": ( | |
f"{shot_folder_path} shot" | |
), | |
"label": f"{shot_folder_path} shot", |
if instance_data["audio"]: | ||
sub_creators = ( | ||
"io.ayon.creators.flame.plate", | ||
"io.ayon.creators.flame.audio" | ||
) | ||
else: | ||
sub_creators = ("io.ayon.creators.flame.plate",) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if instance_data["audio"]: | |
sub_creators = ( | |
"io.ayon.creators.flame.plate", | |
"io.ayon.creators.flame.audio" | |
) | |
else: | |
sub_creators = ("io.ayon.creators.flame.plate",) | |
sub_creators = ["io.ayon.creators.flame.plate"] | |
if instance_data["audio"]: | |
sub_creators.append( | |
"io.ayon.creators.flame.audio" | |
) |
sub_creators = ("io.ayon.creators.flame.plate",) | ||
|
||
for sub_creator_id in sub_creators: | ||
sub_instance_data = instance_data.copy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sub_instance_data = instance_data.copy() | |
sub_instance_data = copy.deepcopy(instance_data) |
if _CONTENT_ID in marker_data: | ||
for creator_id, data in marker_data[_CONTENT_ID].items(): | ||
self._create_and_add_instance( | ||
data, creator_id, segment, instances) | ||
|
||
else: | ||
instances.extend(self._collect_legacy_instance(segment, marker_data)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if _CONTENT_ID in marker_data: | |
for creator_id, data in marker_data[_CONTENT_ID].items(): | |
self._create_and_add_instance( | |
data, creator_id, segment, instances) | |
else: | |
instances.extend(self._collect_legacy_instance(segment, marker_data)) | |
# Legacy instances handling | |
if _CONTENT_ID not in marker_data: | |
instances.extend( | |
self._collect_legacy_instance(segment, marker_data) | |
) | |
continue | |
for creator_id, data in marker_data[_CONTENT_ID].items(): | |
self._create_and_add_instance( | |
data, creator_id, segment, instances) |
default_variant = "Main" | ||
|
||
def collect_instances(self): | ||
@staticmethod | ||
def _get_project_workfile_filepath(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be function somehwere in ayon_flame.api
? (I have no context so maybe not)
|
||
if instance.data.get("reviewTrack") is not None: | ||
instance.data["reviewAudio"] = True | ||
instance.data.pop("reviewTrack") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instance.data.pop("reviewTrack") | |
# Remove review track to avoid creation of reviewable | |
# for the instance | |
instance.data.pop("reviewTrack") |
break | ||
|
||
else: | ||
raise ValueError("Could not retrieve source from selected segments.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this something that is "artist" error or "code" error? If it is something that artist should know about then use PublishError
(from ayon_core.pipeline import PublishError
). It will show the error message to user, otherwise he'll see "This is not your fault".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW for code readability I would use this, technically the same, but easier to read intention (not pushing tho).
segment_item = None
for item in instance.context.data["flameSelectedSegments"]:
item_data = ayfapi.get_segment_data_marker(item) or {}
if item_data.get("clip_index") == instance.data["clip_index"]:
segment_item = item
break
if segment_item is None:
raise PublishError("Could not retrieve source from selected segments.")
# make sure there is not NoneType rather 0 | ||
if head is None: | ||
head = 0 | ||
if tail is None: | ||
tail = 0 | ||
|
||
# make sure value is absolute | ||
if head != 0: | ||
head = abs(head) | ||
if tail != 0: | ||
tail = abs(tail) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# make sure there is not NoneType rather 0 | |
if head is None: | |
head = 0 | |
if tail is None: | |
tail = 0 | |
# make sure value is absolute | |
if head != 0: | |
head = abs(head) | |
if tail != 0: | |
tail = abs(tail) | |
# Make sure there is not None and negative number | |
head = abs(head or 0) | |
tail = abs(tail or 0) | |
# make sure value is absolute | |
if head != 0: | |
head = abs(head) | |
if tail != 0: | |
tail = abs(tail) |
# make sure there is not NoneType rather 0 | ||
if head is None: | ||
head = 0 | ||
if tail is None: | ||
tail = 0 | ||
|
||
# make sure value is absolute | ||
if head != 0: | ||
head = abs(head) | ||
if tail != 0: | ||
tail = abs(tail) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# make sure there is not NoneType rather 0 | |
if head is None: | |
head = 0 | |
if tail is None: | |
tail = 0 | |
# make sure value is absolute | |
if head != 0: | |
head = abs(head) | |
if tail != 0: | |
tail = abs(tail) | |
# Make sure there is not None and negative number | |
head = abs(head or 0) | |
tail = abs(tail or 0) |
BTW did you really wanted to use abs
? Should that be clamped to 0 instead?
# make sure there is not NoneType rather 0 | |
if head is None: | |
head = 0 | |
if tail is None: | |
tail = 0 | |
# make sure value is absolute | |
if head != 0: | |
head = abs(head) | |
if tail != 0: | |
tail = abs(tail) | |
# Make sure there is not None and clamp to 0 | |
if head is None or head < 0: | |
head = 0 | |
if tail is None or head < 0: | |
tail = 0 |
split_comments = [] | ||
if "," in comment_string: | ||
split_comments.extend(comment_string.split(",")) | ||
elif ";" in comment_string: | ||
split_comments.extend(comment_string.split(";")) | ||
else: | ||
split_comments.append(comment_string) | ||
|
||
return split_comments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requires import re
.
split_comments = [] | |
if "," in comment_string: | |
split_comments.extend(comment_string.split(",")) | |
elif ";" in comment_string: | |
split_comments.extend(comment_string.split(";")) | |
else: | |
split_comments.append(comment_string) | |
return split_comments | |
return re.split(r",|;", comment_string) |
Or to be more obvious
split_comments = [] | |
if "," in comment_string: | |
split_comments.extend(comment_string.split(",")) | |
elif ";" in comment_string: | |
split_comments.extend(comment_string.split(";")) | |
else: | |
split_comments.append(comment_string) | |
return split_comments | |
pattern = "|".join([",", ";"]) | |
return re.split(pattern, comment_string) |
class CollectShot(pyblish.api.InstancePlugin): | ||
"""Collect new shots.""" | ||
|
||
order = order = pyblish.api.CollectorOrder - 0.095 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
order = order = pyblish.api.CollectorOrder - 0.095 | |
order = pyblish.api.CollectorOrder - 0.095 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to run this plugin much earlier? e.g. pyblish.api.CollectorOrder - 0.49
? If not please describe why not. Does not happen in this PR, but let me know I'll create issue for it if we can't do it now, thanks.
Changelog Description
resolve #10
Make flame creators use the Creator API and new widget. Publishable products are now listed as individual instances following a similar logic than Hiero and Resolve.
Done:
colorspace
data following Update metadata keys and add colorspace data ayon-hiero#23Testing notes:
In Flame:
Tested locally on Flame 2024.2