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" 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(): diff --git a/python/tk_houdini_renderman/handler.py b/python/tk_houdini_renderman/handler.py index a01ae56..a7f2865 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])}" ) @@ -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: