Skip to content

Commit

Permalink
Update product type handling and instance attributes
Browse files Browse the repository at this point in the history
- Added checks for product type in clip creation.
- Introduced new methods to define attributes for audio instances.
- Updated logic to handle review options more cleanly.
- Enhanced shared data management by including `shot_clip_index`.
  • Loading branch information
jakubjezek001 committed Nov 20, 2024
1 parent 08f1138 commit 036790d
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 18 deletions.
82 changes: 70 additions & 12 deletions client/ayon_hiero/plugins/create/create_shot_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ def register_callbacks(self):
self.create_context.add_value_changed_callback(self._on_value_change)

def _on_value_change(self, event):
if self.product_type != "plate":
return

for item in event["changes"]:
instance = item["instance"]
if (
Expand Down Expand Up @@ -219,7 +222,7 @@ def get_attr_defs_for_instance(self, instance):
disabled=True,
)
]
if self.product_type in ("plate", "audio"):
if self.product_type == "plate":
# Review track visibility
current_review = instance.creator_attributes.get("review", False)

Expand Down Expand Up @@ -275,6 +278,39 @@ class EditorialAudioInstanceCreator(_HieroInstanceClipCreatorBase):
product_type = "audio"
label = "Editorial Audio"

def get_product_name(
self,
project_name,
folder_entity,
task_entity,
variant,
host_name=None,
instance=None,
project_entity=None):
return f"{self.product_type}Main"

def get_attr_defs_for_instance(self, instance):

instance_attributes = [
TextDef(
"parentInstance",
label="Linked to",
disabled=True,
)
]

instance_attributes.extend(
[
BoolDef(
"review",
label="Review",
tooltip="Switch to reviewable instance",
default=False,
),
]
)
return instance_attributes


class CreateShotClip(plugin.HieroCreator):
"""Publishable clip"""
Expand Down Expand Up @@ -593,6 +629,8 @@ def create(self, subset_name, instance_data, pre_create_data):
for creator_id in enabled_creators:
creator = self.create_context.creators[creator_id]
sub_instance_data = copy.deepcopy(_instance_data)
creator_attributes = sub_instance_data.setdefault(
"creator_attributes", {})
shot_folder_path = sub_instance_data["folderPath"]

# Shot creation
Expand All @@ -613,41 +651,61 @@ def create(self, subset_name, instance_data, pre_create_data):
"handleStart": sub_instance_data["handleStart"],
"handleEnd": sub_instance_data["handleEnd"],
"frameStart": workfileFrameStart,
"frameEnd": (workfileFrameStart + track_item_duration),
"frameEnd": (
workfileFrameStart + track_item_duration),
"clipIn": track_item.timelineIn(),
"clipOut": track_item.timelineOut(),
"clipDuration": track_item_duration,
"sourceIn": track_item.sourceIn(),
"sourceOut": track_item.sourceOut(),
},
"label": (f"{sub_instance_data['folderPath']} shotMain"),
"label": (
f"{sub_instance_data['folderPath']} shotMain"),
}
)

# Plate, Audio
# insert parent instance data to allow
# metadata recollection as publish time.
else:
elif creator_id == plate_creator_id:
parenting_data = shot_instances[shot_creator_id]
sub_instance_data.update({
"parent_instance_id": parenting_data["instance_id"],
"label": (
f"{sub_instance_data['folderPath']} "
f"{sub_instance_data['productName']}"
),
"creator_attributes": {
"parentInstance": parenting_data["label"],
}
)
})

# add reviewable source to plate if shot has it
creator_attributes["parentInstance"] = parenting_data[
"label"]
if sub_instance_data.get("reviewableSource"):
sub_instance_data["creator_attributes"].update({
creator_attributes.update({
"review": True,
"reviewableSource": sub_instance_data[
"reviewableSource"],
"review": True,
})

elif creator_id == audio_creator_id:
sub_instance_data["variant"] = "main"
sub_instance_data["productType"] = "audio"
sub_instance_data["productName"] = "audioMain"

parenting_data = shot_instances[shot_creator_id]
sub_instance_data.update(
{
"parent_instance_id": parenting_data["instance_id"],
"label": (
f"{sub_instance_data['folderPath']} "
f"{sub_instance_data['productName']}"
)
}
)
creator_attributes["parentInstance"] = parenting_data[
"label"]

if sub_instance_data.get("reviewableSource"):
creator_attributes["review"] = True

instance = creator.create(sub_instance_data, None)
instance.transient_data["track_item"] = track_item
self._add_instance_to_context(instance)
Expand Down
11 changes: 7 additions & 4 deletions client/ayon_hiero/plugins/publish/collect_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,22 @@ def process(self, instance):
# Clip index has to be taken form hero shot data
# audio could be shorter but we need to get full length
otio_clip, _ = utils.get_marker_from_clip_index(
otio_timeline, shot_instance_data["clip_index"]
otio_timeline, shot_instance_data["shot_clip_index"]
)
if not otio_clip:
raise PublishError(
f"Could not retrieve otioClip for shot {instance}")

instance.data["otioClip"] = otio_clip

if instance.data.get("reviewTrack") is not None:
# solve reviewable options
review_switch = instance.data["creator_attributes"].get("review")

if review_switch is True:
instance.data["reviewAudio"] = True
instance.data.pop("reviewTrack")
instance.data.pop("review", None)

clip_src = instance.data["otioClip"].source_range
clip_src = otio_clip.source_range
clip_src_in = clip_src.start_time.to_frames()
clip_src_out = clip_src_in + clip_src.duration.to_frames()
instance.data.update({
Expand Down
9 changes: 7 additions & 2 deletions client/ayon_hiero/plugins/publish/collect_shots.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,15 @@ def _inject_editorial_shared_data(cls, instance):
if not context.data.get("editorialSharedData"):
context.data["editorialSharedData"] = {}

context.data["editorialSharedData"][instance_id] = {
edit_shared_data = context.data["editorialSharedData"].setdefault(
instance_id, {}
)
edit_shared_data.update({
key: value for key, value in instance.data.items()
if key in cls.SHARED_KEYS
}
})
# also add `shot_clip_index` to shared data for audio instance
edit_shared_data["shot_clip_index"] = instance.data["clip_index"]

def process(self, instance):
"""
Expand Down

0 comments on commit 036790d

Please sign in to comment.