Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Houdini: Fix single frame publishes #675

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -60,7 +60,7 @@ def process(self, instance):

# todo: `frames` currently conflicts with "explicit frames" for a
# for a custom frame list. So this should be refactored.
instance.data.update({"frames": result})
instance.data["frames"] = result

@staticmethod
def create_file_list(match, start_frame, end_frame):
Expand Down
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,15 @@ 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 All @@ -39,7 +37,7 @@ def process(self, instance):
representation = {
"name": ext,
"ext": ext,
"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 @@ -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