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

Use task entity attributes instead of folder entity attributes #14

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@


class CollectFrameDataFromAssetEntity(pyblish.api.InstancePlugin):
Copy link
Member

@iLLiCiTiT iLLiCiTiT Sep 11, 2024

Choose a reason for hiding this comment

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

Can we change the plugin name too? (e.g. CollectFrameDataFromEntity )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That'd require also to change the settings around - and hence deal with backwards compatibility there. Any examples that show how that's done?

Copy link
Member

Choose a reason for hiding this comment

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

😞

"""Collect Frame Data From 'folderEntity' found in context.
"""Collect Frame Data From `taskEntity` or `folderEntity` of instance.

Frame range data will only be collected if the keys
are not yet collected for the instance.
Frame range data will only be collected if the keys are not yet
collected for the instance.
"""

order = pyblish.api.CollectorOrder + 0.491
label = "Collect Missing Frame Data From Folder"
label = "Collect Missing Frame Data From Folder/Task"
families = [
"plate",
"pointcache",
Expand Down Expand Up @@ -38,14 +38,20 @@ def process(self, instance):
return

keys_set = []
folder_attributes = instance.data["folderEntity"]["attrib"]

folder_entity = instance.data["folderEntity"]
task_entity = instance.data.get("taskEntity")
context_attributes = (
task_entity["attrib"] if task_entity else folder_entity["attrib"]
)

for key in missing_keys:
if key in folder_attributes:
instance.data[key] = folder_attributes[key]
if key in context_attributes:
instance.data[key] = context_attributes[key]
keys_set.append(key)

if keys_set:
self.log.debug(
f"Frame range data {keys_set} "
"has been collected from folder entity."
"has been collected from folder (or task) entity."
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ class CollectReviewInfo(pyblish.api.InstancePlugin):
hosts = ["traypublisher"]

def process(self, instance):
folder_entity = instance.data.get("folderEntity")
if instance.data.get("frameStart") is not None or not folder_entity:

entity = (
instance.data.get("taskEntity")
or instance.data.get("folderEntity")
)
if instance.data.get("frameStart") is not None or not entity:
self.log.debug("Missing required data on instance")
return

folder_attributes = folder_entity["attrib"]
context_attributes = entity["attrib"]
# Store collected data for logging
collected_data = {}
for key in (
Expand All @@ -35,9 +39,9 @@ def process(self, instance):
"handleStart",
"handleEnd",
):
if key in instance.data or key not in folder_attributes:
if key in instance.data or key not in context_attributes:
continue
value = folder_attributes[key]
value = context_attributes[key]
collected_data[key] = value
instance.data[key] = value
self.log.debug("Collected data: {}".format(str(collected_data)))
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ def process(self, instance):

def get_frame_data_from_repre_sequence(self, instance):
repres = instance.data.get("representations")
folder_attributes = instance.data["folderEntity"]["attrib"]

entity: dict = (
instance.data.get("taskEntity") or instance.data["folderEntity"]
)
entity_attributes: dict = entity["attrib"]

if repres:
first_repre = repres[0]
Expand Down Expand Up @@ -78,5 +82,5 @@ def get_frame_data_from_repre_sequence(self, instance):
"frameEnd": repres_frames[-1],
"handleStart": 0,
"handleEnd": 0,
"fps": folder_attributes["fps"]
"fps": entity_attributes["fps"]
}
16 changes: 10 additions & 6 deletions client/ayon_traypublisher/plugins/publish/validate_frame_ranges.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,15 @@ def process(self, instance):
for pattern in self.skip_timelines_check)):
self.log.info("Skipping for {} task".format(instance.data["task"]))

folder_attributes = instance.data["folderEntity"]["attrib"]
frame_start = folder_attributes["frameStart"]
frame_end = folder_attributes["frameEnd"]
handle_start = folder_attributes["handleStart"]
handle_end = folder_attributes["handleEnd"]
# Use attributes from task entity if set, otherwise from folder entity
entity = (
instance.data.get("taskEntity") or instance.data["folderEntity"]
)
attributes = entity["attrib"]
frame_start = attributes["frameStart"]
frame_end = attributes["frameEnd"]
handle_start = attributes["handleStart"]
handle_end = attributes["handleEnd"]
duration = (frame_end - frame_start + 1) + handle_start + handle_end

repres = instance.data.get("representations")
Expand All @@ -73,7 +77,7 @@ def process(self, instance):

msg = (
"Frame duration from DB:'{}' doesn't match number of files:'{}'"
" Please change frame range for Folder or limit no. of files"
" Please change frame range for folder/task or limit no. of files"
). format(int(duration), frames)

formatting_data = {"duration": duration,
Expand Down