mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
fixing lost commit content
- loading updating fixed and container data are imprinted with updated representation id - not failing due `::` split on NoneType object - workfile colorspace is separated key from ocio look items - validator treating workfile colorspace key separately
This commit is contained in:
parent
620269c2fc
commit
2445f6a1e4
5 changed files with 65 additions and 28 deletions
|
|
@ -15,7 +15,8 @@ from openpype.pipeline import (
|
|||
)
|
||||
from openpype.hosts.nuke.api import (
|
||||
containerise,
|
||||
viewer_update_and_undo_stop
|
||||
viewer_update_and_undo_stop,
|
||||
update_container,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -122,9 +123,9 @@ class LoadOcioLookNodes(load.LoaderPlugin):
|
|||
for node in group_node.nodes():
|
||||
if node.Class() not in ["Input", "Output"]:
|
||||
nuke.delete(node)
|
||||
if node.Class() == "Input":
|
||||
elif node.Class() == "Input":
|
||||
input_node = node
|
||||
if node.Class() == "Output":
|
||||
elif node.Class() == "Output":
|
||||
output_node = node
|
||||
else:
|
||||
group_node = nuke.createNode(
|
||||
|
|
@ -178,13 +179,12 @@ class LoadOcioLookNodes(load.LoaderPlugin):
|
|||
(
|
||||
file for file in all_files
|
||||
if file.endswith(extension)
|
||||
and item_name in file
|
||||
),
|
||||
None
|
||||
)
|
||||
if not item_lut_file:
|
||||
raise ValueError(
|
||||
"File with extension {} not found in directory".format(
|
||||
"File with extension '{}' not found in directory".format(
|
||||
extension))
|
||||
|
||||
item_lut_path = os.path.join(
|
||||
|
|
@ -243,6 +243,9 @@ class LoadOcioLookNodes(load.LoaderPlugin):
|
|||
self.log.info("Updated lut setup: `{}`".format(
|
||||
group_node["name"].value()))
|
||||
|
||||
return update_container(
|
||||
group_node, {"representation": str(representation["_id"])})
|
||||
|
||||
def _load_json_data(self, filepath):
|
||||
# getting data from json file with unicode conversion
|
||||
with open(filepath, "r") as _file:
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
from math import e
|
||||
import os
|
||||
from pprint import pformat
|
||||
import pyblish.api
|
||||
|
|
@ -42,9 +43,18 @@ class CollectColorspaceLook(pyblish.api.InstancePlugin,
|
|||
"input_colorspace",
|
||||
"output_colorspace"
|
||||
]:
|
||||
color_data = colorspace.convert_colorspace_enumerator_item(
|
||||
creator_attrs[colorspace_key], config_items)
|
||||
converted_color_data[colorspace_key] = color_data
|
||||
if creator_attrs[colorspace_key]:
|
||||
color_data = colorspace.convert_colorspace_enumerator_item(
|
||||
creator_attrs[colorspace_key], config_items)
|
||||
converted_color_data[colorspace_key] = color_data
|
||||
else:
|
||||
converted_color_data[colorspace_key] = None
|
||||
|
||||
# add colorspace to config data
|
||||
if converted_color_data["working_colorspace"]:
|
||||
config_data["colorspace"] = (
|
||||
converted_color_data["working_colorspace"]["name"]
|
||||
)
|
||||
|
||||
# create lut representation data
|
||||
lut_repre = {
|
||||
|
|
@ -58,12 +68,11 @@ class CollectColorspaceLook(pyblish.api.InstancePlugin,
|
|||
instance.data.update({
|
||||
"representations": [lut_repre],
|
||||
"source": file_url,
|
||||
"ocioLookWorkingSpace": converted_color_data["working_colorspace"],
|
||||
"ocioLookItems": [
|
||||
{
|
||||
"name": lut_repre_name,
|
||||
"ext": ext.lstrip("."),
|
||||
"working_colorspace": converted_color_data[
|
||||
"working_colorspace"],
|
||||
"input_colorspace": converted_color_data[
|
||||
"input_colorspace"],
|
||||
"output_colorspace": converted_color_data[
|
||||
|
|
@ -72,7 +81,7 @@ class CollectColorspaceLook(pyblish.api.InstancePlugin,
|
|||
"interpolation": creator_attrs["interpolation"],
|
||||
"config_data": config_data
|
||||
}
|
||||
]
|
||||
],
|
||||
})
|
||||
|
||||
self.log.debug(pformat(instance.data))
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ class ExtractColorspaceLook(publish.Extractor,
|
|||
|
||||
def process(self, instance):
|
||||
ociolook_items = instance.data["ocioLookItems"]
|
||||
ociolook_working_color = instance.data["ocioLookWorkingSpace"]
|
||||
staging_dir = self.staging_dir(instance)
|
||||
|
||||
# create ociolook file attributes
|
||||
|
|
@ -23,7 +24,8 @@ class ExtractColorspaceLook(publish.Extractor,
|
|||
ociolook_file_content = {
|
||||
"version": 1,
|
||||
"data": {
|
||||
"ocioLookItems": ociolook_items
|
||||
"ocioLookItems": ociolook_items,
|
||||
"ocioLookWorkingSpace": ociolook_working_color
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,25 +21,54 @@ class ValidateColorspaceLook(pyblish.api.InstancePlugin,
|
|||
instance.data["instance_id"])
|
||||
creator_defs = created_instance.creator_attribute_defs
|
||||
|
||||
ociolook_working_color = instance.data.get("ocioLookWorkingSpace")
|
||||
ociolook_items = instance.data.get("ocioLookItems", [])
|
||||
|
||||
for ociolook_item in ociolook_items:
|
||||
self.validate_colorspace_set_attrs(ociolook_item, creator_defs)
|
||||
creator_defs_by_key = {_def.key: _def.label for _def in creator_defs}
|
||||
|
||||
def validate_colorspace_set_attrs(self, ociolook_item, creator_defs):
|
||||
not_set_keys = {}
|
||||
if not ociolook_working_color:
|
||||
not_set_keys["working_colorspace"] = creator_defs_by_key[
|
||||
"working_colorspace"]
|
||||
|
||||
for ociolook_item in ociolook_items:
|
||||
item_not_set_keys = self.validate_colorspace_set_attrs(
|
||||
ociolook_item, creator_defs_by_key)
|
||||
if item_not_set_keys:
|
||||
not_set_keys[ociolook_item["name"]] = item_not_set_keys
|
||||
|
||||
if not_set_keys:
|
||||
message = (
|
||||
"Colorspace look attributes are not set: \n"
|
||||
)
|
||||
for key, value in not_set_keys.items():
|
||||
if isinstance(value, list):
|
||||
values_string = "\n\t- ".join(value)
|
||||
message += f"\n\t{key}:\n\t- {values_string}"
|
||||
else:
|
||||
message += f"\n\t{value}"
|
||||
|
||||
raise PublishValidationError(
|
||||
title="Colorspace Look attributes",
|
||||
message=message,
|
||||
description=message
|
||||
)
|
||||
|
||||
def validate_colorspace_set_attrs(
|
||||
self,
|
||||
ociolook_item,
|
||||
creator_defs_by_key
|
||||
):
|
||||
"""Validate colorspace look attributes"""
|
||||
|
||||
self.log.debug(f"Validate colorspace look attributes: {ociolook_item}")
|
||||
self.log.debug(f"Creator defs: {creator_defs}")
|
||||
|
||||
check_keys = [
|
||||
"working_colorspace",
|
||||
"input_colorspace",
|
||||
"output_colorspace",
|
||||
"direction",
|
||||
"interpolation"
|
||||
]
|
||||
creator_defs_by_key = {_def.key: _def.label for _def in creator_defs}
|
||||
|
||||
not_set_keys = []
|
||||
for key in check_keys:
|
||||
|
|
@ -57,13 +86,4 @@ class ValidateColorspaceLook(pyblish.api.InstancePlugin,
|
|||
)
|
||||
not_set_keys.append(def_label)
|
||||
|
||||
if not_set_keys:
|
||||
message = (
|
||||
"Colorspace look attributes are not set: "
|
||||
f"{', '.join(not_set_keys)}"
|
||||
)
|
||||
raise PublishValidationError(
|
||||
title="Colorspace Look attributes",
|
||||
message=message,
|
||||
description=message
|
||||
)
|
||||
return not_set_keys
|
||||
|
|
|
|||
|
|
@ -546,6 +546,9 @@ def convert_colorspace_enumerator_item(
|
|||
Returns:
|
||||
dict: colorspace data
|
||||
"""
|
||||
if "::" not in colorspace_enum_item:
|
||||
return None
|
||||
|
||||
# split string with `::` separator and set first as key and second as value
|
||||
item_type, item_name = colorspace_enum_item.split("::")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue