Merge branch 'develop' into bugfixes/AY-6975_retimes_consolidations

This commit is contained in:
robin@ynput.io 2025-02-03 14:55:14 +01:00
commit 8ff67e6f38
5 changed files with 63 additions and 31 deletions

View file

@ -858,18 +858,30 @@ class Creator(BaseCreator):
["CollectAnatomyInstanceData"] ["CollectAnatomyInstanceData"]
["follow_workfile_version"] ["follow_workfile_version"]
) )
follow_version_hosts = (
publish_settings
["CollectSceneVersion"]
["hosts"]
)
current_host = create_ctx.host.name
follow_workfile_version = (
follow_workfile_version and
current_host in follow_version_hosts
)
# Gather version number provided from the instance. # Gather version number provided from the instance.
current_workfile = create_ctx.get_current_workfile_path()
version = instance.get("version") version = instance.get("version")
# If follow workfile, gather version from workfile path. # If follow workfile, gather version from workfile path.
if version is None and follow_workfile_version: if version is None and follow_workfile_version and current_workfile:
current_workfile = self.create_context.get_current_workfile_path()
workfile_version = get_version_from_path(current_workfile) workfile_version = get_version_from_path(current_workfile)
version = int(workfile_version) if workfile_version is not None:
version = int(workfile_version)
# Fill-up version with next version available. # Fill-up version with next version available.
elif version is None: if version is None:
versions = self.get_next_versions_for_instances( versions = self.get_next_versions_for_instances(
[instance] [instance]
) )

View file

@ -1,6 +1,7 @@
import copy import copy
import collections import collections
from uuid import uuid4 from uuid import uuid4
import typing
from typing import Optional, Dict, List, Any from typing import Optional, Dict, List, Any
from ayon_core.lib.attribute_definitions import ( from ayon_core.lib.attribute_definitions import (
@ -17,6 +18,9 @@ from ayon_core.pipeline import (
from .exceptions import ImmutableKeyError from .exceptions import ImmutableKeyError
from .changes import TrackChangesItem from .changes import TrackChangesItem
if typing.TYPE_CHECKING:
from .creator_plugins import BaseCreator
class ConvertorItem: class ConvertorItem:
"""Item representing convertor plugin. """Item representing convertor plugin.
@ -444,10 +448,11 @@ class CreatedInstance:
def __init__( def __init__(
self, self,
product_type, product_type: str,
product_name, product_name: str,
data, data: Dict[str, Any],
creator, creator: "BaseCreator",
transient_data: Optional[Dict[str, Any]] = None,
): ):
self._creator = creator self._creator = creator
creator_identifier = creator.identifier creator_identifier = creator.identifier
@ -462,7 +467,9 @@ class CreatedInstance:
self._members = [] self._members = []
# Data that can be used for lifetime of object # Data that can be used for lifetime of object
self._transient_data = {} if transient_data is None:
transient_data = {}
self._transient_data = transient_data
# Create a copy of passed data to avoid changing them on the fly # Create a copy of passed data to avoid changing them on the fly
data = copy.deepcopy(data or {}) data = copy.deepcopy(data or {})
@ -787,16 +794,26 @@ class CreatedInstance:
self._create_context.instance_create_attr_defs_changed(self.id) self._create_context.instance_create_attr_defs_changed(self.id)
@classmethod @classmethod
def from_existing(cls, instance_data, creator): def from_existing(
cls,
instance_data: Dict[str, Any],
creator: "BaseCreator",
transient_data: Optional[Dict[str, Any]] = None,
) -> "CreatedInstance":
"""Convert instance data from workfile to CreatedInstance. """Convert instance data from workfile to CreatedInstance.
Args: Args:
instance_data (Dict[str, Any]): Data in a structure ready for instance_data (Dict[str, Any]): Data in a structure ready for
'CreatedInstance' object. 'CreatedInstance' object.
creator (BaseCreator): Creator plugin which is creating the creator (BaseCreator): Creator plugin which is creating the
instance of for which the instance belong. instance of for which the instance belongs.
""" transient_data (Optional[dict[str, Any]]): Instance transient
data.
Returns:
CreatedInstance: Instance object.
"""
instance_data = copy.deepcopy(instance_data) instance_data = copy.deepcopy(instance_data)
product_type = instance_data.get("productType") product_type = instance_data.get("productType")
@ -809,7 +826,11 @@ class CreatedInstance:
product_name = instance_data.get("subset") product_name = instance_data.get("subset")
return cls( return cls(
product_type, product_name, instance_data, creator product_type,
product_name,
instance_data,
creator,
transient_data=transient_data,
) )
def attribute_value_changed(self, key, changes): def attribute_value_changed(self, key, changes):

View file

@ -464,6 +464,12 @@ def filter_pyblish_plugins(plugins):
if getattr(plugin, "enabled", True) is False: if getattr(plugin, "enabled", True) is False:
plugins.remove(plugin) plugins.remove(plugin)
# Pyblish already operated a filter based on host.
# But applying settings might have changed "hosts"
# value in plugin so re-filter.
elif not pyblish.plugin.host_is_compatible(plugin):
plugins.remove(plugin)
def get_errored_instances_from_context(context, plugin=None): def get_errored_instances_from_context(context, plugin=None):
"""Collect failed instances from pyblish context. """Collect failed instances from pyblish context.

View file

@ -292,6 +292,9 @@ class OptionalPyblishPluginMixin(AYONPyblishPluginMixin):
``` ```
""" """
# Allow exposing tooltip from class with `optional_tooltip` attribute
optional_tooltip: Optional[str] = None
@classmethod @classmethod
def get_attribute_defs(cls): def get_attribute_defs(cls):
"""Attribute definitions based on plugin's optional attribute.""" """Attribute definitions based on plugin's optional attribute."""
@ -304,8 +307,14 @@ class OptionalPyblishPluginMixin(AYONPyblishPluginMixin):
active = getattr(cls, "active", True) active = getattr(cls, "active", True)
# Return boolean stored under 'active' key with label of the class name # Return boolean stored under 'active' key with label of the class name
label = cls.label or cls.__name__ label = cls.label or cls.__name__
return [ return [
BoolDef("active", default=active, label=label) BoolDef(
"active",
default=active,
label=label,
tooltip=cls.optional_tooltip,
)
] ]
def is_active(self, data): def is_active(self, data):

View file

@ -14,23 +14,7 @@ class CollectSceneVersion(pyblish.api.ContextPlugin):
order = pyblish.api.CollectorOrder order = pyblish.api.CollectorOrder
label = 'Collect Scene Version' label = 'Collect Scene Version'
# configurable in Settings # configurable in Settings
hosts = [ hosts = ["*"]
"aftereffects",
"blender",
"celaction",
"fusion",
"harmony",
"hiero",
"houdini",
"maya",
"max",
"nuke",
"photoshop",
"resolve",
"tvpaint",
"motionbuilder",
"substancepainter"
]
# in some cases of headless publishing (for example webpublisher using PS) # in some cases of headless publishing (for example webpublisher using PS)
# you want to ignore version from name and let integrate use next version # you want to ignore version from name and let integrate use next version