Merge branch 'develop' into enhancement/maya_get_related_sets_optimize

This commit is contained in:
Roy Nieterau 2024-04-02 11:21:38 +02:00 committed by GitHub
commit aeaf36dda7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 152 additions and 112 deletions

View file

@ -307,10 +307,6 @@ def on_save():
# update houdini vars
lib.update_houdini_vars_context_dialog()
nodes = lib.get_id_required_nodes()
for node, new_id in lib.generate_ids(nodes):
lib.set_id(node, new_id, overwrite=False)
# We are now starting the actual save directly
global ABOUT_TO_SAVE
ABOUT_TO_SAVE = False

View file

@ -4,7 +4,10 @@ from __future__ import absolute_import
import pyblish.api
import ayon_api
from ayon_core.pipeline.publish import get_errored_instances_from_context
from ayon_core.pipeline.publish import (
get_errored_instances_from_context,
get_errored_plugins_from_context
)
class GenerateUUIDsOnInvalidAction(pyblish.api.Action):
@ -112,20 +115,25 @@ class SelectInvalidAction(pyblish.api.Action):
except ImportError:
raise ImportError("Current host is not Maya")
errored_instances = get_errored_instances_from_context(context,
plugin=plugin)
# Get the invalid nodes for the plug-ins
self.log.info("Finding invalid nodes..")
invalid = list()
for instance in errored_instances:
invalid_nodes = plugin.get_invalid(instance)
if invalid_nodes:
if isinstance(invalid_nodes, (list, tuple)):
invalid.extend(invalid_nodes)
else:
self.log.warning("Plug-in returned to be invalid, "
"but has no selectable nodes.")
if issubclass(plugin, pyblish.api.ContextPlugin):
errored_plugins = get_errored_plugins_from_context(context)
if plugin in errored_plugins:
invalid = plugin.get_invalid(context)
else:
errored_instances = get_errored_instances_from_context(
context, plugin=plugin
)
for instance in errored_instances:
invalid_nodes = plugin.get_invalid(instance)
if invalid_nodes:
if isinstance(invalid_nodes, (list, tuple)):
invalid.extend(invalid_nodes)
else:
self.log.warning("Plug-in returned to be invalid, "
"but has no selectable nodes.")
# Ensure unique (process each node only once)
invalid = list(set(invalid))

View file

@ -113,7 +113,9 @@ def override_toolbox_ui():
annotation="Look Manager",
label="Look Manager",
image=os.path.join(icons, "lookmanager.png"),
command=show_look_assigner,
command=lambda: show_look_assigner(
parent=parent_widget
),
width=icon_size,
height=icon_size,
parent=parent

View file

@ -1876,18 +1876,9 @@ def list_looks(project_name, folder_id):
list[dict[str, Any]]: List of look products.
"""
# # get all products with look leading in
# the name associated with the asset
# TODO this should probably look for product type 'look' instead of
# checking product name that can not start with product type
product_entities = ayon_api.get_products(
project_name, folder_ids=[folder_id]
)
return [
product_entity
for product_entity in product_entities
if product_entity["name"].startswith("look")
]
return list(ayon_api.get_products(
project_name, folder_ids=[folder_id], product_types={"look"}
))
def assign_look_by_version(nodes, version_id):
@ -1906,12 +1897,15 @@ def assign_look_by_version(nodes, version_id):
project_name = get_current_project_name()
# Get representations of shader file and relationships
look_representation = ayon_api.get_representation_by_name(
project_name, "ma", version_id
)
json_representation = ayon_api.get_representation_by_name(
project_name, "json", version_id
)
representations = list(ayon_api.get_representations(
project_name=project_name,
representation_names={"ma", "json"},
version_ids=[version_id]
))
look_representation = next(
repre for repre in representations if repre["name"] == "ma")
json_representation = next(
repre for repre in representations if repre["name"] == "json")
# See if representation is already loaded, if so reuse it.
host = registered_host()
@ -1948,7 +1942,7 @@ def assign_look_by_version(nodes, version_id):
apply_shaders(relationships, shader_nodes, nodes)
def assign_look(nodes, product_name="lookDefault"):
def assign_look(nodes, product_name="lookMain"):
"""Assigns a look to a node.
Optimizes the nodes by grouping by folder id and finding
@ -1981,14 +1975,10 @@ def assign_look(nodes, product_name="lookDefault"):
product_entity["id"]
for product_entity in product_entities_by_folder_id.values()
}
last_version_entities = ayon_api.get_last_versions(
last_version_entities_by_product_id = ayon_api.get_last_versions(
project_name,
product_ids
)
last_version_entities_by_product_id = {
last_version_entity["productId"]: last_version_entity
for last_version_entity in last_version_entities
}
for folder_id, asset_nodes in grouped.items():
product_entity = product_entities_by_folder_id.get(folder_id)

View file

@ -1,24 +1,19 @@
# -*- coding: utf-8 -*-
"""Collect render data.
This collector will go through render layers in maya and prepare all data
needed to create instances and their representations for submission and
publishing on farm.
This collector will go through renderlayer instances and prepare all data
needed to detect the expected rendered files for a layer, with resolution,
frame ranges and collects the data needed for publishing on the farm.
Requires:
instance -> families
instance -> setMembers
instance -> folderPath
context -> currentFile
context -> workspaceDir
context -> user
Optional:
Provides:
instance -> label
instance -> productName
instance -> subset
instance -> attachTo
instance -> setMembers
instance -> publish
@ -26,6 +21,8 @@ Provides:
instance -> frameEnd
instance -> byFrameStep
instance -> renderer
instance -> family
instance -> asset
instance -> time
instance -> author
instance -> source
@ -71,8 +68,6 @@ class CollectMayaRender(pyblish.api.InstancePlugin):
# TODO: Re-add force enable of workfile instance?
# TODO: Re-add legacy layer support with LAYER_ prefix but in Creator
# TODO: Set and collect active state of RenderLayer in Creator using
# renderlayer.isRenderable()
context = instance.context
layer = instance.data["transientData"]["layer"]
@ -112,7 +107,13 @@ class CollectMayaRender(pyblish.api.InstancePlugin):
except UnsupportedRendererException as exc:
raise KnownPublishError(exc)
render_products = layer_render_products.layer_data.products
assert render_products, "no render products generated"
if not render_products:
self.log.error(
"No render products generated for '%s'. You might not have "
"any render camera in the renderlayer or render end frame is "
"lower than start frame.",
instance.name
)
expected_files = []
multipart = False
for product in render_products:
@ -130,16 +131,21 @@ class CollectMayaRender(pyblish.api.InstancePlugin):
})
has_cameras = any(product.camera for product in render_products)
assert has_cameras, "No render cameras found."
self.log.debug("multipart: {}".format(
multipart))
assert expected_files, "no file names were generated, this is a bug"
self.log.debug(
"expected files: {}".format(
json.dumps(expected_files, indent=4, sort_keys=True)
if render_products and not has_cameras:
self.log.error(
"No render cameras found for: %s",
instance
)
)
if not expected_files:
self.log.warning(
"No file names were generated, this is a bug.")
for render_product in render_products:
self.log.debug(render_product)
self.log.debug("multipart: {}".format(multipart))
self.log.debug("expected files: {}".format(
json.dumps(expected_files, indent=4, sort_keys=True)
))
# if we want to attach render to product, check if we have AOV's
# in expectedFiles. If so, raise error as we cannot attach AOV
@ -151,14 +157,14 @@ class CollectMayaRender(pyblish.api.InstancePlugin):
)
# append full path
aov_dict = {}
image_directory = os.path.join(
cmds.workspace(query=True, rootDirectory=True),
cmds.workspace(fileRuleEntry="images")
)
# replace relative paths with absolute. Render products are
# returned as list of dictionaries.
publish_meta_path = None
publish_meta_path = "NOT-SET"
aov_dict = {}
for aov in expected_files:
full_paths = []
aov_first_key = list(aov.keys())[0]
@ -169,14 +175,6 @@ class CollectMayaRender(pyblish.api.InstancePlugin):
publish_meta_path = os.path.dirname(full_path)
aov_dict[aov_first_key] = full_paths
full_exp_files = [aov_dict]
self.log.debug(full_exp_files)
if publish_meta_path is None:
raise KnownPublishError("Unable to detect any expected output "
"images for: {}. Make sure you have a "
"renderable camera and a valid frame "
"range set for your renderlayer."
"".format(instance.name))
frame_start_render = int(self.get_render_attribute(
"startFrame", layer=layer_name))
@ -222,7 +220,8 @@ class CollectMayaRender(pyblish.api.InstancePlugin):
common_publish_meta_path = "/" + common_publish_meta_path
self.log.debug(
"Publish meta path: {}".format(common_publish_meta_path))
"Publish meta path: {}".format(common_publish_meta_path)
)
# Get layer specific settings, might be overrides
colorspace_data = lib.get_color_management_preferences()

View file

@ -5,7 +5,8 @@ from maya import cmds
from ayon_core.pipeline import publish
class ExtractGPUCache(publish.Extractor):
class ExtractGPUCache(publish.Extractor,
publish.OptionalPyblishPluginMixin):
"""Extract the content of the instance to a GPU cache file."""
label = "GPU Cache"
@ -20,6 +21,9 @@ class ExtractGPUCache(publish.Extractor):
useBaseTessellation = True
def process(self, instance):
if not self.is_active(instance.data):
return
cmds.loadPlugin("gpuCache", quiet=True)
staging_dir = self.staging_dir(instance)

View file

@ -47,10 +47,18 @@ class ValidateShadingEngine(pyblish.api.InstancePlugin,
shape, destination=True, type="shadingEngine"
) or []
for shading_engine in shading_engines:
name = (
cmds.listConnections(shading_engine + ".surfaceShader")[0]
+ "SG"
materials = cmds.listConnections(
shading_engine + ".surfaceShader",
source=True, destination=False
)
if not materials:
cls.log.warning(
"Shading engine '{}' has no material connected to its "
".surfaceShader attribute.".format(shading_engine))
continue
material = materials[0] # there should only ever be one input
name = material + "SG"
if shading_engine != name:
invalid.append(shading_engine)

View file

@ -1,4 +1,5 @@
import re
import inspect
import pyblish.api
from maya import cmds
@ -36,7 +37,10 @@ class ValidateRenderSingleCamera(pyblish.api.InstancePlugin,
return
invalid = self.get_invalid(instance)
if invalid:
raise PublishValidationError("Invalid cameras for render.")
raise PublishValidationError(
"Invalid render cameras.",
description=self.get_description()
)
@classmethod
def get_invalid(cls, instance):
@ -51,17 +55,30 @@ class ValidateRenderSingleCamera(pyblish.api.InstancePlugin,
RenderSettings.get_image_prefix_attr(renderer)
)
renderlayer = instance.data["renderlayer"]
if len(cameras) > 1:
if re.search(cls.R_CAMERA_TOKEN, file_prefix):
# if there is <Camera> token in prefix and we have more then
# 1 camera, all is ok.
return
cls.log.error("Multiple renderable cameras found for %s: %s " %
(instance.data["setMembers"], cameras))
return [instance.data["setMembers"]] + cameras
cls.log.error(
"Multiple renderable cameras found for %s: %s ",
renderlayer, ", ".join(cameras))
return [renderlayer] + cameras
elif len(cameras) < 1:
cls.log.error("No renderable cameras found for %s " %
instance.data["setMembers"])
return [instance.data["setMembers"]]
cls.log.error("No renderable cameras found for %s ", renderlayer)
return [renderlayer]
def get_description(self):
return inspect.cleandoc(
"""### Render Cameras Invalid
Your render cameras are misconfigured. You may have no render
camera set or have multiple cameras with a render filename
prefix that does not include the `<Camera>` token.
See the logs for more details about the cameras.
"""
)

View file

@ -51,7 +51,7 @@ def assign_vrayproxy_shaders(vrayproxy, assignments):
index += 1
def vrayproxy_assign_look(vrayproxy, product_name="lookDefault"):
def vrayproxy_assign_look(vrayproxy, product_name="lookMain"):
# type: (str, str) -> None
"""Assign look to vray proxy.

View file

@ -18,7 +18,7 @@ class SubstanceLoadProjectMesh(load.LoaderPlugin):
"""Load mesh for project"""
product_types = {"*"}
representations = ["abc", "fbx", "obj", "gltf"]
representations = ["abc", "fbx", "obj", "gltf", "usd", "usda", "usdc"]
label = "Load mesh"
order = -10

View file

@ -194,6 +194,16 @@ class ExtractBurnin(publish.Extractor):
).format(host_name, product_type, task_name, profile))
return
burnins_per_repres = self._get_burnins_per_representations(
instance, burnin_defs
)
if not burnins_per_repres:
self.log.debug(
"Skipped instance. No representations found matching a burnin"
"definition in: %s", burnin_defs
)
return
burnin_options = self._get_burnin_options()
# Prepare basic data for processing
@ -204,9 +214,6 @@ class ExtractBurnin(publish.Extractor):
# Args that will execute the script
executable_args = ["run", scriptpath]
burnins_per_repres = self._get_burnins_per_representations(
instance, burnin_defs
)
for repre, repre_burnin_defs in burnins_per_repres:
# Create copy of `_burnin_data` and `_temp_data` for repre.
burnin_data = copy.deepcopy(_burnin_data)

View file

@ -619,7 +619,7 @@ class ExtractReview(pyblish.api.InstancePlugin):
# Prepare input and output filepaths
self.input_output_paths(new_repre, output_def, temp_data)
# Set output frames len to 1 when ouput is single image
# Set output frames len to 1 when output is single image
if (
temp_data["output_ext_is_image"]
and not temp_data["output_is_sequence"]
@ -955,7 +955,7 @@ class ExtractReview(pyblish.api.InstancePlugin):
self.log.debug("New representation ext: `{}`".format(output_ext))
# Output is image file sequence witht frames
# Output is image file sequence with frames
output_ext_is_image = bool(output_ext in self.image_exts)
output_is_sequence = bool(
output_ext_is_image
@ -967,7 +967,7 @@ class ExtractReview(pyblish.api.InstancePlugin):
frame_end = temp_data["output_frame_end"]
filename_base = "{}_{}".format(filename, filename_suffix)
# Temporary tempalte for frame filling. Example output:
# Temporary template for frame filling. Example output:
# "basename.%04d.exr" when `frame_end` == 1001
repr_file = "{}.%{:0>2}d.{}".format(
filename_base, len(str(frame_end)), output_ext
@ -997,7 +997,7 @@ class ExtractReview(pyblish.api.InstancePlugin):
self.log.debug("Creating dir: {}".format(dst_staging_dir))
os.makedirs(dst_staging_dir)
# Store stagingDir to representaion
# Store stagingDir to representation
new_repre["stagingDir"] = dst_staging_dir
# Store paths to temp data
@ -1228,16 +1228,6 @@ class ExtractReview(pyblish.api.InstancePlugin):
reformat_in_baking = bool("reformated" in new_repre["tags"])
self.log.debug("reformat_in_baking: `{}`".format(reformat_in_baking))
# Get instance data
pixel_aspect = temp_data["pixel_aspect"]
if reformat_in_baking:
self.log.debug((
"Using resolution from input. It is already "
"reformated from upstream process"
))
pixel_aspect = 1
# NOTE Skipped using instance's resolution
full_input_path_single_file = temp_data["full_input_path_single_file"]
try:
@ -1268,7 +1258,7 @@ class ExtractReview(pyblish.api.InstancePlugin):
if reformat_in_baking:
self.log.debug((
"Using resolution from input. It is already "
"reformated from upstream process"
"reformatted from upstream process"
))
pixel_aspect = 1
output_width = input_width
@ -1374,7 +1364,7 @@ class ExtractReview(pyblish.api.InstancePlugin):
# Make sure output width and height is not an odd number
# When this can happen:
# - if output definition has set width and height with odd number
# - `instance.data` contain width and height with odd numbeer
# - `instance.data` contain width and height with odd number
if output_width % 2 != 0:
self.log.warning((
"Converting output width from odd to even number. {} -> {}"
@ -1555,7 +1545,7 @@ class ExtractReview(pyblish.api.InstancePlugin):
custom_tags (list): Custom Tags of processed representation.
Returns:
list: Containg all output definitions matching entered tags.
list: Containing all output definitions matching entered tags.
"""
filtered_outputs = []
@ -1820,8 +1810,8 @@ class OverscanCrop:
"""
# crop=width:height:x:y - explicit start x, y position
# crop=width:height - x, y are related to center by width/height
# pad=width:heigth:x:y - explicit start x, y position
# pad=width:heigth - x, y are set to 0 by default
# pad=width:height:x:y - explicit start x, y position
# pad=width:height - x, y are set to 0 by default
width = self.width()
height = self.height()
@ -1869,7 +1859,7 @@ class OverscanCrop:
# Replace "px" (and spaces before) with single space
string_value = re.sub(r"([ ]+)?px", " ", string_value)
string_value = re.sub(r"([ ]+)%", "%", string_value)
# Make sure +/- sign at the beggining of string is next to number
# Make sure +/- sign at the beginning of string is next to number
string_value = re.sub(r"^([\+\-])[ ]+", "\g<1>", string_value)
# Make sure +/- sign in the middle has zero spaces before number under
# which belongs

View file

@ -316,6 +316,12 @@ class ExtractObjModel(BaseSettingsModel):
optional: bool = SettingsField(title="Optional")
class ExtractModelModel(BaseSettingsModel):
enabled: bool = SettingsField(title="Enabled")
optional: bool = SettingsField(title="Optional")
active: bool = SettingsField(title="Active")
class ExtractMayaSceneRawModel(BaseSettingsModel):
"""Add loaded instances to those published families:"""
enabled: bool = SettingsField(title="ExtractMayaSceneRaw")
@ -372,7 +378,9 @@ class ExtractLookModel(BaseSettingsModel):
class ExtractGPUCacheModel(BaseSettingsModel):
enabled: bool = True
enabled: bool = SettingsField(title="Enabled")
optional: bool = SettingsField(title="Optional")
active: bool = SettingsField(title="Active")
families: list[str] = SettingsField(default_factory=list, title="Families")
step: float = SettingsField(1.0, ge=1.0, title="Step")
stepSave: int = SettingsField(1, ge=1, title="Step Save")
@ -799,6 +807,10 @@ class PublishersModel(BaseSettingsModel):
default_factory=ExtractGPUCacheModel,
title="Extract GPU Cache",
)
ExtractModel: ExtractModelModel = SettingsField(
default_factory=ExtractModelModel,
title="Extract Model (Maya Scene)"
)
DEFAULT_SUFFIX_NAMING = {
@ -1341,6 +1353,8 @@ DEFAULT_PUBLISH_SETTINGS = {
},
"ExtractGPUCache": {
"enabled": False,
"optional": False,
"active": True,
"families": [
"model",
"animation",
@ -1353,5 +1367,10 @@ DEFAULT_PUBLISH_SETTINGS = {
"optimizeAnimationsForMotionBlur": True,
"writeMaterials": True,
"useBaseTessellation": True
},
"ExtractModel": {
"enabled": True,
"optional": True,
"active": True,
}
}

View file

@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-
"""Package declaring addon version."""
__version__ = "0.1.12"
__version__ = "0.1.13"