mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 13:52:15 +01:00
feat(nuke): updating validation of nodes write
This commit is contained in:
parent
115937ab00
commit
b8f64d293e
3 changed files with 52 additions and 22 deletions
|
|
@ -59,6 +59,32 @@ def version_up_script():
|
|||
nukescripts.script_and_write_nodes_version_up()
|
||||
|
||||
|
||||
def get_render_path(node):
|
||||
from .templates import (
|
||||
get_dataflow,
|
||||
get_colorspace
|
||||
)
|
||||
data = dict()
|
||||
data['avalon'] = get_avalon_knob_data(node)
|
||||
|
||||
data_preset = {
|
||||
"class": data['avalon']['family'],
|
||||
"preset": data['avalon']['families']
|
||||
}
|
||||
|
||||
nuke_dataflow_writes = get_dataflow(**data_preset)
|
||||
nuke_colorspace_writes = get_colorspace(**data_preset)
|
||||
|
||||
application = lib.get_application(os.environ["AVALON_APP_NAME"])
|
||||
data.update({
|
||||
"application": application,
|
||||
"nuke_dataflow_writes": nuke_dataflow_writes,
|
||||
"nuke_colorspace_writes": nuke_colorspace_writes
|
||||
})
|
||||
|
||||
anatomy_filled = format_anatomy(data)
|
||||
return anatomy_filled.render.path
|
||||
|
||||
def format_anatomy(data):
|
||||
from .templates import (
|
||||
get_anatomy
|
||||
|
|
@ -76,11 +102,11 @@ def format_anatomy(data):
|
|||
data.update({
|
||||
"subset": data["avalon"]["subset"],
|
||||
"asset": data["avalon"]["asset"],
|
||||
"task": pype.get_task(),
|
||||
"task": str(pype.get_task()).lower(),
|
||||
"family": data["avalon"]["family"],
|
||||
"project": {"name": pype.get_project_name(),
|
||||
"code": pype.get_project_code()},
|
||||
"representation": ["nuke_dataflow_writes"].file_type,
|
||||
"representation": data["nuke_dataflow_writes"].file_type,
|
||||
"app": data["application"]["application_dir"],
|
||||
"hierarchy": pype.get_hierarchy(),
|
||||
"frame": "#" * padding,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import pyblish.api
|
|||
import pype.utils
|
||||
|
||||
|
||||
|
||||
@pyblish.api.log
|
||||
class RepairNukeWriteNodeVersionAction(pyblish.api.Action):
|
||||
label = "Repair"
|
||||
|
|
@ -10,21 +11,14 @@ class RepairNukeWriteNodeVersionAction(pyblish.api.Action):
|
|||
icon = "wrench"
|
||||
|
||||
def process(self, context, plugin):
|
||||
|
||||
import pype.nuke.lib as nukelib
|
||||
instances = pype.utils.filter_instances(context, plugin)
|
||||
|
||||
for instance in instances:
|
||||
if "create_directories" in instance[0].knobs():
|
||||
instance[0]['create_directories'].setValue(True)
|
||||
else:
|
||||
path, file = os.path.split(instance[0].data['outputFilename'])
|
||||
self.log.info(path)
|
||||
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
|
||||
if "metadata" in instance[0].knobs().keys():
|
||||
instance[0]["metadata"].setValue("all metadata")
|
||||
node = instance[0]
|
||||
render_path = nukelib.get_render_path(node)
|
||||
self.log.info("render_path: {}".format(render_path))
|
||||
node['file'].setValue(render_path.replace("\\", "/"))
|
||||
|
||||
|
||||
class ValidateVersionMatch(pyblish.api.InstancePlugin):
|
||||
|
|
@ -2,7 +2,6 @@ import os
|
|||
import pyblish.api
|
||||
import pype.utils
|
||||
|
||||
|
||||
@pyblish.api.log
|
||||
class RepairNukeWriteNodeAction(pyblish.api.Action):
|
||||
label = "Repair"
|
||||
|
|
@ -10,20 +9,25 @@ class RepairNukeWriteNodeAction(pyblish.api.Action):
|
|||
icon = "wrench"
|
||||
|
||||
def process(self, context, plugin):
|
||||
|
||||
import pype.nuke.lib as nukelib
|
||||
instances = pype.utils.filter_instances(context, plugin)
|
||||
|
||||
for instance in instances:
|
||||
node = instance[0]
|
||||
render_path = nukelib.get_render_path(node).replace("\\", "/")
|
||||
self.log.info("render_path: {}".format(render_path))
|
||||
node['file'].setValue(render_path)
|
||||
|
||||
if "create_directories" in instance[0].knobs():
|
||||
instance[0]['create_directories'].setValue(True)
|
||||
node['create_directories'].setValue(True)
|
||||
else:
|
||||
path, file = os.path.split(instance[0].data['outputFilename'])
|
||||
path, file = os.path.split(render_path)
|
||||
self.log.info(path)
|
||||
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
|
||||
if "metadata" in instance[0].knobs().keys():
|
||||
if "metadata" in node.knobs().keys():
|
||||
instance[0]["metadata"].setValue("all metadata")
|
||||
|
||||
|
||||
|
|
@ -38,10 +42,16 @@ class ValidateNukeWriteNode(pyblish.api.InstancePlugin):
|
|||
hosts = ["nuke"]
|
||||
|
||||
def process(self, instance):
|
||||
import pype.nuke.lib as nukelib
|
||||
# validate: create_directories, created path, node file knob, version, metadata
|
||||
# TODO: colorspace, dataflow from presets
|
||||
node = instance[0]
|
||||
render_path = nukelib.get_render_path(node).replace("\\", "/")
|
||||
self.log.info("render_path: {}".format(render_path))
|
||||
|
||||
msg_file = "path is not correct"
|
||||
assert node['file'].value() is render_path, msg_file
|
||||
|
||||
# Validate output directory exists, if not creating directories.
|
||||
# The existence of the knob is queried because previous version
|
||||
# of Nuke did not have this feature.
|
||||
if "create_directories" in instance[0].knobs():
|
||||
msg = "Use Create Directories"
|
||||
assert instance[0].knobs()['create_directories'].value() is True, msg
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue