Skip to content

Commit

Permalink
Merge pull request #113 from ynput/enhancement/OP-8264_Use-productNam…
Browse files Browse the repository at this point in the history
…e-n-productType

Chore: Product name and type
  • Loading branch information
iLLiCiTiT authored Feb 28, 2024
2 parents e567c2d + d85b4ee commit 2a0f68a
Show file tree
Hide file tree
Showing 419 changed files with 4,356 additions and 4,558 deletions.
76 changes: 43 additions & 33 deletions client/ayon_core/hosts/aftereffects/plugins/create/create_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from ayon_core.hosts.aftereffects.api.pipeline import cache_and_get_instances
from ayon_core.hosts.aftereffects.api.lib import set_settings
from ayon_core.lib import prepare_template_data
from ayon_core.pipeline.create import SUBSET_NAME_ALLOWED_SYMBOLS
from ayon_core.pipeline.create import PRODUCT_NAME_ALLOWED_SYMBOLS


class RenderCreator(Creator):
Expand All @@ -22,7 +22,7 @@ class RenderCreator(Creator):
"""
identifier = "render"
label = "Render"
family = "render"
product_type = "render"
description = "Render creator"

create_allow_context_change = True
Expand All @@ -31,7 +31,7 @@ class RenderCreator(Creator):
mark_for_review = True
force_setting_values = True

def create(self, subset_name_from_ui, data, pre_create_data):
def create(self, product_name, data, pre_create_data):
stub = api.get_stub() # only after After Effects is up

try:
Expand All @@ -58,33 +58,37 @@ def create(self, subset_name_from_ui, data, pre_create_data):
len(comps) > 1)
for comp in comps:
composition_name = re.sub(
"[^{}]+".format(SUBSET_NAME_ALLOWED_SYMBOLS),
"[^{}]+".format(PRODUCT_NAME_ALLOWED_SYMBOLS),
"",
comp.name
)
if use_composition_name:
if "{composition}" not in subset_name_from_ui.lower():
subset_name_from_ui += "{Composition}"
if "{composition}" not in product_name.lower():
product_name += "{Composition}"

dynamic_fill = prepare_template_data({"composition":
composition_name})
subset_name = subset_name_from_ui.format(**dynamic_fill)
comp_product_name = product_name.format(**dynamic_fill)
data["composition_name"] = composition_name
else:
subset_name = subset_name_from_ui
subset_name = re.sub(r"\{composition\}", '', subset_name,
flags=re.IGNORECASE)
comp_product_name = re.sub(
r"\{composition\}",
"",
product_name,
flags=re.IGNORECASE
)

for inst in self.create_context.instances:
if subset_name == inst.subset_name:
if comp_product_name == inst.product_name:
raise CreatorError("{} already exists".format(
inst.subset_name))
inst.product_name))

data["members"] = [comp.id]
data["orig_comp_name"] = composition_name

new_instance = CreatedInstance(self.family, subset_name, data,
self)
new_instance = CreatedInstance(
self.product_type, comp_product_name, data, self
)
if "farm" in pre_create_data:
use_farm = pre_create_data["farm"]
new_instance.creator_attributes["farm"] = use_farm
Expand All @@ -96,7 +100,7 @@ def create(self, subset_name_from_ui, data, pre_create_data):
new_instance.data_to_store())
self._add_instance_to_context(new_instance)

stub.rename_item(comp.id, subset_name)
stub.rename_item(comp.id, comp_product_name)
if self.force_setting_values:
set_settings(True, True, [comp.id], print_msg=False)

Expand All @@ -107,7 +111,7 @@ def get_pre_create_attr_defs(self):
"selected by default.",
default=True, label="Use selection"),
BoolDef("use_composition_name",
label="Use composition name in subset"),
label="Use composition name in product"),
UISeparatorDef(),
BoolDef("farm", label="Render on farm"),
BoolDef(
Expand All @@ -133,9 +137,14 @@ def get_icon(self):

def collect_instances(self):
for instance_data in cache_and_get_instances(self):
# legacy instances have family=='render' or 'renderLocal', use them
creator_id = (instance_data.get("creator_identifier") or
instance_data.get("family", '').replace("Local", ''))
# legacy instances have product_type=='render' or 'renderLocal', use them
creator_id = instance_data.get("creator_identifier")
if not creator_id:
# NOTE this is for backwards compatibility but probably can be
# removed
creator_id = instance_data.get("family", "")
creator_id = creator_id.replace("Local", "")

if creator_id == self.identifier:
instance_data = self._handle_legacy(instance_data)
instance = CreatedInstance.from_existing(
Expand All @@ -147,10 +156,10 @@ def update_instances(self, update_list):
for created_inst, _changes in update_list:
api.get_stub().imprint(created_inst.get("instance_id"),
created_inst.data_to_store())
subset_change = _changes.get("subset")
if subset_change:
name_change = _changes.get("productName")
if name_change:
api.get_stub().rename_item(created_inst.data["members"][0],
subset_change.new_value)
name_change.new_value)

def remove_instances(self, instances):
"""Removes metadata and renames to original comp name if available."""
Expand Down Expand Up @@ -183,15 +192,15 @@ def apply_settings(self, project_settings):
def get_detail_description(self):
return """Creator for Render instances
Main publishable item in AfterEffects will be of `render` family.
Main publishable item in AfterEffects will be of `render` product type.
Result of this item (instance) is picture sequence or video that could
be a final delivery product or loaded and used in another DCCs.
Select single composition and create instance of 'render' family or
turn off 'Use selection' to create instance for all compositions.
Select single composition and create instance of 'render' product type
or turn off 'Use selection' to create instance for all compositions.
'Use composition name in subset' allows to explicitly add composition
name into created subset name.
'Use composition name in product' allows to explicitly add composition
name into created product name.
Position of composition name could be set in
`project_settings/global/tools/creator/product_name_profiles` with
Expand All @@ -201,15 +210,16 @@ def get_detail_description(self):
be handled at same time.
If {composition} placeholder is not us 'product_name_profiles'
composition name will be capitalized and set at the end of subset name
if necessary.
composition name will be capitalized and set at the end of
product name if necessary.
If composition name should be used, it will be cleaned up of characters
that would cause an issue in published file names.
"""

def get_dynamic_data(self, variant, task_name, asset_doc,
project_name, host_name, instance):
def get_dynamic_data(
self, project_name, asset_doc, task_name, variant, host_name, instance
):
dynamic_data = {}
if instance is not None:
composition_name = instance.get("composition_name")
Expand All @@ -234,9 +244,9 @@ def _handle_legacy(self, instance_data):
instance_data["task"] = self.create_context.get_current_task_name()

if not instance_data.get("creator_attributes"):
is_old_farm = instance_data["family"] != "renderLocal"
is_old_farm = instance_data.get("family") != "renderLocal"
instance_data["creator_attributes"] = {"farm": is_old_farm}
instance_data["family"] = self.family
instance_data["productType"] = self.product_type

if instance_data["creator_attributes"].get("mark_for_review") is None:
instance_data["creator_attributes"]["mark_for_review"] = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class AEWorkfileCreator(AutoCreator):
identifier = "workfile"
family = "workfile"
product_type = "workfile"

default_variant = "Main"

Expand All @@ -20,9 +20,9 @@ def collect_instances(self):
for instance_data in cache_and_get_instances(self):
creator_id = instance_data.get("creator_identifier")
if creator_id == self.identifier:
subset_name = instance_data["subset"]
product_name = instance_data["productName"]
instance = CreatedInstance(
self.family, subset_name, instance_data, self
self.product_type, product_name, instance_data, self
)
self._add_instance_to_context(instance)

Expand All @@ -33,7 +33,7 @@ def update_instances(self, update_list):
def create(self, options=None):
existing_instance = None
for instance in self.create_context.instances:
if instance.family == self.family:
if instance.product_type == self.product_type:
existing_instance = instance
break

Expand All @@ -49,22 +49,29 @@ def create(self, options=None):

if existing_instance is None:
asset_doc = get_asset_by_name(project_name, asset_name)
subset_name = self.get_subset_name(
self.default_variant, task_name, asset_doc,
project_name, host_name
product_name = self.get_product_name(
project_name,
asset_doc,
task_name,
self.default_variant,
host_name,
)
data = {
"folderPath": asset_name,
"task": task_name,
"variant": self.default_variant,
}
data.update(self.get_dynamic_data(
self.default_variant, task_name, asset_doc,
project_name, host_name, None
project_name,
asset_doc,
task_name,
self.default_variant,
host_name,
None,
))

new_instance = CreatedInstance(
self.family, subset_name, data, self
self.product_type, product_name, data, self
)
self._add_instance_to_context(new_instance)

Expand All @@ -76,10 +83,13 @@ def create(self, options=None):
or existing_instance["task"] != task_name
):
asset_doc = get_asset_by_name(project_name, asset_name)
subset_name = self.get_subset_name(
self.default_variant, task_name, asset_doc,
project_name, host_name
product_name = self.get_product_name(
project_name,
asset_doc,
task_name,
self.default_variant,
host_name,
)
existing_instance["folderPath"] = asset_name
existing_instance["task"] = task_name
existing_instance["subset"] = subset_name
existing_instance["productName"] = product_name
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class BackgroundLoader(api.AfterEffectsLoader):
"""
Load images from Background family
Load images from Background product type
Creates for each background separate folder with all imported images
from background json AND automatically created composition with layers,
each layer for separate image.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def get_instances(self, context):
if not inst.data.get("active", True):
continue

family = inst.data["family"]
if family not in ["render", "renderLocal"]: # legacy
product_type = inst.data["productType"]
if product_type not in ["render", "renderLocal"]: # legacy
continue

comp_id = int(inst.data["members"][0])
Expand All @@ -81,29 +81,32 @@ def get_instances(self, context):
fps = comp_info.frameRate
# TODO add resolution when supported by extension

task_name = inst.data.get("task") # legacy
task_name = inst.data.get("task")

render_q = CollectAERender.get_stub().get_render_info(comp_id)
if not render_q:
raise ValueError("No file extension set in Render Queue")
render_item = render_q[0]

product_type = "render"
instance_families = inst.data.get("families", [])
subset_name = inst.data["subset"]
instance_families.append(product_type)
product_name = inst.data["productName"]
instance = AERenderInstance(
family="render",
productType=product_type,
family=product_type,
families=instance_families,
version=version,
time="",
source=current_file,
label="{} - {}".format(subset_name, family),
subset=subset_name,
label="{} - {}".format(product_name, product_type),
productName=product_name,
folderPath=inst.data["folderPath"],
task=task_name,
attachTo=False,
setMembers='',
publish=True,
name=subset_name,
name=product_name,
resolutionWidth=render_item.width,
resolutionHeight=render_item.height,
pixelAspect=1,
Expand Down Expand Up @@ -176,7 +179,7 @@ def get_expected_files(self, render_instance):
if "#" not in file_name: # single frame (mov)W
path = os.path.join(base_dir, "{}_{}_{}.{}".format(
render_instance.folderPath,
render_instance.subset,
render_instance.productName,
version_str,
ext
))
Expand All @@ -185,7 +188,7 @@ def get_expected_files(self, render_instance):
for frame in range(start, end + 1):
path = os.path.join(base_dir, "{}_{}_{}.{}.{}".format(
render_instance.folderPath,
render_instance.subset,
render_instance.productName,
version_str,
str(frame).zfill(self.padding_width),
ext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
None
Provides:
instance -> family ("review")
instance -> families ("review")
"""
import pyblish.api

Expand Down
Loading

0 comments on commit 2a0f68a

Please sign in to comment.