From e2711e9f90db6646021e2ba3c3c0190273668211 Mon Sep 17 00:00:00 2001 From: MaximumFX Date: Mon, 15 Jan 2024 10:56:03 +0100 Subject: [PATCH 1/4] Fixed missing LOP nodes from get_all_renderman_nodes() --- app.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index dcf16b3..a4d1593 100644 --- a/app.py +++ b/app.py @@ -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" From d131ee7c479420e9a47c25fd1b7cfddeacbd52c3 Mon Sep 17 00:00:00 2001 From: MaximumFX Date: Mon, 15 Jan 2024 11:18:43 +0100 Subject: [PATCH 2/4] Added batch name to job info --- info.yml | 6 ++++ python/tk_houdini_renderman/farm_dialog.py | 34 +++++++++++++--------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/info.yml b/info.yml index e9ebb1e..5aa120e 100644 --- a/info.yml +++ b/info.yml @@ -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_" diff --git a/python/tk_houdini_renderman/farm_dialog.py b/python/tk_houdini_renderman/farm_dialog.py index 895ad11..1fd3f8e 100644 --- a/python/tk_houdini_renderman/farm_dialog.py +++ b/python/tk_houdini_renderman/farm_dialog.py @@ -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(): From a0b1f66f903b7edd53d071c5b28877f7836af146 Mon Sep 17 00:00:00 2001 From: MaximumFX Date: Mon, 15 Jan 2024 11:24:28 +0100 Subject: [PATCH 3/4] Added used publish version metadata --- python/tk_houdini_renderman/handler.py | 99 ++++++++++++++++++++------ 1 file changed, 76 insertions(+), 23 deletions(-) diff --git a/python/tk_houdini_renderman/handler.py b/python/tk_houdini_renderman/handler.py index a01ae56..64eb5bd 100644 --- a/python/tk_houdini_renderman/handler.py +++ b/python/tk_houdini_renderman/handler.py @@ -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])}" ) @@ -589,22 +641,24 @@ def setup_aovs(self, node: hou.Node, show_notification: bool = True) -> bool: node_md.parm("metadata_entries").set(0) node_md.parm("metadata_entries").set(len(md_items)) - for i, item in enumerate(md_items): - item: MetaData + for i, published_item in enumerate(md_items): + published_item: MetaData - node_md.parm(f"metadata_{i + 1}_key").set(item.key) - node_md.parm(f"metadata_{i + 1}_type").set(item.type) - if "`" in item.value: - expression = item.value[1:-1] + node_md.parm(f"metadata_{i + 1}_key").set(published_item.key) + node_md.parm(f"metadata_{i + 1}_type").set(published_item.type) + if "`" in published_item.value: + expression = published_item.value[1:-1] expression = re.sub( r"(ch[a-z]*)(\()([\"'])", r"\1(\3../", expression ) - node_md.parm(f"metadata_{i + 1}_{item.type}").setExpression( - expression - ) + node_md.parm( + f"metadata_{i + 1}_{published_item.type}" + ).setExpression(expression) else: - node_md.parm(f"metadata_{i + 1}_{item.type}").set(item.value) + node_md.parm(f"metadata_{i + 1}_{published_item.type}").set( + published_item.value + ) else: rman = node.node("render") rman.parm("ri_displays").set(0) @@ -693,24 +747,26 @@ def setup_aovs(self, node: hou.Node, show_notification: bool = True) -> bool: node_md.parm(f"ri_image_Artist_{i}").set(md_artist) - for j, item in enumerate(md_items): - item: MetaData + for j, published_item in enumerate(md_items): + published_item: MetaData - node_md.parm(f"ri_exr_metadata_key_{i}_{j}").set(item.key) - node_md.parm(f"ri_exr_metadata_type_{i}_{j}").set(item.type) - if "`" in item.value: - expression = item.value[1:-1] + node_md.parm(f"ri_exr_metadata_key_{i}_{j}").set(published_item.key) + node_md.parm(f"ri_exr_metadata_type_{i}_{j}").set( + published_item.type + ) + if "`" in published_item.value: + expression = published_item.value[1:-1] expression = re.sub( r"(ch[a-z]*)(\()([\"'])", r"\1(\3../", expression ) node_md.parm( - f"ri_exr_metadata_{item.type}_{i}_{j}_" + f"ri_exr_metadata_{published_item.type}_{i}_{j}_" ).setExpression(expression) else: - node_md.parm(f"ri_exr_metadata_{item.type}_{i}_{j}_").set( - item.value - ) + node_md.parm( + f"ri_exr_metadata_{published_item.type}_{i}_{j}_" + ).set(published_item.value) msg = f"Setup AOVs complete with {len(active_files)} files." if show_notification: @@ -796,15 +852,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: From fe6dee31789b9acb9ff03bedf42749573f2c5f2c Mon Sep 17 00:00:00 2001 From: MaximumFX Date: Mon, 15 Jan 2024 13:16:18 +0100 Subject: [PATCH 4/4] Fix out of context rename of item to published_item --- python/tk_houdini_renderman/handler.py | 44 ++++++++++++-------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/python/tk_houdini_renderman/handler.py b/python/tk_houdini_renderman/handler.py index 64eb5bd..a7f2865 100644 --- a/python/tk_houdini_renderman/handler.py +++ b/python/tk_houdini_renderman/handler.py @@ -641,24 +641,22 @@ def setup_aovs(self, node: hou.Node, show_notification: bool = True) -> bool: node_md.parm("metadata_entries").set(0) node_md.parm("metadata_entries").set(len(md_items)) - for i, published_item in enumerate(md_items): - published_item: MetaData + for i, item in enumerate(md_items): + item: MetaData - node_md.parm(f"metadata_{i + 1}_key").set(published_item.key) - node_md.parm(f"metadata_{i + 1}_type").set(published_item.type) - if "`" in published_item.value: - expression = published_item.value[1:-1] + node_md.parm(f"metadata_{i + 1}_key").set(item.key) + node_md.parm(f"metadata_{i + 1}_type").set(item.type) + if "`" in item.value: + expression = item.value[1:-1] expression = re.sub( r"(ch[a-z]*)(\()([\"'])", r"\1(\3../", expression ) - node_md.parm( - f"metadata_{i + 1}_{published_item.type}" - ).setExpression(expression) - else: - node_md.parm(f"metadata_{i + 1}_{published_item.type}").set( - published_item.value + node_md.parm(f"metadata_{i + 1}_{item.type}").setExpression( + expression ) + else: + node_md.parm(f"metadata_{i + 1}_{item.type}").set(item.value) else: rman = node.node("render") rman.parm("ri_displays").set(0) @@ -747,26 +745,24 @@ def setup_aovs(self, node: hou.Node, show_notification: bool = True) -> bool: node_md.parm(f"ri_image_Artist_{i}").set(md_artist) - for j, published_item in enumerate(md_items): - published_item: MetaData + for j, item in enumerate(md_items): + item: MetaData - node_md.parm(f"ri_exr_metadata_key_{i}_{j}").set(published_item.key) - node_md.parm(f"ri_exr_metadata_type_{i}_{j}").set( - published_item.type - ) - if "`" in published_item.value: - expression = published_item.value[1:-1] + node_md.parm(f"ri_exr_metadata_key_{i}_{j}").set(item.key) + node_md.parm(f"ri_exr_metadata_type_{i}_{j}").set(item.type) + if "`" in item.value: + expression = item.value[1:-1] expression = re.sub( r"(ch[a-z]*)(\()([\"'])", r"\1(\3../", expression ) node_md.parm( - f"ri_exr_metadata_{published_item.type}_{i}_{j}_" + f"ri_exr_metadata_{item.type}_{i}_{j}_" ).setExpression(expression) else: - node_md.parm( - f"ri_exr_metadata_{published_item.type}_{i}_{j}_" - ).set(published_item.value) + node_md.parm(f"ri_exr_metadata_{item.type}_{i}_{j}_").set( + item.value + ) msg = f"Setup AOVs complete with {len(active_files)} files." if show_notification: