mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
Merge pull request #1315 from ynput/enhancement/1296-product-base-types-support-in-integrator
🏛️Product base types: Support in the integrator
This commit is contained in:
commit
c7e9789582
3 changed files with 52 additions and 11 deletions
|
|
@ -1,4 +1,5 @@
|
|||
"""Package to handle compatibility checks for pipeline components."""
|
||||
import ayon_api
|
||||
|
||||
|
||||
def is_product_base_type_supported() -> bool:
|
||||
|
|
@ -13,4 +14,7 @@ def is_product_base_type_supported() -> bool:
|
|||
bool: True if product base types are supported, False otherwise.
|
||||
|
||||
"""
|
||||
return False
|
||||
|
||||
if not hasattr(ayon_api, "is_product_base_type_supported"):
|
||||
return False
|
||||
return ayon_api.is_product_base_type_supported()
|
||||
|
|
|
|||
|
|
@ -122,7 +122,8 @@ def get_publish_template_name(
|
|||
task_type,
|
||||
project_settings=None,
|
||||
hero=False,
|
||||
logger=None
|
||||
product_base_type: Optional[str] = None,
|
||||
logger=None,
|
||||
):
|
||||
"""Get template name which should be used for passed context.
|
||||
|
||||
|
|
@ -140,17 +141,29 @@ def get_publish_template_name(
|
|||
task_type (str): Task type on which is instance working.
|
||||
project_settings (Dict[str, Any]): Prepared project settings.
|
||||
hero (bool): Template is for hero version publishing.
|
||||
product_base_type (Optional[str]): Product type for which should
|
||||
be found template.
|
||||
logger (logging.Logger): Custom logger used for 'filter_profiles'
|
||||
function.
|
||||
|
||||
Returns:
|
||||
str: Template name which should be used for integration.
|
||||
"""
|
||||
if not product_base_type:
|
||||
msg = (
|
||||
"Argument 'product_base_type' is not provided to"
|
||||
" 'get_publish_template_name' function. This argument"
|
||||
" will be required in future versions."
|
||||
)
|
||||
warnings.warn(msg, DeprecationWarning)
|
||||
if logger:
|
||||
logger.warning(msg)
|
||||
|
||||
template = None
|
||||
filter_criteria = {
|
||||
"hosts": host_name,
|
||||
"product_types": product_type,
|
||||
"product_base_types": product_base_type,
|
||||
"task_names": task_name,
|
||||
"task_types": task_type,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ from ayon_core.pipeline.publish import (
|
|||
KnownPublishError,
|
||||
get_publish_template_name,
|
||||
)
|
||||
from pipeline import is_product_base_type_supported
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -367,6 +368,8 @@ class IntegrateAsset(pyblish.api.InstancePlugin):
|
|||
folder_entity = instance.data["folderEntity"]
|
||||
product_name = instance.data["productName"]
|
||||
product_type = instance.data["productType"]
|
||||
product_base_type = instance.data.get("productBaseType")
|
||||
|
||||
self.log.debug("Product: {}".format(product_name))
|
||||
|
||||
# Get existing product if it exists
|
||||
|
|
@ -394,14 +397,33 @@ class IntegrateAsset(pyblish.api.InstancePlugin):
|
|||
product_id = None
|
||||
if existing_product_entity:
|
||||
product_id = existing_product_entity["id"]
|
||||
product_entity = new_product_entity(
|
||||
product_name,
|
||||
product_type,
|
||||
folder_entity["id"],
|
||||
data=data,
|
||||
attribs=attributes,
|
||||
entity_id=product_id
|
||||
)
|
||||
|
||||
new_product_entity_kwargs = {
|
||||
"product_name": product_name,
|
||||
"product_type": product_type,
|
||||
"folder_id": folder_entity["id"],
|
||||
"data": data,
|
||||
"attribs": attributes,
|
||||
"entity_id": product_id,
|
||||
"product_base_type": product_base_type,
|
||||
}
|
||||
|
||||
if not is_product_base_type_supported():
|
||||
new_product_entity_kwargs.pop("product_base_type")
|
||||
if (
|
||||
product_base_type is not None
|
||||
and product_base_type != product_type):
|
||||
self.log.warning((
|
||||
"Product base type %s is not supported by the server, "
|
||||
"but it's defined - and it differs from product type %s. "
|
||||
"Using product base type as product type."
|
||||
), product_base_type, product_type)
|
||||
|
||||
new_product_entity_kwargs["product_type"] = (
|
||||
product_base_type
|
||||
)
|
||||
|
||||
product_entity = new_product_entity(**new_product_entity_kwargs)
|
||||
|
||||
if existing_product_entity is None:
|
||||
# Create a new product
|
||||
|
|
@ -927,6 +949,7 @@ class IntegrateAsset(pyblish.api.InstancePlugin):
|
|||
host_name = context.data["hostName"]
|
||||
anatomy_data = instance.data["anatomyData"]
|
||||
product_type = instance.data["productType"]
|
||||
product_base_type = instance.data.get("productBaseType")
|
||||
task_info = anatomy_data.get("task") or {}
|
||||
|
||||
return get_publish_template_name(
|
||||
|
|
@ -936,7 +959,8 @@ class IntegrateAsset(pyblish.api.InstancePlugin):
|
|||
task_name=task_info.get("name"),
|
||||
task_type=task_info.get("type"),
|
||||
project_settings=context.data["project_settings"],
|
||||
logger=self.log
|
||||
logger=self.log,
|
||||
product_base_type=product_base_type
|
||||
)
|
||||
|
||||
def get_rootless_path(self, anatomy, path):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue