Skip to content

Commit

Permalink
Support single frame publishes - fix #672
Browse files Browse the repository at this point in the history
  • Loading branch information
BigRoy committed Jun 19, 2024
1 parent 506c997 commit fbcd56e
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 51 deletions.
20 changes: 20 additions & 0 deletions server_addon/houdini/client/ayon_houdini/api/plugin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
"""Houdini specific Avalon/Pyblish plugin definitions."""
import os
import sys
from abc import (
ABCMeta
Expand Down Expand Up @@ -392,3 +393,22 @@ class HoudiniExtractorPlugin(publish.Extractor):

hosts = ["houdini"]
settings_category = SETTINGS_CATEGORY

def validate_expected_frames(self, instance, staging_dir):
"""
Validate all expected files in `instance.data["frames"]` exist in
the staging directory.
"""
filenames = instance.data["frames"]
if isinstance(filenames, str):
# Single frame
filenames = [filenames]

missing_filenames = []
for filename in filenames:
path = os.path.join(staging_dir, filename)
if not os.path.isfile(path):
missing_filenames.append(filename)
if missing_filenames:
raise RuntimeError(f"Missing frames: {missing_filenames}")

Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,8 @@ def process(self, instance):
staging_dir = os.path.dirname(output)
instance.data["stagingDir"] = staging_dir

if instance.data.get("frames"):
# list of files
files = instance.data["frames"]
else:
# single file
files = os.path.basename(output)

# We run the render
self.log.info("Writing alembic '%s' to '%s'" % (files,
self.log.info("Writing alembic '%s' to '%s'" % (output,
staging_dir))

render_rop(ropnode)
Expand All @@ -45,7 +38,7 @@ def process(self, instance):
representation = {
'name': 'abc',
'ext': 'abc',
'files': files,
'files': instance.data["frames"],
"stagingDir": staging_dir,
}
instance.data["representations"].append(representation)
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,7 @@ def process(self, instance):
# Unfortunately user interrupting the extraction does not raise an
# error and thus still continues to the integrator. To capture that
# we make sure all files exist
files = instance.data["frames"]
missing = []
for file_name in files:
full_path = os.path.normpath(os.path.join(staging_dir, file_name))
if not os.path.exists(full_path):
missing.append(full_path)

if missing:
raise RuntimeError("Failed to complete Arnold ass extraction. "
"Missing output files: {}".format(missing))
self.validate_expected_frames(instance, staging_dir)

if "representations" not in instance.data:
instance.data["representations"] = []
Expand All @@ -55,7 +46,7 @@ def process(self, instance):
representation = {
'name': 'ass',
'ext': ext,
"files": files,
"files": instance.data["frames"],
"stagingDir": staging_dir,
"frameStart": instance.data["frameStartHandle"],
"frameEnd": instance.data["frameEndHandle"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def process(self, instance):
ropnode = hou.node(instance.data["instance_node"])

# Get the filename from the filename parameter
output = ropnode.evalParm("sopoutput")
staging_dir, file_name = os.path.split(output)
sop_output = ropnode.evalParm("sopoutput")
staging_dir, file_name = os.path.split(sop_output)
instance.data["stagingDir"] = staging_dir

# We run the render
Expand All @@ -30,10 +30,8 @@ def process(self, instance):
# write files
lib.render_rop(ropnode)

output = instance.data["frames"]

_, ext = lib.splitext(
output[0], allowed_multidot_extensions=[
sop_output, allowed_multidot_extensions=[
".ass.gz", ".bgeo.sc", ".bgeo.gz",
".bgeo.lzma", ".bgeo.bz2"])

Expand All @@ -43,7 +41,7 @@ def process(self, instance):
representation = {
"name": "bgeo",
"ext": ext.lstrip("."),
"files": output,
"files": instance.data["frames"],
"stagingDir": staging_dir,
"frameStart": instance.data["frameStartHandle"],
"frameEnd": instance.data["frameEndHandle"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@ def process(self, instance):

# Get the filename from the copoutput parameter
# `.evalParm(parameter)` will make sure all tokens are resolved
output = ropnode.evalParm("copoutput")
staging_dir = os.path.dirname(output)
cop_output = ropnode.evalParm("copoutput")
staging_dir, file_name = os.path.split(cop_output)
instance.data["stagingDir"] = staging_dir
file_name = os.path.basename(output)

self.log.info("Writing comp '%s' to '%s'" % (file_name, staging_dir))

render_rop(ropnode)

output = instance.data["frames"]
_, ext = splitext(output[0], [])
_, ext = splitext(file_name, [])
ext = ext.lstrip(".")

if "representations" not in instance.data:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,15 @@ def process(self, instance):
staging_dir = os.path.dirname(output)
instance.data["stagingDir"] = staging_dir

files = instance.data["frames"]
missing_frames = [
frame
for frame in instance.data["frames"]
if not os.path.exists(
os.path.normpath(os.path.join(staging_dir, frame)))
]
if missing_frames:
raise RuntimeError("Failed to complete Mantra ifd extraction. "
"Missing output files: {}".format(
missing_frames))
self.validate_expected_frames(instance, staging_dir)

if "representations" not in instance.data:
instance.data["representations"] = []

representation = {
'name': 'ifd',
'ext': 'ifd',
'files': files,
'files': instance.data["frames"],
"stagingDir": staging_dir,
"frameStart": instance.data["frameStart"],
"frameEnd": instance.data["frameEnd"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,14 @@ def process(self, instance):

render_rop(ropnode)

output = instance.data["frames"]

tags = ["review"]
if not instance.data.get("keepImages"):
tags.append("delete")

representation = {
"name": instance.data["imageFormat"],
"ext": instance.data["imageFormat"],
"files": output,
"files": instance.data["frames"],
"stagingDir": staging_dir,
"frameStart": instance.data["frameStartHandle"],
"frameEnd": instance.data["frameEndHandle"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,13 @@ def process(self, instance):

render_rop(ropnode)

output = instance.data["frames"]

if "representations" not in instance.data:
instance.data["representations"] = []

representation = {
"name": "rs",
"ext": "rs",
"files": output,
"files": instance.data["frames"],
"stagingDir": staging_dir,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@ def process(self, instance):

render_rop(ropnode)

output = instance.data["frames"]

if "representations" not in instance.data:
instance.data["representations"] = []

representation = {
"name": "vdb",
"ext": "vdb",
"files": output,
"files": instance.data["frames"],
"stagingDir": staging_dir,
"frameStart": instance.data["frameStartHandle"],
"frameEnd": instance.data["frameEndHandle"],
Expand Down

0 comments on commit fbcd56e

Please sign in to comment.