mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
Merge pull request #1344 from pypeclub/bugfix/nuke-families-issue-validator-images
Nuke: freschdesk ticket v2
This commit is contained in:
commit
a02c63d2e7
3 changed files with 78 additions and 58 deletions
|
|
@ -55,11 +55,6 @@ class PreCollectNukeInstances(pyblish.api.ContextPlugin):
|
|||
families_ak = avalon_knob_data.get("families", [])
|
||||
families = list()
|
||||
|
||||
if families_ak:
|
||||
families.append(families_ak.lower())
|
||||
|
||||
families.append(family)
|
||||
|
||||
# except disabled nodes but exclude backdrops in test
|
||||
if ("nukenodes" not in family) and (node["disable"].value()):
|
||||
continue
|
||||
|
|
@ -81,36 +76,33 @@ class PreCollectNukeInstances(pyblish.api.ContextPlugin):
|
|||
# Add all nodes in group instances.
|
||||
if node.Class() == "Group":
|
||||
# only alter families for render family
|
||||
if "write" in families_ak:
|
||||
if "write" in families_ak.lower():
|
||||
target = node["render"].value()
|
||||
if target == "Use existing frames":
|
||||
# Local rendering
|
||||
self.log.info("flagged for no render")
|
||||
families.append(family)
|
||||
elif target == "Local":
|
||||
# Local rendering
|
||||
self.log.info("flagged for local render")
|
||||
families.append("{}.local".format(family))
|
||||
family = families_ak.lower()
|
||||
elif target == "On farm":
|
||||
# Farm rendering
|
||||
self.log.info("flagged for farm render")
|
||||
instance.data["transfer"] = False
|
||||
families.append("{}.farm".format(family))
|
||||
|
||||
# suffle family to `write` as it is main family
|
||||
# this will be changed later on in process
|
||||
if "render" in families:
|
||||
families.remove("render")
|
||||
family = "write"
|
||||
elif "prerender" in families:
|
||||
families.remove("prerender")
|
||||
family = "write"
|
||||
family = families_ak.lower()
|
||||
|
||||
node.begin()
|
||||
for i in nuke.allNodes():
|
||||
instance.append(i)
|
||||
node.end()
|
||||
|
||||
if not families and families_ak and family not in [
|
||||
"render", "prerender"]:
|
||||
families.append(families_ak.lower())
|
||||
|
||||
self.log.debug("__ family: `{}`".format(family))
|
||||
self.log.debug("__ families: `{}`".format(families))
|
||||
|
||||
# Get format
|
||||
|
|
@ -124,7 +116,9 @@ class PreCollectNukeInstances(pyblish.api.ContextPlugin):
|
|||
anlib.add_publish_knob(node)
|
||||
|
||||
# sync workfile version
|
||||
if not next((f for f in families
|
||||
_families_test = [family] + families
|
||||
self.log.debug("__ _families_test: `{}`".format(_families_test))
|
||||
if not next((f for f in _families_test
|
||||
if "prerender" in f),
|
||||
None) and self.sync_workfile_version:
|
||||
# get version to instance for integration
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
import re
|
||||
import nuke
|
||||
import pyblish.api
|
||||
import openpype.api as pype
|
||||
|
|
@ -14,11 +15,8 @@ class CollectNukeWrites(pyblish.api.InstancePlugin):
|
|||
hosts = ["nuke", "nukeassist"]
|
||||
families = ["write"]
|
||||
|
||||
# preset attributes
|
||||
sync_workfile_version = True
|
||||
|
||||
def process(self, instance):
|
||||
families = instance.data["families"]
|
||||
_families_test = [instance.data["family"]] + instance.data["families"]
|
||||
|
||||
node = None
|
||||
for x in instance:
|
||||
|
|
@ -63,7 +61,7 @@ class CollectNukeWrites(pyblish.api.InstancePlugin):
|
|||
int(last_frame)
|
||||
)
|
||||
|
||||
if [fm for fm in families
|
||||
if [fm for fm in _families_test
|
||||
if fm in ["render", "prerender"]]:
|
||||
if "representations" not in instance.data:
|
||||
instance.data["representations"] = list()
|
||||
|
|
@ -91,9 +89,9 @@ class CollectNukeWrites(pyblish.api.InstancePlugin):
|
|||
collected_frames_len))
|
||||
# this will only run if slate frame is not already
|
||||
# rendered from previews publishes
|
||||
if "slate" in instance.data["families"] \
|
||||
if "slate" in _families_test \
|
||||
and (frame_length == collected_frames_len) \
|
||||
and ("prerender" not in instance.data["families"]):
|
||||
and ("prerender" not in _families_test):
|
||||
frame_slate_str = "%0{}d".format(
|
||||
len(str(last_frame))) % (first_frame - 1)
|
||||
slate_frame = collected_frames[0].replace(
|
||||
|
|
@ -107,10 +105,17 @@ class CollectNukeWrites(pyblish.api.InstancePlugin):
|
|||
self.log.debug("couldn't collect frames: {}".format(label))
|
||||
|
||||
# Add version data to instance
|
||||
colorspace = node["colorspace"].value()
|
||||
|
||||
# remove default part of the string
|
||||
if "default (" in colorspace:
|
||||
colorspace = re.sub(r"default.\(|\)", "", colorspace)
|
||||
self.log.debug("colorspace: `{}`".format(colorspace))
|
||||
|
||||
version_data = {
|
||||
"families": [f.replace(".local", "").replace(".farm", "")
|
||||
for f in families if "write" not in f],
|
||||
"colorspace": node["colorspace"].value(),
|
||||
for f in _families_test if "write" not in f],
|
||||
"colorspace": colorspace
|
||||
}
|
||||
|
||||
group_node = [x for x in instance if x.Class() == "Group"][0]
|
||||
|
|
@ -135,13 +140,12 @@ class CollectNukeWrites(pyblish.api.InstancePlugin):
|
|||
"frameStartHandle": first_frame,
|
||||
"frameEndHandle": last_frame,
|
||||
"outputType": output_type,
|
||||
"families": families,
|
||||
"colorspace": node["colorspace"].value(),
|
||||
"colorspace": colorspace,
|
||||
"deadlineChunkSize": deadlineChunkSize,
|
||||
"deadlinePriority": deadlinePriority
|
||||
})
|
||||
|
||||
if "prerender" in families:
|
||||
if "prerender" in _families_test:
|
||||
instance.data.update({
|
||||
"family": "prerender",
|
||||
"families": []
|
||||
|
|
@ -166,6 +170,4 @@ class CollectNukeWrites(pyblish.api.InstancePlugin):
|
|||
"filename": api.get_representation_path(repre_doc)
|
||||
}]
|
||||
|
||||
self.log.debug("families: {}".format(families))
|
||||
|
||||
self.log.debug("instance.data: {}".format(instance.data))
|
||||
|
|
|
|||
|
|
@ -5,23 +5,50 @@ import clique
|
|||
|
||||
|
||||
@pyblish.api.log
|
||||
class RepairCollectionAction(pyblish.api.Action):
|
||||
label = "Repair"
|
||||
class RepairActionBase(pyblish.api.Action):
|
||||
on = "failed"
|
||||
icon = "wrench"
|
||||
|
||||
@staticmethod
|
||||
def get_instance(context, plugin):
|
||||
# Get the errored instances
|
||||
failed = []
|
||||
for result in context.data["results"]:
|
||||
if (result["error"] is not None and result["instance"] is not None
|
||||
and result["instance"] not in failed):
|
||||
failed.append(result["instance"])
|
||||
|
||||
# Apply pyblish.logic to get the instances for the plug-in
|
||||
return pyblish.api.instances_by_plugin(failed, plugin)
|
||||
|
||||
def repair_knob(self, instances, state):
|
||||
for instance in instances:
|
||||
files_remove = [os.path.join(instance.data["outputDir"], f)
|
||||
for r in instance.data.get("representations", [])
|
||||
for f in r.get("files", [])
|
||||
]
|
||||
self.log.info("Files to be removed: {}".format(files_remove))
|
||||
for f in files_remove:
|
||||
os.remove(f)
|
||||
self.log.debug("removing file: {}".format(f))
|
||||
instance[0]["render"].setValue(state)
|
||||
self.log.info("Rendering toggled to `{}`".format(state))
|
||||
|
||||
|
||||
class RepairCollectionActionToLocal(RepairActionBase):
|
||||
label = "Repair > rerender with `Local` machine"
|
||||
|
||||
def process(self, context, plugin):
|
||||
self.log.info(context[0][0])
|
||||
files_remove = [os.path.join(context[0].data["outputDir"], f)
|
||||
for r in context[0].data.get("representations", [])
|
||||
for f in r.get("files", [])
|
||||
]
|
||||
self.log.info("Files to be removed: {}".format(files_remove))
|
||||
for f in files_remove:
|
||||
os.remove(f)
|
||||
self.log.debug("removing file: {}".format(f))
|
||||
context[0][0]["render"].setValue(True)
|
||||
self.log.info("Rendering toggled ON")
|
||||
instances = self.get_instance(context, plugin)
|
||||
self.repair_knob(instances, "Local")
|
||||
|
||||
|
||||
class RepairCollectionActionToFarm(RepairActionBase):
|
||||
label = "Repair > rerender `On farm` with remote machines"
|
||||
|
||||
def process(self, context, plugin):
|
||||
instances = self.get_instance(context, plugin)
|
||||
self.repair_knob(instances, "On farm")
|
||||
|
||||
|
||||
class ValidateRenderedFrames(pyblish.api.InstancePlugin):
|
||||
|
|
@ -32,26 +59,28 @@ class ValidateRenderedFrames(pyblish.api.InstancePlugin):
|
|||
|
||||
label = "Validate rendered frame"
|
||||
hosts = ["nuke", "nukestudio"]
|
||||
actions = [RepairCollectionAction]
|
||||
actions = [RepairCollectionActionToLocal, RepairCollectionActionToFarm]
|
||||
|
||||
|
||||
def process(self, instance):
|
||||
|
||||
for repre in instance.data.get('representations'):
|
||||
for repre in instance.data["representations"]:
|
||||
|
||||
if not repre.get('files'):
|
||||
if not repre.get("files"):
|
||||
msg = ("no frames were collected, "
|
||||
"you need to render them")
|
||||
self.log.error(msg)
|
||||
raise ValidationException(msg)
|
||||
|
||||
collections, remainder = clique.assemble(repre["files"])
|
||||
self.log.info('collections: {}'.format(str(collections)))
|
||||
self.log.info('remainder: {}'.format(str(remainder)))
|
||||
self.log.info("collections: {}".format(str(collections)))
|
||||
self.log.info("remainder: {}".format(str(remainder)))
|
||||
|
||||
collection = collections[0]
|
||||
|
||||
frame_length = int(
|
||||
instance.data["frameEndHandle"] - instance.data["frameStartHandle"] + 1
|
||||
instance.data["frameEndHandle"]
|
||||
- instance.data["frameStartHandle"] + 1
|
||||
)
|
||||
|
||||
if frame_length != 1:
|
||||
|
|
@ -65,15 +94,10 @@ class ValidateRenderedFrames(pyblish.api.InstancePlugin):
|
|||
self.log.error(msg)
|
||||
raise ValidationException(msg)
|
||||
|
||||
# if len(remainder) != 0:
|
||||
# msg = "There are some extra files in folder"
|
||||
# self.log.error(msg)
|
||||
# raise ValidationException(msg)
|
||||
|
||||
collected_frames_len = int(len(collection.indexes))
|
||||
self.log.info('frame_length: {}'.format(frame_length))
|
||||
self.log.info("frame_length: {}".format(frame_length))
|
||||
self.log.info(
|
||||
'len(collection.indexes): {}'.format(collected_frames_len)
|
||||
"len(collection.indexes): {}".format(collected_frames_len)
|
||||
)
|
||||
|
||||
if ("slate" in instance.data["families"]) \
|
||||
|
|
@ -84,6 +108,6 @@ class ValidateRenderedFrames(pyblish.api.InstancePlugin):
|
|||
"{} missing frames. Use repair to render all frames"
|
||||
).format(__name__)
|
||||
|
||||
instance.data['collection'] = collection
|
||||
instance.data["collection"] = collection
|
||||
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue