Skip to content

Commit

Permalink
Merge branch 'develop' into feature/add_pyblish_debug_stepper_to_expr…
Browse files Browse the repository at this point in the history
…imental_tools
  • Loading branch information
iLLiCiTiT authored Oct 9, 2024
2 parents 4d6f7d4 + 1489d98 commit 4aea1c9
Show file tree
Hide file tree
Showing 42 changed files with 7,942 additions and 477 deletions.
12 changes: 11 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Bug Report
description: File a bug report
title: 'Your issue title here'
title: Your issue title here
labels:
- 'type: bug'
body:
Expand Down Expand Up @@ -36,6 +36,16 @@ body:
description: What version are you running? Look to AYON Tray
options:
- 1.0.0
- 0.4.4
- 0.4.3
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.2
- 0.3.1
- 0.3.0
- 0.2.1
- 0.2.0
validations:
required: true
- type: dropdown
Expand Down
3 changes: 2 additions & 1 deletion client/ayon_core/hooks/pre_add_last_workfile_arg.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class AddLastWorkfileToLaunchArgs(PreLaunchHook):
"substancepainter",
"aftereffects",
"wrap",
"openrv"
"openrv",
"cinema4d"
}
launch_types = {LaunchTypes.local}

Expand Down
85 changes: 67 additions & 18 deletions client/ayon_core/lib/attribute_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import uuid
import json
import copy
import warnings
from abc import ABCMeta, abstractmethod

import clique
Expand Down Expand Up @@ -90,6 +91,30 @@ def __call__(cls, *args, **kwargs):
return obj


def _convert_reversed_attr(
main_value, depr_value, main_label, depr_label, default
):
if main_value is not None and depr_value is not None:
if main_value == depr_value:
print(
f"Got invalid '{main_label}' and '{depr_label}' arguments."
f" Using '{main_label}' value."
)
elif depr_value is not None:
warnings.warn(
(
"DEPRECATION WARNING: Using deprecated argument"
f" '{depr_label}' please use '{main_label}' instead."
),
DeprecationWarning,
stacklevel=4,
)
main_value = not depr_value
elif main_value is None:
main_value = default
return main_value


class AbstractAttrDef(metaclass=AbstractAttrDefMeta):
"""Abstraction of attribute definition.
Expand All @@ -106,12 +131,14 @@ class AbstractAttrDef(metaclass=AbstractAttrDefMeta):
Args:
key (str): Under which key will be attribute value stored.
default (Any): Default value of an attribute.
label (str): Attribute label.
tooltip (str): Attribute tooltip.
is_label_horizontal (bool): UI specific argument. Specify if label is
next to value input or ahead.
hidden (bool): Will be item hidden (for UI purposes).
disabled (bool): Item will be visible but disabled (for UI purposes).
label (Optional[str]): Attribute label.
tooltip (Optional[str]): Attribute tooltip.
is_label_horizontal (Optional[bool]): UI specific argument. Specify
if label is next to value input or ahead.
visible (Optional[bool]): Item is shown to user (for UI purposes).
enabled (Optional[bool]): Item is enabled (for UI purposes).
hidden (Optional[bool]): DEPRECATED: Use 'visible' instead.
disabled (Optional[bool]): DEPRECATED: Use 'enabled' instead.
"""

type_attributes = []
Expand All @@ -125,22 +152,28 @@ def __init__(
label=None,
tooltip=None,
is_label_horizontal=None,
hidden=False,
disabled=False
visible=None,
enabled=None,
hidden=None,
disabled=None,
):
if is_label_horizontal is None:
is_label_horizontal = True

if hidden is None:
hidden = False
enabled = _convert_reversed_attr(
enabled, disabled, "enabled", "disabled", True
)
visible = _convert_reversed_attr(
visible, hidden, "visible", "hidden", True
)

self.key = key
self.label = label
self.tooltip = tooltip
self.default = default
self.is_label_horizontal = is_label_horizontal
self.hidden = hidden
self.disabled = disabled
self.visible = visible
self.enabled = enabled
self._id = uuid.uuid4().hex

self.__init__class__ = AbstractAttrDef
Expand All @@ -149,14 +182,30 @@ def __init__(
def id(self):
return self._id

@property
def hidden(self):
return not self.visible

@hidden.setter
def hidden(self, value):
self.visible = not value

@property
def disabled(self):
return not self.enabled

@disabled.setter
def disabled(self, value):
self.enabled = not value

def __eq__(self, other):
if not isinstance(other, self.__class__):
return False
return (
self.key == other.key
and self.hidden == other.hidden
and self.default == other.default
and self.disabled == other.disabled
and self.visible == other.visible
and self.enabled == other.enabled
)

def __ne__(self, other):
Expand Down Expand Up @@ -198,8 +247,8 @@ def serialize(self):
"tooltip": self.tooltip,
"default": self.default,
"is_label_horizontal": self.is_label_horizontal,
"hidden": self.hidden,
"disabled": self.disabled
"visible": self.visible,
"enabled": self.enabled
}
for attr in self.type_attributes:
data[attr] = getattr(self, attr)
Expand Down Expand Up @@ -279,8 +328,8 @@ class HiddenDef(AbstractAttrDef):

def __init__(self, key, default=None, **kwargs):
kwargs["default"] = default
kwargs["hidden"] = True
super(HiddenDef, self).__init__(key, **kwargs)
kwargs["visible"] = False
super().__init__(key, **kwargs)

def convert_value(self, value):
return value
Expand Down
8 changes: 3 additions & 5 deletions client/ayon_core/lib/transcoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -1152,9 +1152,7 @@ def convert_colorspace(
input_arg, input_path,
# Tell oiiotool which channels should be put to top stack
# (and output)
"--ch", channels_arg,
# Use first subimage
"--subimage", "0"
"--ch", channels_arg
])

if all([target_colorspace, view, display]):
Expand All @@ -1168,12 +1166,12 @@ def convert_colorspace(
oiio_cmd.extend(additional_command_args)

if target_colorspace:
oiio_cmd.extend(["--colorconvert",
oiio_cmd.extend(["--colorconvert:subimages=0",
source_colorspace,
target_colorspace])
if view and display:
oiio_cmd.extend(["--iscolorspace", source_colorspace])
oiio_cmd.extend(["--ociodisplay", display, view])
oiio_cmd.extend(["--ociodisplay:subimages=0", display, view])

oiio_cmd.extend(["-o", output_path])

Expand Down
76 changes: 56 additions & 20 deletions client/ayon_core/pipeline/colorspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,34 @@ def get_ocio_config_views(config_path):
)


def _get_config_path_from_profile_data(
profile, profile_type, template_data
):
"""Get config path from profile data.
Args:
profile (dict[str, Any]): Profile data.
profile_type (str): Profile type.
template_data (dict[str, Any]): Template data.
Returns:
dict[str, str]: Config data with path and template.
"""
template = profile[profile_type]
result = StringTemplate.format_strict_template(
template, template_data
)
normalized_path = str(result.normalized())
if not os.path.exists(normalized_path):
log.warning(f"Path was not found '{normalized_path}'.")
return None

return {
"path": normalized_path,
"template": template
}


def _get_global_config_data(
project_name,
host_name,
Expand All @@ -717,7 +745,7 @@ def _get_global_config_data(
2. Custom path to ocio config.
3. Path to 'ocioconfig' representation on product. Name of product can be
defined in settings. Product name can be regex but exact match is
always preferred.
always preferred. Fallback can be defined in case no product is found.
None is returned when no profile is found, when path
Expand Down Expand Up @@ -755,30 +783,36 @@ def _get_global_config_data(

profile_type = profile["type"]
if profile_type in ("builtin_path", "custom_path"):
template = profile[profile_type]
result = StringTemplate.format_strict_template(
template, template_data
)
normalized_path = str(result.normalized())
if not os.path.exists(normalized_path):
log.warning(f"Path was not found '{normalized_path}'.")
return None

return {
"path": normalized_path,
"template": template
}
return _get_config_path_from_profile_data(
profile, profile_type, template_data)

# TODO decide if this is the right name for representation
repre_name = "ocioconfig"

published_product_data = profile["published_product"]
product_name = published_product_data["product_name"]
fallback_data = published_product_data["fallback"]

if product_name == "":
log.error(
"Colorspace OCIO config path cannot be set. "
"Profile is set to published product but `Product name` is empty."
)
return None

folder_info = template_data.get("folder")
if not folder_info:
log.warning("Folder info is missing.")
return None

log.info("Using fallback data for ocio config path.")
# in case no product was found we need to use fallback
fallback_type = fallback_data["fallback_type"]
return _get_config_path_from_profile_data(
fallback_data, fallback_type, template_data
)

folder_path = folder_info["path"]

product_name = profile["product_name"]
if folder_id is None:
folder_entity = ayon_api.get_folder_by_path(
project_name, folder_path, fields={"id"}
Expand All @@ -797,12 +831,13 @@ def _get_global_config_data(
fields={"id", "name"}
)
}

if not product_entities_by_name:
log.debug(
f"No product entities were found for folder '{folder_path}' with"
f" product name filter '{product_name}'."
# in case no product was found we need to use fallback
fallback_type = fallback_data["type"]
return _get_config_path_from_profile_data(
fallback_data, fallback_type, template_data
)
return None

# Try to use exact match first, otherwise use first available product
product_entity = product_entities_by_name.get(product_name)
Expand Down Expand Up @@ -837,6 +872,7 @@ def _get_global_config_data(

path = get_representation_path_with_anatomy(repre_entity, anatomy)
template = repre_entity["attrib"]["template"]

return {
"path": path,
"template": template,
Expand Down
5 changes: 4 additions & 1 deletion client/ayon_core/pipeline/context_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ def install_host(host):

def modified_emit(obj, record):
"""Method replacing `emit` in Pyblish's MessageHandler."""
record.msg = record.getMessage()
try:
record.msg = record.getMessage()
except Exception:
record.msg = str(record.msg)
obj.records.append(record)

MessageHandler.emit = modified_emit
Expand Down
Loading

0 comments on commit 4aea1c9

Please sign in to comment.