mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
♻️ consolidate warninings
This commit is contained in:
parent
05547c752e
commit
b967f8f818
4 changed files with 17 additions and 50 deletions
|
|
@ -29,7 +29,6 @@ from ayon_core.host import IWorkfileHost, IPublishHost
|
|||
from ayon_core.pipeline import Anatomy
|
||||
from ayon_core.pipeline.template_data import get_template_data
|
||||
from ayon_core.pipeline.plugin_discover import DiscoverResult
|
||||
from ayon_core.pipeline.compatibility import is_product_base_type_supported
|
||||
|
||||
from .exceptions import (
|
||||
CreatorError,
|
||||
|
|
@ -1237,6 +1236,15 @@ class CreateContext:
|
|||
"""
|
||||
creator = self._get_creator_in_create(creator_identifier)
|
||||
|
||||
if not hasattr(creator, "product_base_type"):
|
||||
warn(
|
||||
f"Provided creator {creator!r} doesn't have "
|
||||
"product base type attribute defined. This will be "
|
||||
"required in future.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2
|
||||
)
|
||||
|
||||
project_name = self.project_name
|
||||
if folder_entity is None:
|
||||
folder_path = self.get_current_folder_path()
|
||||
|
|
@ -1290,23 +1298,12 @@ class CreateContext:
|
|||
"folderPath": folder_entity["path"],
|
||||
"task": task_entity["name"] if task_entity else None,
|
||||
"productType": creator.product_type,
|
||||
# Add product base type if supported. Fallback to product type
|
||||
"productBaseType": (
|
||||
creator.product_base_type or creator.product_type),
|
||||
"variant": variant
|
||||
}
|
||||
|
||||
# Add product base type if supported.
|
||||
# TODO (antirotor): Once all creators support product base type
|
||||
# remove this check.
|
||||
if is_product_base_type_supported():
|
||||
|
||||
instance_data["productBaseType"] = creator.product_base_type
|
||||
if creator.product_base_type is None:
|
||||
msg = (
|
||||
f"Creator {creator_identifier} does not set "
|
||||
"product base type. This will be required in future."
|
||||
)
|
||||
warn(msg, DeprecationWarning, stacklevel=2)
|
||||
self.log.warning(msg)
|
||||
|
||||
if active is not None:
|
||||
if not isinstance(active, bool):
|
||||
self.log.warning(
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import copy
|
|||
import os
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||
from warnings import warn
|
||||
|
||||
from ayon_core.lib import Logger, get_version_from_path
|
||||
from ayon_core.pipeline.plugin_discover import (
|
||||
|
|
@ -399,12 +398,6 @@ class BaseCreator(ABC):
|
|||
product_type = self.product_type
|
||||
|
||||
if not product_base_type and not self.product_base_type:
|
||||
warn(
|
||||
f"Creator {self.identifier} does not support "
|
||||
"product base type. This will be required in future.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
product_base_type = product_type
|
||||
|
||||
instance = CreatedInstance(
|
||||
|
|
@ -547,10 +540,6 @@ class BaseCreator(ABC):
|
|||
project_entity (Optional[dict[str, Any]]): Project entity.
|
||||
|
||||
"""
|
||||
product_base_type = None
|
||||
if hasattr(self, "product_base_type"): # noqa: E501
|
||||
product_base_type = self.product_base_type
|
||||
|
||||
if host_name is None:
|
||||
host_name = self.create_context.host_name
|
||||
|
||||
|
|
|
|||
|
|
@ -57,16 +57,7 @@ def get_product_name_template(
|
|||
"task_types": task_type
|
||||
}
|
||||
|
||||
if not product_base_type:
|
||||
warn(
|
||||
"Product base type is not provided, please update your"
|
||||
"creation code to include it. It will be required in "
|
||||
"the future.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2
|
||||
)
|
||||
filtering_criteria["product_base_types"] = product_base_type
|
||||
|
||||
|
||||
matching_profile = filter_profiles(profiles, filtering_criteria)
|
||||
template = None
|
||||
|
|
@ -127,8 +118,8 @@ def get_product_name(
|
|||
|
||||
Args:
|
||||
project_name (str): Project name.
|
||||
task_name (str): Task name.
|
||||
task_type (str): Task type.
|
||||
task_name (Optional[str]): Task name.
|
||||
task_type (Optional[str]): Task type.
|
||||
host_name (str): Host name.
|
||||
product_type (str): Product type.
|
||||
variant (str): In most of the cases it is user input during creation.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ from uuid import uuid4
|
|||
from enum import Enum
|
||||
import typing
|
||||
from typing import Optional, Dict, List, Any
|
||||
from warnings import warn
|
||||
|
||||
from ayon_core.lib.attribute_definitions import (
|
||||
AbstractAttrDef,
|
||||
|
|
@ -521,17 +520,9 @@ class CreatedInstance:
|
|||
product_base_type: Optional[str] = None
|
||||
):
|
||||
"""Initialize CreatedInstance."""
|
||||
if is_product_base_type_supported():
|
||||
if not hasattr(creator, "product_base_type"):
|
||||
warn(
|
||||
f"Provided creator {creator!r} doesn't have "
|
||||
"product base type attribute defined. This will be "
|
||||
"required in future.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2
|
||||
)
|
||||
elif not product_base_type:
|
||||
product_base_type = creator.product_base_type
|
||||
# fallback to product type for backward compatibility
|
||||
if not product_base_type:
|
||||
product_base_type = creator.product_base_type or product_type
|
||||
|
||||
self._creator = creator
|
||||
creator_identifier = creator.identifier
|
||||
|
|
@ -587,7 +578,6 @@ class CreatedInstance:
|
|||
self._data["productName"] = product_name
|
||||
|
||||
if is_product_base_type_supported():
|
||||
data.pop("productBaseType", None)
|
||||
self._data["productBaseType"] = product_base_type
|
||||
|
||||
self._data["active"] = data.get("active", True)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue