Skip to content

Commit

Permalink
Merge pull request #11 from nfa-vfxim/dev
Browse files Browse the repository at this point in the history
Update from dev
  • Loading branch information
MaximumFX committed Jan 15, 2024
2 parents da7dc48 + 9e30c6d commit 11a5401
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 17 deletions.
4 changes: 3 additions & 1 deletion app.py
Expand Up @@ -78,7 +78,9 @@ def copy_to_clipboard(self, node, network=None):
@staticmethod
def get_all_renderman_nodes() -> tuple[Node]:
"""Get all nodes from node type sgtk_hdprman"""
return hou.ropNodeTypeCategory().nodeType("sgtk_ris").instances()
rop_nodes = hou.ropNodeTypeCategory().nodeType("sgtk_ris").instances()
lop_nodes = hou.lopNodeTypeCategory().nodeType("sgtk_ris").instances()
return rop_nodes + lop_nodes

def get_output_path(
self, node: hou.Node, aov_name: str, network: str = "rop"
Expand Down
6 changes: 6 additions & 0 deletions info.yml
Expand Up @@ -31,6 +31,12 @@ configuration:
fields: context, version, SEQ, [aov_name], [name], [width], [height], *
description: A template which describes the output of the render.

deadline_batch_name:
type: template
fields: context, *
allows_empty: True
description: A template which describes the current Houdini work hip file. Used to fetch version.

render_metadata:
type: list
description: A list of Render Metadata (RMD) to add to the renders. The key will be prefixed with "rmd_"
Expand Down
34 changes: 21 additions & 13 deletions python/tk_houdini_renderman/farm_dialog.py
Expand Up @@ -168,36 +168,44 @@ def __submit_to_farm(self):

deadline_path = os.getenv("DEADLINE_PATH")

post_task_script = self.app.get_setting("post_task_script")

# Building job info properties
job_info = [
"Plugin=Houdini",
"Frames=" + framerange,
"Priority=" + priority,
"ConcurrentTasks=" + concurrent_tasks,
"ChunkSize=" + str(frames_per_task),
"Name=" + submission_name,
f"Frames={framerange}",
f"Priority={priority}",
f"ConcurrentTasks={concurrent_tasks}",
f"ChunkSize={frames_per_task}",
f"Name={submission_name}",
"Department=3D",
"EnvironmentKeyValue0 = RENDER_ENGINE = RenderMan",
]

# Batch name
batch_name_template = self.app.get_template("deadline_batch_name")
if batch_name_template:
work_template = self.app.get_template("work_file_template")
fields = work_template.get_fields(hou.hipFile.path())
batch_name = batch_name_template.apply_fields(fields)
job_info.append(f"BatchName={batch_name}")

# TODO create post task script for lop denoise renders
post_task_script = self.app.get_setting("post_task_script")

if self.network == "rop" and post_task_script:
job_info.append("PostTaskScript=" + post_task_script)
job_info.append(f"PostTaskScript={post_task_script}")

for i, path in enumerate(self.render_paths):
output_directory = os.path.dirname(path)
job_info.append("OutputDirectory{}={}".format(i, output_directory))
job_info.append(f"OutputDirectory{i}={output_directory}")
if not path.endswith("denoise"):
output_filename = os.path.basename(path).replace("$F4", "%04d")
job_info.append("OutputFilename{}={}".format(i, output_filename))
job_info.append(f"OutputFilename{i}={output_filename}")

# Building plugin info properties
plugin_info = [
"OutputDriver=" + render_rop_node,
"Version=" + houdini_version,
"SceneFile=" + houdini_file,
f"OutputDriver={render_rop_node}",
f"Version={houdini_version}",
f"SceneFile={houdini_file}",
]
# Save the file before submitting
if hou.hipFile.hasUnsavedChanges():
Expand Down
55 changes: 52 additions & 3 deletions python/tk_houdini_renderman/handler.py
Expand Up @@ -429,6 +429,58 @@ def setup_aovs(self, node: hou.Node, show_notification: bool = True) -> bool:

md_artist = str(self.app.context.user["id"])

# Metadata get used publish versions
current_engine = sgtk.platform.current_engine()
breakdown_app = current_engine.apps["tk-multi-breakdown"]

if breakdown_app:
self.app.logger.debug(
"Getting used publish versions with tk-multi-breakdown."
)

used_versions = []

# Get list of breakdown items
published_items = breakdown_app.analyze_scene()

# Now loop over all items
for published_item in published_items:
# Get the latest version on disk
latest_version = breakdown_app.compute_highest_version(
published_item["template"], published_item["fields"]
)

fields = published_item["fields"]
entity_type = published_item["sg_data"]["entity"]["type"]

version = {
"version": published_item["sg_data"]["version_number"],
"latest_version": latest_version,
"type": entity_type,
}

if entity_type == "Shot":
version[
"name"
] = f"{fields['Sequence']} {fields['Shot']} {fields['Step']} {fields['name']}"
elif entity_type == "Asset":
version[
"name"
] = f"{fields['Asset']} {fields['Step']} {fields['name']}"
else:
version["name"] = "Undefined"

used_versions.append(version)

md_items.append(
MetaData("rmd_UsedPublishVersions", "string", json.dumps(used_versions))
)

else:
self.app.logger.debug(
"The app tk-multi-breakdown is not installed, skipping used publish version metadata."
)

self.app.logger.debug(
f"Setting up aovs for files: {', '.join([file.identifier.value for file in active_files])}"
)
Expand Down Expand Up @@ -796,15 +848,12 @@ def get_output_path(self, node: hou.Node, aov_name: str) -> str:
def get_output_paths(self, node: hou.Node) -> list[str]:
paths = []

print(node.path())

try:
output_files, active_files = self.get_active_files(node)
for file in active_files:
file: aov_file.OutputFile
if file.identifier == aov_file.OutputIdentifier.CRYPTOMATTE:
for crypto in file.options:
print(crypto.key)
if node.parm(crypto.key).eval():
paths.append(self.get_output_path(node, crypto.key))
else:
Expand Down

0 comments on commit 11a5401

Please sign in to comment.