mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 22:02:15 +01:00
support local rendering for mantra_rop and add dedicated plugins
This commit is contained in:
parent
71bf18910c
commit
620538330c
6 changed files with 213 additions and 16 deletions
|
|
@ -1,8 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""Creator plugin to create Mantra ROP."""
|
||||
from ayon_core.hosts.houdini.api import plugin
|
||||
from ayon_core.pipeline import CreatedInstance
|
||||
from ayon_core.lib import EnumDef, BoolDef
|
||||
from ayon_core.lib import EnumDef, BoolDef, UISeparatorDef, UILabelDef
|
||||
|
||||
|
||||
class CreateMantraROP(plugin.HoudiniCreator):
|
||||
|
|
@ -23,12 +22,14 @@ class CreateMantraROP(plugin.HoudiniCreator):
|
|||
# Add chunk size attribute
|
||||
instance_data["chunkSize"] = 10
|
||||
# Submit for job publishing
|
||||
instance_data["farm"] = pre_create_data.get("farm")
|
||||
creator_attributes = instance_data.setdefault(
|
||||
"creator_attributes", dict())
|
||||
creator_attributes["farm"] = pre_create_data.get("farm")
|
||||
|
||||
instance = super(CreateMantraROP, self).create(
|
||||
product_name,
|
||||
instance_data,
|
||||
pre_create_data) # type: CreatedInstance
|
||||
pre_create_data)
|
||||
|
||||
instance_node = hou.node(instance.get("instance_node"))
|
||||
|
||||
|
|
@ -78,21 +79,14 @@ class CreateMantraROP(plugin.HoudiniCreator):
|
|||
to_lock = ["productType", "id"]
|
||||
self.lock_parameters(instance_node, to_lock)
|
||||
|
||||
def get_pre_create_attr_defs(self):
|
||||
attrs = super(CreateMantraROP, self).get_pre_create_attr_defs()
|
||||
|
||||
def get_instance_attr_defs(self):
|
||||
image_format_enum = [
|
||||
"bmp", "cin", "exr", "jpg", "pic", "pic.gz", "png",
|
||||
"rad", "rat", "rta", "sgi", "tga", "tif",
|
||||
]
|
||||
|
||||
return attrs + [
|
||||
BoolDef("farm",
|
||||
label="Submitting to Farm",
|
||||
default=True),
|
||||
BoolDef("export_job",
|
||||
label="Split export and render jobs",
|
||||
default=self.export_job),
|
||||
return [
|
||||
UILabelDef(label="Mantra Render Settings:"),
|
||||
EnumDef("image_format",
|
||||
image_format_enum,
|
||||
default="exr",
|
||||
|
|
@ -101,5 +95,24 @@ class CreateMantraROP(plugin.HoudiniCreator):
|
|||
label="Override Camera Resolution",
|
||||
tooltip="Override the current camera "
|
||||
"resolution, recommended for IPR.",
|
||||
default=False)
|
||||
default=False),
|
||||
UISeparatorDef(key="1"),
|
||||
UILabelDef(label="Farm Render Options:"),
|
||||
BoolDef("farm",
|
||||
label="Submitting to Farm",
|
||||
default=True),
|
||||
BoolDef("export_job",
|
||||
label="Split export and render jobs",
|
||||
default=self.export_job),
|
||||
UISeparatorDef(key="2"),
|
||||
UILabelDef(label="Local Render Options:"),
|
||||
BoolDef("skip_render",
|
||||
label="Skip Render",
|
||||
tooltip="Enable this option to skip render which publish existing frames.",
|
||||
default=False),
|
||||
]
|
||||
|
||||
def get_pre_create_attr_defs(self):
|
||||
attrs = super(CreateMantraROP, self).get_pre_create_attr_defs()
|
||||
|
||||
return attrs + self.get_instance_attr_defs()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,88 @@
|
|||
import os
|
||||
import pyblish.api
|
||||
|
||||
|
||||
class CollectLocalRenderInstances(pyblish.api.InstancePlugin):
|
||||
"""Collect instances for local render.
|
||||
|
||||
Agnostic Local Render Collector.
|
||||
"""
|
||||
|
||||
# this plugin runs after Collect Render Products
|
||||
order = pyblish.api.CollectorOrder + 0.12
|
||||
families = ["mantra_rop"]
|
||||
|
||||
hosts = ["houdini"]
|
||||
targets = ["local", "remote"]
|
||||
label = "Collect local render instances"
|
||||
|
||||
def process(self, instance):
|
||||
creator_attribute = instance.data["creator_attributes"]
|
||||
farm_enabled = creator_attribute["farm"]
|
||||
instance.data["farm"] = farm_enabled
|
||||
if farm_enabled:
|
||||
self.log.debug("Render on farm is enabled. "
|
||||
"Skipping local render collecting.")
|
||||
return
|
||||
|
||||
# Create Instance for each AOV.
|
||||
context = instance.context
|
||||
expectedFiles = next(iter(instance.data["expectedFiles"]), {})
|
||||
|
||||
product_type = "render" # is always render
|
||||
product_group = "render{Task}{productName}".format(
|
||||
Task=self._capitalize(instance.data["task"]),
|
||||
productName=self._capitalize(instance.data["productName"])
|
||||
) # is always the group
|
||||
|
||||
for aov_name, aov_filepaths in expectedFiles.items():
|
||||
# Some AOV instance data
|
||||
# label = "{productName}_{AOV}".format(
|
||||
# AOV=aov_name,
|
||||
# productName=instance.data["productName"]
|
||||
# )
|
||||
product_name = "render{Task}{productName}_{AOV}".format(
|
||||
Task=self._capitalize(instance.data["task"]),
|
||||
productName=self._capitalize(instance.data["productName"]),
|
||||
AOV=aov_name
|
||||
)
|
||||
|
||||
# Create instance for each AOV
|
||||
aov_instance = context.create_instance(product_name)
|
||||
|
||||
# Prepare Representation for each AOV
|
||||
aov_filenames = [os.path.basename(path) for path in aov_filepaths]
|
||||
staging_dir = os.path.dirname(aov_filepaths[0])
|
||||
ext = aov_filepaths[0].split(".")[-1]
|
||||
|
||||
aov_instance.data.update({
|
||||
# 'label': label,
|
||||
"task": instance.data["task"],
|
||||
"folderPath": instance.data["folderPath"],
|
||||
"frameStart": instance.data["frameStartHandle"],
|
||||
"frameEnd": instance.data["frameEndHandle"],
|
||||
"productType": product_type,
|
||||
"productName": product_name,
|
||||
"productGroup": product_group,
|
||||
"tags": [],
|
||||
"families": ["render.local.hou"],
|
||||
"instance_node": instance.data["instance_node"],
|
||||
"representations": [
|
||||
{
|
||||
"stagingDir": staging_dir,
|
||||
"ext": ext,
|
||||
"name": ext,
|
||||
"files": aov_filenames,
|
||||
"frameStart": instance.data["frameStartHandle"],
|
||||
"frameEnd": instance.data["frameEndHandle"]
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
# Remove Mantra instance
|
||||
# I can't remove it here as I still need it to trigger the render.
|
||||
# context.remove(instance)
|
||||
|
||||
@staticmethod
|
||||
def _capitalize(word):
|
||||
return word[:1].upper() + word[1:]
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
import pyblish.api
|
||||
|
||||
from ayon_core.pipeline import publish
|
||||
from ayon_core.hosts.houdini.api.lib import render_rop
|
||||
import hou
|
||||
|
||||
|
||||
class ExtractMantraLocalRender(publish.Extractor):
|
||||
|
||||
order = pyblish.api.ExtractorOrder
|
||||
label = "Extract Mantra Local Render"
|
||||
hosts = ["houdini"]
|
||||
families = ["mantra_rop"]
|
||||
targets = ["local", "remote"]
|
||||
|
||||
def process(self, instance):
|
||||
if instance.data.get("farm"):
|
||||
self.log.debug("Should be processed on farm, skipping.")
|
||||
return
|
||||
|
||||
creator_attribute = instance.data["creator_attributes"]
|
||||
skip_render = creator_attribute["skip_render"]
|
||||
|
||||
if skip_render:
|
||||
self.log.debug("Skip render is enabled, skipping rendering.")
|
||||
return
|
||||
|
||||
ropnode = hou.node(instance.data.get("instance_node"))
|
||||
render_rop(ropnode)
|
||||
|
|
@ -23,6 +23,7 @@ class IncrementCurrentFile(pyblish.api.ContextPlugin):
|
|||
"karma_rop",
|
||||
"usdrender",
|
||||
"render.farm.hou",
|
||||
"render.local.hou",
|
||||
"publish.hou"]
|
||||
optional = True
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,65 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import pyblish.api
|
||||
import hou
|
||||
from ayon_core.pipeline import PublishValidationError
|
||||
from ayon_core.pipeline.publish import RepairAction
|
||||
|
||||
|
||||
class DisableSplitExportAction(RepairAction):
|
||||
label = "Disable Split Export"
|
||||
|
||||
|
||||
class ValidateSplitExportIsDisabled(pyblish.api.InstancePlugin):
|
||||
"""Validate the Instance has no current cooking errors."""
|
||||
|
||||
order = pyblish.api.ValidatorOrder
|
||||
hosts = ["houdini"]
|
||||
families = ["mantra_rop"]
|
||||
label = "Validate Split Export Is Disabled"
|
||||
actions = [DisableSplitExportAction]
|
||||
|
||||
def process(self, instance):
|
||||
|
||||
invalid = self.get_invalid(instance)
|
||||
if invalid:
|
||||
nodes = [n.path() for n in invalid]
|
||||
raise PublishValidationError(
|
||||
"See log for details. "
|
||||
"Invalid nodes: {0}".format(nodes)
|
||||
)
|
||||
|
||||
|
||||
@classmethod
|
||||
def get_invalid(cls, instance):
|
||||
|
||||
invalid = []
|
||||
rop_node = hou.node(instance.data["instance_node"])
|
||||
|
||||
creator_attribute = instance.data["creator_attributes"]
|
||||
farm_enabled = creator_attribute["farm"]
|
||||
if farm_enabled:
|
||||
cls.log.debug(
|
||||
"Farm is enabled, skipping validation."
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
split_enabled = creator_attribute["export_job"]
|
||||
if split_enabled:
|
||||
invalid.append(rop_node)
|
||||
cls.log.error(
|
||||
"Split Export must be disabled in local render instances."
|
||||
)
|
||||
|
||||
return invalid
|
||||
|
||||
@classmethod
|
||||
def repair(cls, instance):
|
||||
|
||||
create_context = instance.context.data["create_context"]
|
||||
created_instance = create_context.get_instance_by_id(
|
||||
instance.data["instance_id"])
|
||||
creator_attributes = created_instance["creator_attributes"]
|
||||
# Disable export_job
|
||||
creator_attributes["export_job"] = False
|
||||
create_context.save_changes()
|
||||
|
|
@ -167,7 +167,8 @@ class IntegrateAsset(pyblish.api.InstancePlugin):
|
|||
"uasset",
|
||||
"blendScene",
|
||||
"yeticacheUE",
|
||||
"tycache"
|
||||
"tycache",
|
||||
"render.local.hou"
|
||||
]
|
||||
|
||||
default_template_name = "publish"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue