From 058fcb97a358a972d34a4cabd45773e249e15cf0 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 9 Jun 2023 17:51:54 +0800 Subject: [PATCH 001/104] multiple render camera supports for 3dsmax --- openpype/hosts/max/api/lib_rendersettings.py | 11 ++-------- .../hosts/max/plugins/create/create_render.py | 22 ++++++++++++++----- .../max/plugins/publish/collect_render.py | 5 +++++ .../plugins/publish/submit_max_deadline.py | 11 ++++++++++ 4 files changed, 34 insertions(+), 15 deletions(-) diff --git a/openpype/hosts/max/api/lib_rendersettings.py b/openpype/hosts/max/api/lib_rendersettings.py index 91e4a5bf9b..db8dee3340 100644 --- a/openpype/hosts/max/api/lib_rendersettings.py +++ b/openpype/hosts/max/api/lib_rendersettings.py @@ -35,15 +35,8 @@ class RenderSettings(object): ) def set_render_camera(self, selection): - for sel in selection: - # to avoid Attribute Error from pymxs wrapper - found = False - if rt.classOf(sel) in rt.Camera.classes: - found = True - rt.viewport.setCamera(sel) - break - if not found: - raise RuntimeError("Camera not found") + # to avoid Attribute Error from pymxs wrapper + return rt.viewport.setCamera(selection[0]) def render_output(self, container): folder = rt.maxFilePath diff --git a/openpype/hosts/max/plugins/create/create_render.py b/openpype/hosts/max/plugins/create/create_render.py index 5ad895b86e..ec5635b81b 100644 --- a/openpype/hosts/max/plugins/create/create_render.py +++ b/openpype/hosts/max/plugins/create/create_render.py @@ -14,7 +14,10 @@ class CreateRender(plugin.MaxCreator): def create(self, subset_name, instance_data, pre_create_data): from pymxs import runtime as rt - sel_obj = list(rt.selection) + sel_obj = [ + c for c in rt.Objects + if rt.classOf(c) in rt.Camera.classes] + file = rt.maxFileName filename, _ = os.path.splitext(file) instance_data["AssetName"] = filename @@ -24,11 +27,20 @@ class CreateRender(plugin.MaxCreator): instance_data, pre_create_data) # type: CreatedInstance container_name = instance.data.get("instance_node") - container = rt.getNodeByName(container_name) # TODO: Disable "Add to Containers?" Panel # parent the selected cameras into the container - for obj in sel_obj: - obj.parent = container + if self.selected_nodes: + # set viewport camera for + # rendering(mandatory for deadline) + sel_obj = [ + c for c in rt.getCurrentSelection() + if rt.classOf(c) in rt.Camera.classes] + + if not sel_obj: + raise RuntimeError("Please add at least one camera to the scene " + "before creating the render instance") + + RenderSettings().set_render_camera(sel_obj) # for additional work on the node: # instance_node = rt.getNodeByName(instance.get("instance_node")) @@ -37,7 +49,5 @@ class CreateRender(plugin.MaxCreator): # Changing the Render Setup dialog settings should be done # with the actual Render Setup dialog in a closed state. - # set viewport camera for rendering(mandatory for deadline) - RenderSettings().set_render_camera(sel_obj) # set output paths for rendering(mandatory for deadline) RenderSettings().render_output(container_name) diff --git a/openpype/hosts/max/plugins/publish/collect_render.py b/openpype/hosts/max/plugins/publish/collect_render.py index db5c84fad9..cbb3a7b4d6 100644 --- a/openpype/hosts/max/plugins/publish/collect_render.py +++ b/openpype/hosts/max/plugins/publish/collect_render.py @@ -48,6 +48,10 @@ class CollectRender(pyblish.api.InstancePlugin): instance.name, asset_id) self.log.debug("version_doc: {0}".format(version_doc)) + sel_obj = [ + c for c in rt.Objects + if rt.classOf(c) in rt.Camera.classes] + version_int = 1 if version_doc: version_int += int(version_doc["name"]) @@ -78,6 +82,7 @@ class CollectRender(pyblish.api.InstancePlugin): "renderer": renderer, "source": filepath, "plugin": "3dsmax", + "cameras": sel_obj, "frameStart": int(rt.rendStart), "frameEnd": int(rt.rendEnd), "version": version_int, diff --git a/openpype/modules/deadline/plugins/publish/submit_max_deadline.py b/openpype/modules/deadline/plugins/publish/submit_max_deadline.py index b6a30e36b7..ff5adc39ad 100644 --- a/openpype/modules/deadline/plugins/publish/submit_max_deadline.py +++ b/openpype/modules/deadline/plugins/publish/submit_max_deadline.py @@ -212,6 +212,17 @@ class MaxSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline, plugin_data["RenderOutput"] = beauty_name # as 3dsmax has version with different languages plugin_data["Language"] = "ENU" + render_cameras = instance.data["cameras"] + if render_cameras: + for i, camera in enumerate(render_cameras): + cam_name = "Camera%s" % (i + 1) + plugin_data[cam_name] = camera.name + # set the default camera + plugin_data["Camera"] = render_cameras[0].name + # set empty camera of Camera 0 for the ' + # correct parameter submission + plugin_data["Camera0"] = None + renderer_class = get_current_renderer() renderer = str(renderer_class).split(":")[0] From 5fc037880fa7ddee5c65d63679d1db2810469411 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Mon, 19 Jun 2023 17:33:16 +0800 Subject: [PATCH 002/104] refactor the collector and deadline for multiple camera --- openpype/hosts/max/plugins/publish/collect_render.py | 2 +- .../modules/deadline/plugins/publish/submit_max_deadline.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openpype/hosts/max/plugins/publish/collect_render.py b/openpype/hosts/max/plugins/publish/collect_render.py index cbb3a7b4d6..8e39da0fbb 100644 --- a/openpype/hosts/max/plugins/publish/collect_render.py +++ b/openpype/hosts/max/plugins/publish/collect_render.py @@ -49,7 +49,7 @@ class CollectRender(pyblish.api.InstancePlugin): asset_id) self.log.debug("version_doc: {0}".format(version_doc)) sel_obj = [ - c for c in rt.Objects + c.name for c in rt.Objects if rt.classOf(c) in rt.Camera.classes] version_int = 1 diff --git a/openpype/modules/deadline/plugins/publish/submit_max_deadline.py b/openpype/modules/deadline/plugins/publish/submit_max_deadline.py index ff5adc39ad..365be7b07b 100644 --- a/openpype/modules/deadline/plugins/publish/submit_max_deadline.py +++ b/openpype/modules/deadline/plugins/publish/submit_max_deadline.py @@ -216,9 +216,9 @@ class MaxSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline, if render_cameras: for i, camera in enumerate(render_cameras): cam_name = "Camera%s" % (i + 1) - plugin_data[cam_name] = camera.name - # set the default camera - plugin_data["Camera"] = render_cameras[0].name + plugin_data[cam_name] = camera + # set the default camera + plugin_data["Camera"] = camera # set empty camera of Camera 0 for the ' # correct parameter submission plugin_data["Camera0"] = None From 6b716b8ce92d5e0466ecb92c03aad86e920b8217 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 12 Jul 2023 19:16:52 +0800 Subject: [PATCH 003/104] hound fix --- openpype/hosts/max/api/lib_renderproducts.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/openpype/hosts/max/api/lib_renderproducts.py b/openpype/hosts/max/api/lib_renderproducts.py index a1039b9309..45d7d7134d 100644 --- a/openpype/hosts/max/api/lib_renderproducts.py +++ b/openpype/hosts/max/api/lib_renderproducts.py @@ -155,8 +155,8 @@ class RenderProducts(object): for name in render_name: render_dict.update({ name: self.get_expected_render_elements( - output_file, name, start_frame, - end_frame, img_fmt) + output_file, name, start_frame, + end_frame, img_fmt) }) elif renderer == "Redshift_Renderer": render_name = self.get_render_elements_name() @@ -169,15 +169,15 @@ class RenderProducts(object): if name == "RsCryptomatte": render_dict.update({ name: self.get_expected_render_elements( - output_file, name, start_frame, - end_frame, img_fmt) + output_file, name, start_frame, + end_frame, img_fmt) }) else: for name in render_name: render_dict.update({ name: self.get_expected_render_elements( - output_file, name, start_frame, - end_frame, img_fmt) + output_file, name, start_frame, + end_frame, img_fmt) }) elif renderer == "Arnold": @@ -186,7 +186,7 @@ class RenderProducts(object): for name in render_name: render_dict.update({ name: self.get_expected_arnold_product( - output_file, name, start_frame, end_frame, img_fmt) + output_file, name, start_frame, end_frame, img_fmt) }) elif renderer in [ "V_Ray_6_Hotfix_3", @@ -198,8 +198,8 @@ class RenderProducts(object): for name in render_name: render_dict.update({ name: self.get_expected_render_elements( - output_file, name, start_frame, - end_frame, img_fmt) # noqa + output_file, name, start_frame, + end_frame, img_fmt) # noqa }) return render_dict From e96bada178f11d8f24d1036746a3f3e519e95b84 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 12 Jul 2023 19:23:03 +0800 Subject: [PATCH 004/104] hound fix --- openpype/hosts/max/api/lib_renderproducts.py | 44 ++++++++++--------- openpype/hosts/max/api/lib_rendersettings.py | 2 +- .../hosts/max/plugins/create/create_render.py | 2 +- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/openpype/hosts/max/api/lib_renderproducts.py b/openpype/hosts/max/api/lib_renderproducts.py index 45d7d7134d..433214935d 100644 --- a/openpype/hosts/max/api/lib_renderproducts.py +++ b/openpype/hosts/max/api/lib_renderproducts.py @@ -33,6 +33,7 @@ class RenderProducts(object): output_file, start_frame, end_frame, img_fmt ) } + def get_multiple_beauty(self, outputs, cameras): beauty_output_frames = dict() for output, camera in zip(outputs, cameras): @@ -68,9 +69,9 @@ class RenderProducts(object): for name in render_name: aovs_frames.update({ f"{camera}_{name}": ( - self.get_expected_render_elements( - filename, name, start_frame, - end_frame, ext) + self.get_expected_render_elements( + filename, name, start_frame, + end_frame, ext) ) }) elif renderer == "Redshift_Renderer": @@ -84,9 +85,9 @@ class RenderProducts(object): if name == "RsCryptomatte": aovs_frames.update({ f"{camera}_{name}": ( - self.get_expected_render_elements( - filename, name, start_frame, - end_frame, ext) + self.get_expected_render_elements( + filename, name, start_frame, + end_frame, ext) ) }) else: @@ -105,9 +106,9 @@ class RenderProducts(object): for name in render_name: aovs_frames.update({ f"{camera}_{name}": ( - self.get_expected_arnold_product( - filename, name, start_frame, - end_frame, ext) + self.get_expected_arnold_product( + filename, name, start_frame, + end_frame, ext) ) }) elif renderer in [ @@ -120,9 +121,9 @@ class RenderProducts(object): for name in render_name: aovs_frames.update({ f"{camera}_{name}": ( - self.get_expected_render_elements( - filename, name, start_frame, - end_frame, ext) + self.get_expected_render_elements( + filename, name, start_frame, + end_frame, ext) ) }) @@ -155,8 +156,8 @@ class RenderProducts(object): for name in render_name: render_dict.update({ name: self.get_expected_render_elements( - output_file, name, start_frame, - end_frame, img_fmt) + output_file, name, start_frame, + end_frame, img_fmt) }) elif renderer == "Redshift_Renderer": render_name = self.get_render_elements_name() @@ -169,15 +170,15 @@ class RenderProducts(object): if name == "RsCryptomatte": render_dict.update({ name: self.get_expected_render_elements( - output_file, name, start_frame, - end_frame, img_fmt) + output_file, name, start_frame, + end_frame, img_fmt) }) else: for name in render_name: render_dict.update({ name: self.get_expected_render_elements( - output_file, name, start_frame, - end_frame, img_fmt) + output_file, name, start_frame, + end_frame, img_fmt) }) elif renderer == "Arnold": @@ -186,7 +187,8 @@ class RenderProducts(object): for name in render_name: render_dict.update({ name: self.get_expected_arnold_product( - output_file, name, start_frame, end_frame, img_fmt) + output_file, name, start_frame, + end_frame, img_fmt) }) elif renderer in [ "V_Ray_6_Hotfix_3", @@ -198,8 +200,8 @@ class RenderProducts(object): for name in render_name: render_dict.update({ name: self.get_expected_render_elements( - output_file, name, start_frame, - end_frame, img_fmt) # noqa + output_file, name, start_frame, + end_frame, img_fmt) # noqa }) return render_dict diff --git a/openpype/hosts/max/api/lib_rendersettings.py b/openpype/hosts/max/api/lib_rendersettings.py index 663f610e45..33cfc6dc4a 100644 --- a/openpype/hosts/max/api/lib_rendersettings.py +++ b/openpype/hosts/max/api/lib_rendersettings.py @@ -192,7 +192,7 @@ class RenderSettings(object): renderlayer = rt.batchRenderMgr.GetView(layer_no) # use camera name as renderlayer name renderlayer.name = cam - renderlayer.outputFilename ="{0}_{1}..{2}".format( + renderlayer.outputFilename = "{0}_{1}..{2}".format( output, cam, img_fmt) outputs.append(renderlayer.outputFilename) return outputs diff --git a/openpype/hosts/max/plugins/create/create_render.py b/openpype/hosts/max/plugins/create/create_render.py index 64e97fb941..23397e1a98 100644 --- a/openpype/hosts/max/plugins/create/create_render.py +++ b/openpype/hosts/max/plugins/create/create_render.py @@ -17,7 +17,7 @@ class CreateRender(plugin.MaxCreator): file = rt.maxFileName filename, _ = os.path.splitext(file) instance_data["AssetName"] = filename - num_of_renderlayer = rt.batchRenderMgr.numViews + num_of_renderlayer = rt.batchRenderMgr.numViews if num_of_renderlayer > 0: rt.batchRenderMgr.DeleteView(num_of_renderlayer) From 9ce0d97e48d4313b3d50d6edab36ab3608a98799 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 12 Jul 2023 19:28:08 +0800 Subject: [PATCH 005/104] hound fix --- openpype/hosts/max/api/lib_renderproducts.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/openpype/hosts/max/api/lib_renderproducts.py b/openpype/hosts/max/api/lib_renderproducts.py index 433214935d..d2d5fb08da 100644 --- a/openpype/hosts/max/api/lib_renderproducts.py +++ b/openpype/hosts/max/api/lib_renderproducts.py @@ -77,7 +77,7 @@ class RenderProducts(object): elif renderer == "Redshift_Renderer": render_name = self.get_render_elements_name() if render_name: - rs_aov_files = rt.Execute("renderers.current.separateAovFiles") + rs_aov_files = rt.Execute("renderers.current.separateAovFiles") # noqa # this doesn't work, always returns False # rs_AovFiles = rt.RedShift_Renderer().separateAovFiles if ext == "exr" and not rs_aov_files: @@ -97,9 +97,8 @@ class RenderProducts(object): self.get_expected_render_elements( filename, name, start_frame, end_frame, ext) - ) - }) - + ) + }) elif renderer == "Arnold": render_name = self.get_arnold_product_name() if render_name: From b182f29c90dd8810ab130331ad370e58fc21ab38 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 12 Jul 2023 19:32:25 +0800 Subject: [PATCH 006/104] hound fix --- openpype/hosts/max/api/lib_renderproducts.py | 24 ++++++-------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/openpype/hosts/max/api/lib_renderproducts.py b/openpype/hosts/max/api/lib_renderproducts.py index d2d5fb08da..03dfcf3345 100644 --- a/openpype/hosts/max/api/lib_renderproducts.py +++ b/openpype/hosts/max/api/lib_renderproducts.py @@ -68,11 +68,9 @@ class RenderProducts(object): if render_name: for name in render_name: aovs_frames.update({ - f"{camera}_{name}": ( - self.get_expected_render_elements( + f"{camera}_{name}": self.get_expected_render_elements( filename, name, start_frame, end_frame, ext) - ) }) elif renderer == "Redshift_Renderer": render_name = self.get_render_elements_name() @@ -84,31 +82,25 @@ class RenderProducts(object): for name in render_name: if name == "RsCryptomatte": aovs_frames.update({ - f"{camera}_{name}": ( - self.get_expected_render_elements( + f"{camera}_{name}": self.get_expected_render_elements( filename, name, start_frame, end_frame, ext) - ) }) else: for name in render_name: aovs_frames.update({ - f"{camera}_{name}": ( - self.get_expected_render_elements( + f"{camera}_{name}": self.get_expected_render_elements( filename, name, start_frame, end_frame, ext) - ) }) elif renderer == "Arnold": render_name = self.get_arnold_product_name() if render_name: for name in render_name: aovs_frames.update({ - f"{camera}_{name}": ( - self.get_expected_arnold_product( + f"{camera}_{name}": self.get_expected_arnold_product( filename, name, start_frame, end_frame, ext) - ) }) elif renderer in [ "V_Ray_6_Hotfix_3", @@ -119,11 +111,9 @@ class RenderProducts(object): if render_name: for name in render_name: aovs_frames.update({ - f"{camera}_{name}": ( - self.get_expected_render_elements( - filename, name, start_frame, - end_frame, ext) - ) + f"{camera}_{name}": self.get_expected_render_elements( + filename, name, start_frame, + end_frame, ext) }) return aovs_frames From 4c01e09ef9d3ae8f4fb67b724e9c227e9afaa7f1 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 12 Jul 2023 19:35:01 +0800 Subject: [PATCH 007/104] hound fix --- openpype/hosts/max/api/lib_renderproducts.py | 24 ++++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/openpype/hosts/max/api/lib_renderproducts.py b/openpype/hosts/max/api/lib_renderproducts.py index 03dfcf3345..59417a39fa 100644 --- a/openpype/hosts/max/api/lib_renderproducts.py +++ b/openpype/hosts/max/api/lib_renderproducts.py @@ -68,7 +68,7 @@ class RenderProducts(object): if render_name: for name in render_name: aovs_frames.update({ - f"{camera}_{name}": self.get_expected_render_elements( + f"{camera}_{name}": self.get_expected_aovs( filename, name, start_frame, end_frame, ext) }) @@ -82,14 +82,14 @@ class RenderProducts(object): for name in render_name: if name == "RsCryptomatte": aovs_frames.update({ - f"{camera}_{name}": self.get_expected_render_elements( + f"{camera}_{name}": self.get_expected_aovs( filename, name, start_frame, end_frame, ext) }) else: for name in render_name: aovs_frames.update({ - f"{camera}_{name}": self.get_expected_render_elements( + f"{camera}_{name}": self.get_expected_aovs( filename, name, start_frame, end_frame, ext) }) @@ -111,9 +111,9 @@ class RenderProducts(object): if render_name: for name in render_name: aovs_frames.update({ - f"{camera}_{name}": self.get_expected_render_elements( - filename, name, start_frame, - end_frame, ext) + f"{camera}_{name}": self.get_expected_aovs( + filename, name, start_frame, + end_frame, ext) }) return aovs_frames @@ -144,7 +144,7 @@ class RenderProducts(object): if render_name: for name in render_name: render_dict.update({ - name: self.get_expected_render_elements( + name: self.get_expected_aovs( output_file, name, start_frame, end_frame, img_fmt) }) @@ -158,14 +158,14 @@ class RenderProducts(object): for name in render_name: if name == "RsCryptomatte": render_dict.update({ - name: self.get_expected_render_elements( + name: self.get_expected_aovs( output_file, name, start_frame, end_frame, img_fmt) }) else: for name in render_name: render_dict.update({ - name: self.get_expected_render_elements( + name: self.get_expected_aovs( output_file, name, start_frame, end_frame, img_fmt) }) @@ -188,7 +188,7 @@ class RenderProducts(object): if render_name: for name in render_name: render_dict.update({ - name: self.get_expected_render_elements( + name: self.get_expected_aovs( output_file, name, start_frame, end_frame, img_fmt) # noqa }) @@ -251,8 +251,8 @@ class RenderProducts(object): return render_name - def get_expected_render_elements(self, folder, name, - start_frame, end_frame, fmt): + def get_expected_aovs(self, folder, name, + start_frame, end_frame, fmt): """Get all the expected render element output files. """ render_elements = [] for f in range(start_frame, end_frame): From 9f90e3a1f15bba7e26303d3fafee5ef5d9bd238e Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 12 Jul 2023 19:35:57 +0800 Subject: [PATCH 008/104] hound fix --- openpype/hosts/max/api/lib_renderproducts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/hosts/max/api/lib_renderproducts.py b/openpype/hosts/max/api/lib_renderproducts.py index 59417a39fa..0b8c53dfa0 100644 --- a/openpype/hosts/max/api/lib_renderproducts.py +++ b/openpype/hosts/max/api/lib_renderproducts.py @@ -98,7 +98,7 @@ class RenderProducts(object): if render_name: for name in render_name: aovs_frames.update({ - f"{camera}_{name}": self.get_expected_arnold_product( + f"{camera}_{name}": self.get_expected_arnold_product( # noqa filename, name, start_frame, end_frame, ext) }) From c81818d09509b6b85e3259e6bac362717aa1ca1c Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 14 Jul 2023 20:25:49 +0800 Subject: [PATCH 009/104] add multi camera options for render creator --- openpype/hosts/max/api/lib_rendersettings.py | 6 +-- .../hosts/max/plugins/create/create_render.py | 19 ++++++++ .../max/plugins/publish/collect_render.py | 46 ++++++++++--------- 3 files changed, 47 insertions(+), 24 deletions(-) diff --git a/openpype/hosts/max/api/lib_rendersettings.py b/openpype/hosts/max/api/lib_rendersettings.py index 33cfc6dc4a..18160c66a0 100644 --- a/openpype/hosts/max/api/lib_rendersettings.py +++ b/openpype/hosts/max/api/lib_rendersettings.py @@ -177,8 +177,8 @@ class RenderSettings(object): render_element_list.append(aov_name) return render_element_list - def create_batch_render_layer(self, container, - output_dir, cameras): + def batch_render_layer(self, container, + output_dir, cameras): outputs = list() output = os.path.join(output_dir, container) img_fmt = self._project_settings["max"]["RenderSettings"]["image_format"] # noqa @@ -186,7 +186,7 @@ class RenderSettings(object): camera = rt.getNodeByName(cam) layer_no = rt.batchRenderMgr.FindView(cam) renderlayer = None - if layer_no is None: + if layer_no == 0: renderlayer = rt.batchRenderMgr.CreateView(camera) else: renderlayer = rt.batchRenderMgr.GetView(layer_no) diff --git a/openpype/hosts/max/plugins/create/create_render.py b/openpype/hosts/max/plugins/create/create_render.py index 23397e1a98..617334753a 100644 --- a/openpype/hosts/max/plugins/create/create_render.py +++ b/openpype/hosts/max/plugins/create/create_render.py @@ -2,6 +2,7 @@ """Creator plugin for creating camera.""" import os from openpype.hosts.max.api import plugin +from openpype.lib import BoolDef from openpype.hosts.max.api.lib_rendersettings import RenderSettings @@ -17,6 +18,7 @@ class CreateRender(plugin.MaxCreator): file = rt.maxFileName filename, _ = os.path.splitext(file) instance_data["AssetName"] = filename + instance_data["multiCamera"] = pre_create_data.get("multi_cam") num_of_renderlayer = rt.batchRenderMgr.numViews if num_of_renderlayer > 0: rt.batchRenderMgr.DeleteView(num_of_renderlayer) @@ -29,3 +31,20 @@ class CreateRender(plugin.MaxCreator): container_name = instance.data.get("instance_node") # set output paths for rendering(mandatory for deadline) RenderSettings().render_output(container_name) + # TODO: create multiple camera options + if self.selected_nodes: + selected_nodes_name = [] + for sel in self.selected_nodes: + name = sel.name + selected_nodes_name.append(name) + RenderSettings().batch_render_layer( + container_name, filename, + selected_nodes_name) + + def get_pre_create_attr_defs(self): + attrs = super(CreateRender, self).get_pre_create_attr_defs() + return attrs + [ + BoolDef("multi_cam", + label="Multiple Cameras Submission", + default=False), + ] diff --git a/openpype/hosts/max/plugins/publish/collect_render.py b/openpype/hosts/max/plugins/publish/collect_render.py index 736ffa5865..ca2f2f444f 100644 --- a/openpype/hosts/max/plugins/publish/collect_render.py +++ b/openpype/hosts/max/plugins/publish/collect_render.py @@ -26,22 +26,7 @@ class CollectRender(pyblish.api.InstancePlugin): file = rt.maxFileName current_file = os.path.join(folder, file) filepath = current_file.replace("\\", "/") - container_name = instance.data.get("instance_node") context.data['currentFile'] = current_file - cameras = instance.data.get("members") - sel_cam = [ - c.name for c in cameras - if rt.classOf(c) in rt.Camera.classes] - render_dir = os.path.dirname(rt.rendOutputFilename) - outputs = RenderSettings().create_batch_render_layer( - container_name, render_dir, sel_cam - ) - aov_outputs = RenderSettings().get_batch_render_elements( - container_name, render_dir, sel_cam - ) - files_aov = RenderProducts().get_multiple_beauty(outputs, cameras) - aovs = RenderProducts().get_multiple_aovs(outputs, cameras) - files_aov.update(aovs) asset = get_current_asset_name() files_by_aov = RenderProducts().get_beauty(instance.name) @@ -49,11 +34,33 @@ class CollectRender(pyblish.api.InstancePlugin): aovs = RenderProducts().get_aovs(instance.name) files_by_aov.update(aovs) + if instance.data.get("multiCamera"): + cameras = instance.data.get("members") + if not cameras: + raise RuntimeError("There should be at least" + " one renderable camera in container") + sel_cam = [ + c.name for c in cameras + if rt.classOf(c) in rt.Camera.classes] + container_name = instance.data.get("instance_node") + render_dir = os.path.dirname(rt.rendOutputFilename) + outputs = RenderSettings().batch_render_layer( + container_name, render_dir, sel_cam + ) + + instance.data["cameras"] = sel_cam + + files_by_aov = RenderProducts().get_multiple_beauty( + outputs, sel_cam) + aovs = RenderProducts().get_multiple_aovs( + outputs, sel_cam) + files_by_aov.update(aovs) + if "expectedFiles" not in instance.data: instance.data["expectedFiles"] = list() instance.data["files"] = list() - instance.data["expectedFiles"].append(files_aov) - instance.data["files"].append(files_aov) + instance.data["expectedFiles"].append(files_by_aov) + instance.data["files"].append(files_by_aov) img_format = RenderProducts().image_format() project_name = context.data["projectName"] @@ -94,13 +101,10 @@ class CollectRender(pyblish.api.InstancePlugin): "renderer": renderer, "source": filepath, "plugin": "3dsmax", - "cameras": sel_cam, "frameStart": int(rt.rendStart), "frameEnd": int(rt.rendEnd), "version": version_int, - "farm": True, - "renderoutput": outputs, - "aovoutput": aov_outputs + "farm": True } instance.data.update(data) From 22524c1d8473226b7687626b30b34ab237708fb5 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Mon, 17 Jul 2023 17:22:09 +0800 Subject: [PATCH 010/104] add option for multiple job and plugin infos --- openpype/hosts/max/api/lib_rendersettings.py | 21 ++-- .../deadline/abstract_submit_deadline.py | 25 ++++ .../plugins/publish/submit_max_deadline.py | 113 +++++++++++++++--- 3 files changed, 136 insertions(+), 23 deletions(-) diff --git a/openpype/hosts/max/api/lib_rendersettings.py b/openpype/hosts/max/api/lib_rendersettings.py index 18160c66a0..f2294fbf95 100644 --- a/openpype/hosts/max/api/lib_rendersettings.py +++ b/openpype/hosts/max/api/lib_rendersettings.py @@ -160,7 +160,7 @@ class RenderSettings(object): return orig_render_elem def get_batch_render_elements(self, container, - output_dir, cameras): + output_dir, camera): render_element_list = list() output = os.path.join(output_dir, container) render_elem = rt.maxOps.GetCurRenderElementMgr() @@ -168,15 +168,20 @@ class RenderSettings(object): if render_elem_num < 0: return img_fmt = self._project_settings["max"]["RenderSettings"]["image_format"] # noqa - for cam in cameras: - for i in range(render_elem_num): - renderlayer_name = render_elem.GetRenderElement(i) - target, renderpass = str(renderlayer_name).split(":") - aov_name = "{0}_{1}_{2}..{3}".format( - output, cam, renderpass, img_fmt) - render_element_list.append(aov_name) + + for i in range(render_elem_num): + renderlayer_name = render_elem.GetRenderElement(i) + target, renderpass = str(renderlayer_name).split(":") + aov_name = "{0}_{1}_{2}..{3}".format( + output, camera, renderpass, img_fmt) + render_element_list.append(aov_name) return render_element_list + def get_batch_render_output(self, camera): + target_layer_no = rt.batchRenderMgr.FindView(camera) + target_layer = rt.batchRenderMgr.GetView(target_layer_no) + return target_layer.outputFilename + def batch_render_layer(self, container, output_dir, cameras): outputs = list() diff --git a/openpype/modules/deadline/abstract_submit_deadline.py b/openpype/modules/deadline/abstract_submit_deadline.py index 551a2f7373..de6babf555 100644 --- a/openpype/modules/deadline/abstract_submit_deadline.py +++ b/openpype/modules/deadline/abstract_submit_deadline.py @@ -592,6 +592,31 @@ class AbstractSubmitDeadline(pyblish.api.InstancePlugin, return file_path + def get_job_info_through_camera(self, camera=None): + """Get the job parameters for deadline submission when + multi-camera is enabled. + Args: + infos(dict): a dictionary with job info. + """ + pass + + def get_plugin_info_through_camera(self, camera=None): + """Get the plugin parameters for deadline submission when + multi-camera is enabled. + Args: + infos(dict): a dictionary with plugin info. + """ + pass + + def _use_published_name_for_multiples(self, data): + """Process the parameters submission for deadline when + user enables multi-cameras option. + Args: + job_info_list (list): A list of multiple job infos + plugin_info_list (list): A list of multiple plugin infos + """ + pass + def assemble_payload( self, job_info=None, plugin_info=None, aux_files=None): """Assemble payload data from its various parts. diff --git a/openpype/modules/deadline/plugins/publish/submit_max_deadline.py b/openpype/modules/deadline/plugins/publish/submit_max_deadline.py index 365be7b07b..6bbc956f55 100644 --- a/openpype/modules/deadline/plugins/publish/submit_max_deadline.py +++ b/openpype/modules/deadline/plugins/publish/submit_max_deadline.py @@ -56,7 +56,7 @@ class MaxSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline, cls.priority) cls.chuck_size = settings.get("chunk_size", cls.chunk_size) cls.group = settings.get("group", cls.group) - + # TODO: multiple camera instance, separate job infos def get_job_info(self): job_info = DeadlineJobInfo(Plugin="3dsmax") @@ -73,7 +73,6 @@ class MaxSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline, src_filepath = context.data["currentFile"] src_filename = os.path.basename(src_filepath) - job_info.Name = "%s - %s" % (src_filename, instance.name) job_info.BatchName = src_filename job_info.Plugin = instance.data["plugin"] @@ -179,9 +178,19 @@ class MaxSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline, } self.log.debug("Submitting 3dsMax render..") - payload = self._use_published_name(payload_data) - job_info, plugin_info = payload - self.submit(self.assemble_payload(job_info, plugin_info)) + #TODO: multiple camera options + if instance.data.get("multiCamera"): + payload = self._use_published_name_for_multiples(payload_data) + job_infos, plugin_infos = payload + for job_info, plugin_info in zip(job_infos, plugin_infos): + self.log.debug(f"job_info: {job_info}") + self.log.debug(f"plugin_info: {plugin_info}") + submission = self.assemble_payload(job_info, plugin_info) + self.submit(submission) + else: + payload = self._use_published_name(payload_data) + job_info, plugin_info = payload + self.submit(self.assemble_payload(job_info, plugin_info)) def _use_published_name(self, data): instance = self._instance @@ -212,16 +221,6 @@ class MaxSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline, plugin_data["RenderOutput"] = beauty_name # as 3dsmax has version with different languages plugin_data["Language"] = "ENU" - render_cameras = instance.data["cameras"] - if render_cameras: - for i, camera in enumerate(render_cameras): - cam_name = "Camera%s" % (i + 1) - plugin_data[cam_name] = camera - # set the default camera - plugin_data["Camera"] = camera - # set empty camera of Camera 0 for the ' - # correct parameter submission - plugin_data["Camera0"] = None renderer_class = get_current_renderer() @@ -250,6 +249,90 @@ class MaxSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline, return job_info, plugin_info + def get_job_info_through_camera(self, camera): + instance = self._instance + context = instance.context + job_info = copy.deepcopy(self.job_info) + exp = instance.data.get("expectedFiles") + + src_filepath = context.data["currentFile"] + src_filename = os.path.basename(src_filepath) + job_info.Name = "%s - %s - %s" % ( + src_filename, instance.name, camera) + for filepath in self._iter_expected_files(exp): + if camera not in filepath: + continue + job_info.OutputDirectory += os.path.dirname(filepath) + job_info.OutputFilename += os.path.basename(filepath) + + return job_info + # set the output filepath with the relative camera + + def get_plugin_info_through_camera(self, camera): + instance = self._instance + # set the target camera + plugin_info = copy.deepcopy(self.plugin_info) + plugin_data = {} + # set the output filepath with the relative camera + files = instance.data.get("expectedFiles") + if not files: + raise RuntimeError("No render elements found") + first_file = next(self._iter_expected_files(files)) + old_output_dir = os.path.dirname(first_file) + rgb_output = RenderSettings().get_batch_render_output(camera) # noqa + rgb_bname = os.path.basename(rgb_output) + dir = os.path.dirname(first_file) + beauty_name = f"{dir}/{rgb_bname}" + beauty_name = beauty_name.replace("\\", "/") + plugin_info["RenderOutput"] = beauty_name + renderer_class = get_current_renderer() + + renderer = str(renderer_class).split(":")[0] + if renderer in [ + "ART_Renderer", + "Redshift_Renderer", + "V_Ray_6_Hotfix_3", + "V_Ray_GPU_6_Hotfix_3", + "Default_Scanline_Renderer", + "Quicksilver_Hardware_Renderer", + ]: + render_elem_list = RenderSettings().get_batch_render_elements( + instance.name, old_output_dir, camera + ) + for i, element in enumerate(render_elem_list): + elem_bname = os.path.basename(element) + new_elem = f"{dir}/{elem_bname}" + new_elem = new_elem.replace("/", "\\") + plugin_info["RenderElementOutputFilename%d" % i] = new_elem # noqa + + if camera: + # set the default camera + plugin_data["Camera"] = camera + + plugin_data["Camera0"] = None + + plugin_info.update(plugin_data) + return plugin_info + + def _use_published_name_for_multiples(self, data): + """Process the parameters submission for deadline when + user enables multi-cameras option. + Args: + job_info_list (list): A list of multiple job infos + plugin_info_list (list): A list of multiple plugin infos + """ + job_info_list = [] + plugin_info_list = [] + instance = self._instance + cameras = instance.data.get("cameras", []) + for cam in cameras: + job_info = self.get_job_info_through_camera(cam) + plugin_info = self.get_plugin_info_through_camera(cam) + job_info_list.append(job_info) + plugin_info_list.append(plugin_info) + + return job_info_list, plugin_info_list + def from_published_scene(self, replace_in_path=True): instance = self._instance if instance.data["renderer"] == "Redshift_Renderer": From 5ad81ea6bff0544cffdf7abe04a29eb64d8ec58c Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Mon, 17 Jul 2023 17:44:24 +0800 Subject: [PATCH 011/104] make sure camera parameters are being collected accurately --- .../plugins/publish/submit_max_deadline.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/openpype/modules/deadline/plugins/publish/submit_max_deadline.py b/openpype/modules/deadline/plugins/publish/submit_max_deadline.py index 6bbc956f55..23a2b4c679 100644 --- a/openpype/modules/deadline/plugins/publish/submit_max_deadline.py +++ b/openpype/modules/deadline/plugins/publish/submit_max_deadline.py @@ -131,11 +131,11 @@ class MaxSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline, # Add list of expected files to job # --------------------------------- - exp = instance.data.get("expectedFiles") - - for filepath in self._iter_expected_files(exp): - job_info.OutputDirectory += os.path.dirname(filepath) - job_info.OutputFilename += os.path.basename(filepath) + if not instance.data.get("multiCamera"): + exp = instance.data.get("expectedFiles") + for filepath in self._iter_expected_files(exp): + job_info.OutputDirectory += os.path.dirname(filepath) + job_info.OutputFilename += os.path.basename(filepath) return job_info @@ -178,7 +178,7 @@ class MaxSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline, } self.log.debug("Submitting 3dsMax render..") - #TODO: multiple camera options + if instance.data.get("multiCamera"): payload = self._use_published_name_for_multiples(payload_data) job_infos, plugin_infos = payload @@ -306,9 +306,10 @@ class MaxSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline, plugin_info["RenderElementOutputFilename%d" % i] = new_elem # noqa if camera: - # set the default camera + # set the default camera and target camera + # (weird parameters from max) plugin_data["Camera"] = camera - + plugin_data["Camera1"] = camera plugin_data["Camera0"] = None plugin_info.update(plugin_data) From f5c8994fa31039b0549eddaa7bbe5ec8e5c3cee8 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Mon, 17 Jul 2023 20:21:34 +0800 Subject: [PATCH 012/104] get the correct naming for all render outputs --- openpype/hosts/max/api/lib_renderproducts.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openpype/hosts/max/api/lib_renderproducts.py b/openpype/hosts/max/api/lib_renderproducts.py index 5446e4fca3..863dccd99e 100644 --- a/openpype/hosts/max/api/lib_renderproducts.py +++ b/openpype/hosts/max/api/lib_renderproducts.py @@ -41,6 +41,8 @@ class RenderProducts(object): beauty_output_frames = dict() for output, camera in zip(outputs, cameras): filename, ext = os.path.splitext(output) + filename = filename.replace(".", "") + ext = ext.replace(".", "") start_frame = int(rt.rendStart) end_frame = int(rt.rendEnd) + 1 new_beauty = self.get_expected_beauty( @@ -57,6 +59,8 @@ class RenderProducts(object): aovs_frames = {} for output, camera in zip(outputs, cameras): filename, ext = os.path.splitext(output) + filename = filename.replace(".", "") + ext = ext.replace(".", "") start_frame = int(rt.rendStart) end_frame = int(rt.rendEnd) + 1 From 523ad0519dcbe52d4821d0981ddc4cc6962aaf60 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Mon, 17 Jul 2023 20:44:29 +0800 Subject: [PATCH 013/104] get all beauty as expected files in a correct manner --- openpype/hosts/max/api/lib_renderproducts.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openpype/hosts/max/api/lib_renderproducts.py b/openpype/hosts/max/api/lib_renderproducts.py index 863dccd99e..eaf5015ba8 100644 --- a/openpype/hosts/max/api/lib_renderproducts.py +++ b/openpype/hosts/max/api/lib_renderproducts.py @@ -48,9 +48,10 @@ class RenderProducts(object): new_beauty = self.get_expected_beauty( filename, start_frame, end_frame, ext ) - beauty_output_frames = ({ + beauty_output = ({ f"{camera}_beauty": new_beauty }) + beauty_output_frames.update(beauty_output) return beauty_output_frames def get_multiple_aovs(self, outputs, cameras): From 3bb7f871d452fdef0e46db3a92518e8dd8d94afe Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Tue, 18 Jul 2023 17:57:04 +0800 Subject: [PATCH 014/104] bug fix camera instance doesn't include anything --- .../deadline/plugins/publish/submit_publish_job.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/openpype/modules/deadline/plugins/publish/submit_publish_job.py b/openpype/modules/deadline/plugins/publish/submit_publish_job.py index 01a5c55286..1665a05f1e 100644 --- a/openpype/modules/deadline/plugins/publish/submit_publish_job.py +++ b/openpype/modules/deadline/plugins/publish/submit_publish_job.py @@ -361,7 +361,7 @@ class ProcessSubmittedJobOnFarm(pyblish.api.InstancePlugin, self.log.info("Submitting Deadline job ...") url = "{}/api/jobs".format(self.deadline_url) - response = requests.post(url, json=payload, timeout=10) + response = requests.post(url, json=payload, timeout=10, verify=False) if not response.ok: raise Exception(response.text) @@ -472,6 +472,7 @@ class ProcessSubmittedJobOnFarm(pyblish.api.InstancePlugin, host_name = self.context.data["hostName"] subset = instance_data["subset"] cameras = instance_data.get("cameras", []) + self.log.info(f"camera: {cameras}") instances = [] # go through aovs in expected files for aov, files in exp_files[0].items(): @@ -497,7 +498,8 @@ class ProcessSubmittedJobOnFarm(pyblish.api.InstancePlugin, task[0].upper(), task[1:], subset[0].upper(), subset[1:]) - cam = [c for c in cameras if c in col.head] + cam = [c for c in cameras if c in cols[0].head] + self.log.debug(f"cam: {cam}") if cam: if aov: subset_name = '{}_{}_{}'.format(group_name, cam, aov) @@ -898,6 +900,12 @@ class ProcessSubmittedJobOnFarm(pyblish.api.InstancePlugin, for v in values: instance_skeleton_data[v] = instance.data.get(v) + # if there are cameras, get the camera + # ]data for instance_skeleton_data + cameras = instance.data.get("cameras") + if cameras: + instance_skeleton_data["cameras"] = cameras + # look into instance data if representations are not having any # which are having tag `publish_on_farm` and include them for repre in instance.data.get("representations", []): From f349e720b09c78e6541eb7b10d6eb31f9020b425 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 20 Jul 2023 23:45:08 +0800 Subject: [PATCH 015/104] exporting camera scene through instanceplugin by subprocess --- openpype/hosts/max/api/lib_rendersettings.py | 18 +++ .../publish/save_scenes_for_cameras.py | 110 ++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py diff --git a/openpype/hosts/max/api/lib_rendersettings.py b/openpype/hosts/max/api/lib_rendersettings.py index 0a6f6569bf..2d453b9712 100644 --- a/openpype/hosts/max/api/lib_rendersettings.py +++ b/openpype/hosts/max/api/lib_rendersettings.py @@ -182,6 +182,24 @@ class RenderSettings(object): target_layer = rt.batchRenderMgr.GetView(target_layer_no) return target_layer.outputFilename + def batch_render_elements(self, camera): + target_layer_no = rt.batchRenderMgr.FindView(camera) + target_layer = rt.batchRenderMgr.GetView(target_layer_no) + outputfilename = target_layer.outputFilename + directory = os.path.dirname(outputfilename) + render_elem = rt.maxOps.GetCurRenderElementMgr() + render_elem_num = render_elem.NumRenderElements() + if render_elem_num < 0: + return + ext = self._project_settings["max"]["RenderSettings"]["image_format"] # noqa + + for i in range(render_elem_num): + renderlayer_name = render_elem.GetRenderElement(i) + target, renderpass = str(renderlayer_name).split(":") + aov_name = "{0}_{1}_{2}..{3}".format( + directory, camera, renderpass, ext) + render_elem.SetRenderElementFileName(i, aov_name) + def batch_render_layer(self, container, output_dir, cameras): outputs = list() diff --git a/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py b/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py new file mode 100644 index 0000000000..d3357ba478 --- /dev/null +++ b/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py @@ -0,0 +1,110 @@ +import pyblish.api +import os +import sys +import tempfile + +from pymxs import runtime as rt +from openpype.lib import run_subprocess +from openpype.hosts.max.api.lib import get_max_version +from openpype.hosts.max.api.lib_rendersettings import RenderSettings +from openpype.hosts.max.api.lib_renderproducts import RenderProducts + + +class SaveScenesForCamera(pyblish.api.InstancePlugin): + """Save scene files for multiple cameras before + deadline submission + + """ + + label = "Save Scene files for cameras" + order = pyblish.api.ExtractorOrder - 0.48 + hosts = ["max"] + families = ["maxrender", "workfile"] + + def process(self, instance): + if not instance.data.get("multiCamera"): + self.log.debug("Skipping instance...") + return + current_folder = rt.maxFilePath + current_filename = rt.maxFileName + current_filepath = os.path.join(current_folder, current_filename) + camera_scene_files = [] + repres_list = [] + scripts = [] + filename, ext = os.path.splitext(current_filename) + fmt = RenderProducts().image_format() + cameras = instance.data.get("cameras") + if not cameras: + return + new_folder = "{}_{}".format(current_folder, filename) + os.makedirs(new_folder, exist_ok=True) + for camera in cameras: + new_output = RenderSettings().get_batch_render_output(camera) # noqa + new_output = new_output.replace("\\", "/") + new_filename = "{}_{}{}".format( + filename, camera, ext) + new_filepath = os.path.join(new_folder, new_filename) + new_filepath = new_filepath.replace("\\", "/") + camera_scene_files.append(new_filepath) + RenderSettings().batch_render_elements(camera) + rt.rendOutputFilename = new_output + rt.saveMaxFile(current_filepath) + script = (""" +from pymxs import runtime as rt +import os +new_filepath = "{new_filepath}" +new_output = "{new_output}" +camera = "{camera}" +rt.rendOutputFilename = new_output +directory = os.path.dirname(new_output) +render_elem = rt.maxOps.GetCurRenderElementMgr() +render_elem_num = render_elem.NumRenderElements() +if render_elem_num > 0: + ext = "{ext}" + for i in range(render_elem_num): + renderlayer_name = render_elem.GetRenderElement(i) + target, renderpass = str(renderlayer_name).split(":") + aov_name = directory + "_" + camera + "_" + renderpass + "." + "." + ext + render_elem.SetRenderElementFileName(i, aov_name) +rt.saveMaxFile(new_filepath) + """).format(new_filepath=new_filepath, + new_output=new_output, + camera=camera, + ext=fmt) + scripts.append(script) + + max_version = get_max_version() + maxBatch_exe = os.path.join(os.getenv(f"ADSK_3DSMAX_x64_{max_version}"), "3dsmaxbatch") + maxBatch_exe = maxBatch_exe.replace("\\", "/") + if sys.platform == "windows": + maxBatch_exe += ".exe" + maxBatch_exe = os.path.normpath(maxBatch_exe) + with tempfile.TemporaryDirectory() as tmp_dir_name: + tmp_script_path = os.path.join(tmp_dir_name, "extract_scene_files.py") + log_file =os.path.join(tmp_dir_name, "fatal.log") + self.log.info("Using script file: {}".format(tmp_script_path)) + + with open(tmp_script_path, "wt") as tmp: + for script in scripts: + tmp.write(script+"\n") + tmp.write("rt.quitMax(quiet=True)"+"\n") + tmp.write("import time"+"\n") + tmp.write("time.sleep(3)") + + try: + current_filepath = current_filepath.replace("\\","/") + log_file = log_file.replace("\\", "/") + tmp_script_path = tmp_script_path.replace("\\","/") + run_subprocess([maxBatch_exe, tmp_script_path, + "-sceneFile", current_filepath]) + except RuntimeError: + self.log.debug("Checking the scene files existing or not") + + for camera_scene in camera_scene_files: + if not os.path.exists(camera_scene): + self.log.error("Camera scene files not existed yet!") + raise RuntimeError("MaxBatch.exe doesn't run as expected") + self.log.debug(f"Found Camera scene:{camera_scene}") + + if "sceneFiles" not in instance.data: + instance.data["sceneFiles"] = camera_scene_files From f4a864c0d2b0141f5cd81e40edb25b77374b22d7 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 20 Jul 2023 23:50:29 +0800 Subject: [PATCH 016/104] cosmetic fix --- .../plugins/publish/save_scenes_for_cameras.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py b/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py index d3357ba478..2abdb5dba1 100644 --- a/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py +++ b/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py @@ -74,27 +74,27 @@ rt.saveMaxFile(new_filepath) scripts.append(script) max_version = get_max_version() - maxBatch_exe = os.path.join(os.getenv(f"ADSK_3DSMAX_x64_{max_version}"), "3dsmaxbatch") + maxBatch_exe = os.path.join( + os.getenv(f"ADSK_3DSMAX_x64_{max_version}"), "3dsmaxbatch") maxBatch_exe = maxBatch_exe.replace("\\", "/") if sys.platform == "windows": maxBatch_exe += ".exe" maxBatch_exe = os.path.normpath(maxBatch_exe) with tempfile.TemporaryDirectory() as tmp_dir_name: - tmp_script_path = os.path.join(tmp_dir_name, "extract_scene_files.py") - log_file =os.path.join(tmp_dir_name, "fatal.log") + tmp_script_path = os.path.join( + tmp_dir_name, "extract_scene_files.py") self.log.info("Using script file: {}".format(tmp_script_path)) with open(tmp_script_path, "wt") as tmp: for script in scripts: - tmp.write(script+"\n") - tmp.write("rt.quitMax(quiet=True)"+"\n") - tmp.write("import time"+"\n") + tmp.write(script + "\n") + tmp.write("rt.quitMax(quiet=True)" + "\n") + tmp.write("import time" + "\n") tmp.write("time.sleep(3)") try: - current_filepath = current_filepath.replace("\\","/") - log_file = log_file.replace("\\", "/") - tmp_script_path = tmp_script_path.replace("\\","/") + current_filepath = current_filepath.replace("\\", "/") + tmp_script_path = tmp_script_path.replace("\\", "/") run_subprocess([maxBatch_exe, tmp_script_path, "-sceneFile", current_filepath]) except RuntimeError: From 7ae8b86c58ab061daa8b9acefab478adc14651fb Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 20 Jul 2023 23:51:21 +0800 Subject: [PATCH 017/104] hound fix --- openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py b/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py index 2abdb5dba1..af47959f8f 100644 --- a/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py +++ b/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py @@ -64,7 +64,7 @@ if render_elem_num > 0: for i in range(render_elem_num): renderlayer_name = render_elem.GetRenderElement(i) target, renderpass = str(renderlayer_name).split(":") - aov_name = directory + "_" + camera + "_" + renderpass + "." + "." + ext + aov_name = directory + "_" + camera + "_" + renderpass + "." + "." + ext # noqa render_elem.SetRenderElementFileName(i, aov_name) rt.saveMaxFile(new_filepath) """).format(new_filepath=new_filepath, From 3377150fe65342a421107fe71d08f72303cd0151 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 21 Jul 2023 16:14:36 +0800 Subject: [PATCH 018/104] clean up the save_scene_camera code --- .../plugins/publish/save_scenes_for_cameras.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py b/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py index af47959f8f..c6d264de32 100644 --- a/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py +++ b/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py @@ -29,7 +29,6 @@ class SaveScenesForCamera(pyblish.api.InstancePlugin): current_filename = rt.maxFileName current_filepath = os.path.join(current_folder, current_filename) camera_scene_files = [] - repres_list = [] scripts = [] filename, ext = os.path.splitext(current_filename) fmt = RenderProducts().image_format() @@ -88,9 +87,6 @@ rt.saveMaxFile(new_filepath) with open(tmp_script_path, "wt") as tmp: for script in scripts: tmp.write(script + "\n") - tmp.write("rt.quitMax(quiet=True)" + "\n") - tmp.write("import time" + "\n") - tmp.write("time.sleep(3)") try: current_filepath = current_filepath.replace("\\", "/") @@ -100,11 +96,23 @@ rt.saveMaxFile(new_filepath) except RuntimeError: self.log.debug("Checking the scene files existing or not") - for camera_scene in camera_scene_files: + for camera_scene, camera in zip(camera_scene_files, cameras): if not os.path.exists(camera_scene): self.log.error("Camera scene files not existed yet!") raise RuntimeError("MaxBatch.exe doesn't run as expected") self.log.debug(f"Found Camera scene:{camera_scene}") + instance.context.data["currentFile"] = camera_scene + representation = { + "name": "max", + "ext": "max", + "files": os.path.basename(camera_scene), + "stagingDir": new_folder, + "outputName": camera + } + self.log.debug(f"representation: {representation}") + if instance.data.get("representations") is None: + instance.data["representations"] = [] + instance.data["representations"].append(representation) if "sceneFiles" not in instance.data: instance.data["sceneFiles"] = camera_scene_files From 4144ca8e18fc2c5cf1e3b4971748cffa57ff3a9a Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 21 Jul 2023 16:45:48 +0800 Subject: [PATCH 019/104] clean up the save_scene_camera code --- .../publish/save_scenes_for_cameras.py | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py b/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py index c6d264de32..2369cf78a3 100644 --- a/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py +++ b/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py @@ -22,13 +22,11 @@ class SaveScenesForCamera(pyblish.api.InstancePlugin): families = ["maxrender", "workfile"] def process(self, instance): - if not instance.data.get("multiCamera"): - self.log.debug("Skipping instance...") - return current_folder = rt.maxFilePath current_filename = rt.maxFileName current_filepath = os.path.join(current_folder, current_filename) camera_scene_files = [] + repres_list = [] scripts = [] filename, ext = os.path.splitext(current_filename) fmt = RenderProducts().image_format() @@ -94,25 +92,25 @@ rt.saveMaxFile(new_filepath) run_subprocess([maxBatch_exe, tmp_script_path, "-sceneFile", current_filepath]) except RuntimeError: - self.log.debug("Checking the scene files existing or not") + self.log.debug("Checking the scene files existing") for camera_scene, camera in zip(camera_scene_files, cameras): if not os.path.exists(camera_scene): self.log.error("Camera scene files not existed yet!") raise RuntimeError("MaxBatch.exe doesn't run as expected") self.log.debug(f"Found Camera scene:{camera_scene}") - instance.context.data["currentFile"] = camera_scene representation = { - "name": "max", - "ext": "max", - "files": os.path.basename(camera_scene), - "stagingDir": new_folder, - "outputName": camera + "name": camera, + "ext": "max", + "files": os.path.basename(camera_scene), + "stagingDir": os.path.dirname(camera_scene), + "outputName": camera } - self.log.debug(f"representation: {representation}") - if instance.data.get("representations") is None: - instance.data["representations"] = [] - instance.data["representations"].append(representation) + repres_list.append(representation) if "sceneFiles" not in instance.data: instance.data["sceneFiles"] = camera_scene_files + + if instance.data.get("representations") is None: + instance.data["representations"] = [] + instance.data["representations"] = (repres_list) From d62b410efbc3776598d7705c0ee223f672e4a994 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 21 Jul 2023 16:57:51 +0800 Subject: [PATCH 020/104] clean up the save_scene_camera code --- openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py b/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py index 2369cf78a3..3031c0d4cf 100644 --- a/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py +++ b/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py @@ -113,4 +113,4 @@ rt.saveMaxFile(new_filepath) if instance.data.get("representations") is None: instance.data["representations"] = [] - instance.data["representations"] = (repres_list) + instance.data["representations"]= repres_list From 855143d217400b813f128b0804e599332dbe95d6 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 21 Jul 2023 17:11:26 +0800 Subject: [PATCH 021/104] clean up --- .../plugins/publish/save_scenes_for_cameras.py | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py b/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py index 3031c0d4cf..8aff9b58dd 100644 --- a/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py +++ b/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py @@ -11,8 +11,8 @@ from openpype.hosts.max.api.lib_renderproducts import RenderProducts class SaveScenesForCamera(pyblish.api.InstancePlugin): - """Save scene files for multiple cameras before - deadline submission + """Save scene files for multiple cameras without + editing the original scene before deadline submission """ @@ -26,7 +26,6 @@ class SaveScenesForCamera(pyblish.api.InstancePlugin): current_filename = rt.maxFileName current_filepath = os.path.join(current_folder, current_filename) camera_scene_files = [] - repres_list = [] scripts = [] filename, ext = os.path.splitext(current_filename) fmt = RenderProducts().image_format() @@ -99,18 +98,6 @@ rt.saveMaxFile(new_filepath) self.log.error("Camera scene files not existed yet!") raise RuntimeError("MaxBatch.exe doesn't run as expected") self.log.debug(f"Found Camera scene:{camera_scene}") - representation = { - "name": camera, - "ext": "max", - "files": os.path.basename(camera_scene), - "stagingDir": os.path.dirname(camera_scene), - "outputName": camera - } - repres_list.append(representation) if "sceneFiles" not in instance.data: instance.data["sceneFiles"] = camera_scene_files - - if instance.data.get("representations") is None: - instance.data["representations"] = [] - instance.data["representations"]= repres_list From 7ecb5ba056f2e5adf5f6ebbc6af19db16b207d56 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 21 Jul 2023 17:14:23 +0800 Subject: [PATCH 022/104] hound fix --- openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py b/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py index 8aff9b58dd..918b6cda43 100644 --- a/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py +++ b/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py @@ -93,7 +93,7 @@ rt.saveMaxFile(new_filepath) except RuntimeError: self.log.debug("Checking the scene files existing") - for camera_scene, camera in zip(camera_scene_files, cameras): + for camera_scene in camera_scene_files: if not os.path.exists(camera_scene): self.log.error("Camera scene files not existed yet!") raise RuntimeError("MaxBatch.exe doesn't run as expected") From 0a7d24ba5f2f3b8dfaaeb7b0fbf8309c27ce5c38 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 21 Jul 2023 18:27:00 +0800 Subject: [PATCH 023/104] use sys.executable to find the directory of maxBatch.exe --- openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py b/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py index 918b6cda43..0ccc69591a 100644 --- a/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py +++ b/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py @@ -5,7 +5,6 @@ import tempfile from pymxs import runtime as rt from openpype.lib import run_subprocess -from openpype.hosts.max.api.lib import get_max_version from openpype.hosts.max.api.lib_rendersettings import RenderSettings from openpype.hosts.max.api.lib_renderproducts import RenderProducts @@ -69,9 +68,8 @@ rt.saveMaxFile(new_filepath) ext=fmt) scripts.append(script) - max_version = get_max_version() maxBatch_exe = os.path.join( - os.getenv(f"ADSK_3DSMAX_x64_{max_version}"), "3dsmaxbatch") + os.path.dirname(sys.executable), "3dsmaxbatch") maxBatch_exe = maxBatch_exe.replace("\\", "/") if sys.platform == "windows": maxBatch_exe += ".exe" From 7692b95f1c113c8f2da8c0ae335398c0f7740a17 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 21 Jul 2023 19:37:00 +0800 Subject: [PATCH 024/104] change the scene_path command in submit 3dsmax renders and make sure render elements have the correct path --- .../publish/save_scenes_for_cameras.py | 19 +++++++++++-------- .../plugins/publish/submit_max_deadline.py | 5 ++++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py b/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py index 0ccc69591a..9561f53996 100644 --- a/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py +++ b/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py @@ -18,7 +18,7 @@ class SaveScenesForCamera(pyblish.api.InstancePlugin): label = "Save Scene files for cameras" order = pyblish.api.ExtractorOrder - 0.48 hosts = ["max"] - families = ["maxrender", "workfile"] + families = ["maxrender"] def process(self, instance): current_folder = rt.maxFilePath @@ -47,11 +47,13 @@ class SaveScenesForCamera(pyblish.api.InstancePlugin): script = (""" from pymxs import runtime as rt import os +filename = "{filename}" new_filepath = "{new_filepath}" new_output = "{new_output}" camera = "{camera}" rt.rendOutputFilename = new_output -directory = os.path.dirname(new_output) +directory = os.path.dirname(rt.rendOutputFilename) +directory = os.path.join(directory, filename) render_elem = rt.maxOps.GetCurRenderElementMgr() render_elem_num = render_elem.NumRenderElements() if render_elem_num > 0: @@ -62,18 +64,19 @@ if render_elem_num > 0: aov_name = directory + "_" + camera + "_" + renderpass + "." + "." + ext # noqa render_elem.SetRenderElementFileName(i, aov_name) rt.saveMaxFile(new_filepath) - """).format(new_filepath=new_filepath, + """).format(filename=filename, + new_filepath=new_filepath, new_output=new_output, camera=camera, ext=fmt) scripts.append(script) - maxBatch_exe = os.path.join( + maxbatch_exe = os.path.join( os.path.dirname(sys.executable), "3dsmaxbatch") - maxBatch_exe = maxBatch_exe.replace("\\", "/") + maxbatch_exe = maxbatch_exe.replace("\\", "/") if sys.platform == "windows": - maxBatch_exe += ".exe" - maxBatch_exe = os.path.normpath(maxBatch_exe) + maxbatch_exe += ".exe" + maxbatch_exe = os.path.normpath(maxbatch_exe) with tempfile.TemporaryDirectory() as tmp_dir_name: tmp_script_path = os.path.join( tmp_dir_name, "extract_scene_files.py") @@ -86,7 +89,7 @@ rt.saveMaxFile(new_filepath) try: current_filepath = current_filepath.replace("\\", "/") tmp_script_path = tmp_script_path.replace("\\", "/") - run_subprocess([maxBatch_exe, tmp_script_path, + run_subprocess([maxbatch_exe, tmp_script_path, "-sceneFile", current_filepath]) except RuntimeError: self.log.debug("Checking the scene files existing") diff --git a/openpype/modules/deadline/plugins/publish/submit_max_deadline.py b/openpype/modules/deadline/plugins/publish/submit_max_deadline.py index 5fed10a7c5..57f4353dcc 100644 --- a/openpype/modules/deadline/plugins/publish/submit_max_deadline.py +++ b/openpype/modules/deadline/plugins/publish/submit_max_deadline.py @@ -12,7 +12,6 @@ from openpype.pipeline import ( legacy_io, OpenPypePyblishPluginMixin ) -from openpype.settings import get_project_settings from openpype.hosts.max.api.lib import ( get_current_renderer, get_multipass_setting @@ -272,8 +271,12 @@ class MaxSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline, instance = self._instance # set the target camera plugin_info = copy.deepcopy(self.plugin_info) + plugin_data = {} # set the output filepath with the relative camera + for camera_scene_path in instance.data.get("sceneFiles"): + if camera in camera_scene_path: + plugin_data["SceneFile"] = camera_scene_path files = instance.data.get("expectedFiles") if not files: raise RuntimeError("No render elements found") From b8952629705de15b9fbcc2ca18bba16bd83b7014 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 21 Jul 2023 20:51:16 +0800 Subject: [PATCH 025/104] if multiCamera enabled, the deadline submission wont use the published workfiles to render --- .../modules/deadline/plugins/publish/submit_max_deadline.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/openpype/modules/deadline/plugins/publish/submit_max_deadline.py b/openpype/modules/deadline/plugins/publish/submit_max_deadline.py index 57f4353dcc..f3d873a1db 100644 --- a/openpype/modules/deadline/plugins/publish/submit_max_deadline.py +++ b/openpype/modules/deadline/plugins/publish/submit_max_deadline.py @@ -349,7 +349,11 @@ class MaxSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline, if instance.data["renderer"] == "Redshift_Renderer": self.log.debug("Using Redshift...published scene wont be used..") replace_in_path = False - return replace_in_path + + if instance.data["multiCamera"] == True: + self.log.debug("Using Redshift...published scene wont be used..") + replace_in_path = False + return replace_in_path @staticmethod def _iter_expected_files(exp): From 5893675dc0e96dbcef99c5dc89fabc5b9831a783 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 21 Jul 2023 20:53:35 +0800 Subject: [PATCH 026/104] some cosmetic fix --- .../modules/deadline/plugins/publish/submit_max_deadline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/modules/deadline/plugins/publish/submit_max_deadline.py b/openpype/modules/deadline/plugins/publish/submit_max_deadline.py index f3d873a1db..904732c4b4 100644 --- a/openpype/modules/deadline/plugins/publish/submit_max_deadline.py +++ b/openpype/modules/deadline/plugins/publish/submit_max_deadline.py @@ -350,7 +350,7 @@ class MaxSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline, self.log.debug("Using Redshift...published scene wont be used..") replace_in_path = False - if instance.data["multiCamera"] == True: + if instance.data.get("multiCamera"): self.log.debug("Using Redshift...published scene wont be used..") replace_in_path = False return replace_in_path From 9801ad52a0e42fbc2a69e0b5c514453d0a6d4954 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Mon, 24 Jul 2023 18:30:58 +0800 Subject: [PATCH 027/104] make sure the renderpass subset name is correct when saving scenes for camera in subprocess --- .../max/plugins/publish/save_scenes_for_cameras.py | 2 +- .../deadline/plugins/publish/submit_max_deadline.py | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py b/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py index 9561f53996..9382a8f4b3 100644 --- a/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py +++ b/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py @@ -64,7 +64,7 @@ if render_elem_num > 0: aov_name = directory + "_" + camera + "_" + renderpass + "." + "." + ext # noqa render_elem.SetRenderElementFileName(i, aov_name) rt.saveMaxFile(new_filepath) - """).format(filename=filename, + """).format(filename=instance.name, new_filepath=new_filepath, new_output=new_output, camera=camera, diff --git a/openpype/modules/deadline/plugins/publish/submit_max_deadline.py b/openpype/modules/deadline/plugins/publish/submit_max_deadline.py index 904732c4b4..822962b23e 100644 --- a/openpype/modules/deadline/plugins/publish/submit_max_deadline.py +++ b/openpype/modules/deadline/plugins/publish/submit_max_deadline.py @@ -303,10 +303,11 @@ class MaxSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline, instance.name, old_output_dir, camera ) for i, element in enumerate(render_elem_list): - elem_bname = os.path.basename(element) - new_elem = f"{dir}/{elem_bname}" - new_elem = new_elem.replace("/", "\\") - plugin_info["RenderElementOutputFilename%d" % i] = new_elem # noqa + if camera in element: + elem_bname = os.path.basename(element) + new_elem = f"{dir}/{elem_bname}" + new_elem = new_elem.replace("/", "\\") + plugin_info["RenderElementOutputFilename%d" % i] = new_elem # noqa if camera: # set the default camera and target camera @@ -349,10 +350,6 @@ class MaxSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline, if instance.data["renderer"] == "Redshift_Renderer": self.log.debug("Using Redshift...published scene wont be used..") replace_in_path = False - - if instance.data.get("multiCamera"): - self.log.debug("Using Redshift...published scene wont be used..") - replace_in_path = False return replace_in_path @staticmethod From ed55100dd19d2f99d572a78999278b73a78b1c76 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Mon, 31 Jul 2023 17:37:21 +0800 Subject: [PATCH 028/104] ondrej's comment --- .../publish/save_scenes_for_cameras.py | 3 --- .../deadline/abstract_submit_deadline.py | 25 ------------------ .../plugins/publish/submit_max_deadline.py | 26 ++++++++++++++++--- 3 files changed, 22 insertions(+), 32 deletions(-) diff --git a/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py b/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py index 9382a8f4b3..79e9088ac7 100644 --- a/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py +++ b/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py @@ -99,6 +99,3 @@ rt.saveMaxFile(new_filepath) self.log.error("Camera scene files not existed yet!") raise RuntimeError("MaxBatch.exe doesn't run as expected") self.log.debug(f"Found Camera scene:{camera_scene}") - - if "sceneFiles" not in instance.data: - instance.data["sceneFiles"] = camera_scene_files diff --git a/openpype/modules/deadline/abstract_submit_deadline.py b/openpype/modules/deadline/abstract_submit_deadline.py index ae568c43e3..3fa427204b 100644 --- a/openpype/modules/deadline/abstract_submit_deadline.py +++ b/openpype/modules/deadline/abstract_submit_deadline.py @@ -531,31 +531,6 @@ class AbstractSubmitDeadline(pyblish.api.InstancePlugin, return replace_with_published_scene_path( self._instance, replace_in_path=replace_in_path) - def get_job_info_through_camera(self, camera=None): - """Get the job parameters for deadline submission when - multi-camera is enabled. - Args: - infos(dict): a dictionary with job info. - """ - pass - - def get_plugin_info_through_camera(self, camera=None): - """Get the plugin parameters for deadline submission when - multi-camera is enabled. - Args: - infos(dict): a dictionary with plugin info. - """ - pass - - def _use_published_name_for_multiples(self, data): - """Process the parameters submission for deadline when - user enables multi-cameras option. - Args: - job_info_list (list): A list of multiple job infos - plugin_info_list (list): A list of multiple plugin infos - """ - pass - def assemble_payload( self, job_info=None, plugin_info=None, aux_files=None): """Assemble payload data from its various parts. diff --git a/openpype/modules/deadline/plugins/publish/submit_max_deadline.py b/openpype/modules/deadline/plugins/publish/submit_max_deadline.py index 822962b23e..78e570a780 100644 --- a/openpype/modules/deadline/plugins/publish/submit_max_deadline.py +++ b/openpype/modules/deadline/plugins/publish/submit_max_deadline.py @@ -164,7 +164,7 @@ class MaxSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline, def process_submission(self): instance = self._instance - filepath = self.scene_path + filepath = instance.context.data["currentFile"] files = instance.data["expectedFiles"] if not files: @@ -184,6 +184,7 @@ class MaxSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline, self.log.debug("Submitting 3dsMax render..") project_settings = instance.context.data["project_settings"] if instance.data.get("multiCamera"): + self.log.debug("Submitting jobs for multiple cameras..") payload = self._use_published_name_for_multiples( payload_data, project_settings) job_infos, plugin_infos = payload @@ -249,6 +250,11 @@ class MaxSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline, return job_info, plugin_info def get_job_info_through_camera(self, camera): + """Get the job parameters for deadline submission when + multi-camera is enabled. + Args: + infos(dict): a dictionary with job info. + """ instance = self._instance context = instance.context job_info = copy.deepcopy(self.job_info) @@ -268,15 +274,27 @@ class MaxSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline, # set the output filepath with the relative camera def get_plugin_info_through_camera(self, camera): + """Get the plugin parameters for deadline submission when + multi-camera is enabled. + Args: + infos(dict): a dictionary with plugin info. + """ instance = self._instance # set the target camera plugin_info = copy.deepcopy(self.plugin_info) plugin_data = {} # set the output filepath with the relative camera - for camera_scene_path in instance.data.get("sceneFiles"): - if camera in camera_scene_path: - plugin_data["SceneFile"] = camera_scene_path + if instance.data.get("multiCamera"): + scene_filepath = instance.context.data["currentFile"] + scene_filename = os.path.basename(scene_filepath) + scene_directory = os.path.dirname(scene_filepath) + current_filename, ext = os.path.splitext(scene_filename) + camera_scene_name = f"{current_filename}_{camera}{ext}" + camera_scene_filepath = os.path.join( + scene_directory, f"_{current_filename}", camera_scene_name) + plugin_data["SceneFile"] = camera_scene_filepath + files = instance.data.get("expectedFiles") if not files: raise RuntimeError("No render elements found") From 0d9873dd41dc71d603b100469a1faa419688a85c Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Mon, 31 Jul 2023 22:32:19 +0800 Subject: [PATCH 029/104] ondrej's comment --- .../modules/deadline/plugins/publish/submit_max_deadline.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openpype/modules/deadline/plugins/publish/submit_max_deadline.py b/openpype/modules/deadline/plugins/publish/submit_max_deadline.py index 78e570a780..15019c2647 100644 --- a/openpype/modules/deadline/plugins/publish/submit_max_deadline.py +++ b/openpype/modules/deadline/plugins/publish/submit_max_deadline.py @@ -12,6 +12,7 @@ from openpype.pipeline import ( legacy_io, OpenPypePyblishPluginMixin ) +from openpype.pipeline.publish import KnownPublishError from openpype.hosts.max.api.lib import ( get_current_renderer, get_multipass_setting @@ -168,7 +169,7 @@ class MaxSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline, files = instance.data["expectedFiles"] if not files: - raise RuntimeError("No Render Elements found!") + raise KnownPublishError("No Render Elements found!") first_file = next(self._iter_expected_files(files)) output_dir = os.path.dirname(first_file) instance.data["outputDir"] = output_dir From 3e49e6c642b1813d90111bd4007b039f46fded27 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Mon, 31 Jul 2023 23:19:31 +0800 Subject: [PATCH 030/104] use KnownPublishError instead of RuntimeError --- .../modules/deadline/plugins/publish/submit_max_deadline.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/modules/deadline/plugins/publish/submit_max_deadline.py b/openpype/modules/deadline/plugins/publish/submit_max_deadline.py index 15019c2647..29ce315bdc 100644 --- a/openpype/modules/deadline/plugins/publish/submit_max_deadline.py +++ b/openpype/modules/deadline/plugins/publish/submit_max_deadline.py @@ -210,7 +210,7 @@ class MaxSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline, files = instance.data.get("expectedFiles") if not files: - raise RuntimeError("No render elements found") + raise KnownPublishError("No render elements found") first_file = next(self._iter_expected_files(files)) old_output_dir = os.path.dirname(first_file) output_beauty = RenderSettings().get_render_output(instance.name, @@ -298,7 +298,7 @@ class MaxSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline, files = instance.data.get("expectedFiles") if not files: - raise RuntimeError("No render elements found") + raise KnownPublishError("No render elements found") first_file = next(self._iter_expected_files(files)) old_output_dir = os.path.dirname(first_file) rgb_output = RenderSettings().get_batch_render_output(camera) # noqa From 1e19bfa6949c7340a7ea146d87d66d1f2bb80aa4 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 30 Aug 2023 16:42:58 +0800 Subject: [PATCH 031/104] fix the weird naming of publish render folder --- openpype/pipeline/farm/pyblish_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/pipeline/farm/pyblish_functions.py b/openpype/pipeline/farm/pyblish_functions.py index fe3ab97de8..61cceb80ad 100644 --- a/openpype/pipeline/farm/pyblish_functions.py +++ b/openpype/pipeline/farm/pyblish_functions.py @@ -583,7 +583,7 @@ def _create_instances_for_aov(instance, skeleton, aov_filter, additional_data, else: # in case of single frame cam = [c for c in cameras if c in col] - if cam: + if cam or subset != "maxrenderMain": if aov: subset_name = '{}_{}_{}'.format(group_name, cam, aov) else: From 960e7a24bc68cb913ef4a6b6857d01b0006f04cd Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 30 Aug 2023 17:32:31 +0800 Subject: [PATCH 032/104] fixing bigroy's comment on camera subset interruption --- openpype/pipeline/farm/pyblish_functions.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/openpype/pipeline/farm/pyblish_functions.py b/openpype/pipeline/farm/pyblish_functions.py index 61cceb80ad..fb73e46508 100644 --- a/openpype/pipeline/farm/pyblish_functions.py +++ b/openpype/pipeline/farm/pyblish_functions.py @@ -583,11 +583,15 @@ def _create_instances_for_aov(instance, skeleton, aov_filter, additional_data, else: # in case of single frame cam = [c for c in cameras if c in col] - if cam or subset != "maxrenderMain": + if cam: if aov: subset_name = '{}_{}_{}'.format(group_name, cam, aov) + if subset == "maxrenderMain": + subset_name = '{}_{}'.format(group_name, aov) else: subset_name = '{}_{}'.format(group_name, cam) + if subset == "maxrenderMain": + subset_name = '{}'.format(group_name) else: if aov: subset_name = '{}_{}'.format(group_name, aov) From 749ca64e58caa9b95df2edc0347c72d44e15c151 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 30 Aug 2023 18:54:14 +0800 Subject: [PATCH 033/104] roy's comment on the subset naming based on cameras in multiple camera rendering --- openpype/pipeline/farm/pyblish_functions.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/openpype/pipeline/farm/pyblish_functions.py b/openpype/pipeline/farm/pyblish_functions.py index fb73e46508..0c5d6a2712 100644 --- a/openpype/pipeline/farm/pyblish_functions.py +++ b/openpype/pipeline/farm/pyblish_functions.py @@ -579,18 +579,24 @@ def _create_instances_for_aov(instance, skeleton, aov_filter, additional_data, # if there are multiple cameras, we need to add camera name if isinstance(col, (list, tuple)): - cam = [c for c in cameras if c in col[0]] + cam = next((c for c in cameras if c in col[0]), None) else: # in case of single frame - cam = [c for c in cameras if c in col] + cam = next((cam for cam in cameras if cam in col), None) if cam: if aov: subset_name = '{}_{}_{}'.format(group_name, cam, aov) if subset == "maxrenderMain": + # Max submit scenes by cameras for multiple camera + # submission, it results to include the camera name inside + # the original subset and i.e group_name subset_name = '{}_{}'.format(group_name, aov) else: subset_name = '{}_{}'.format(group_name, cam) if subset == "maxrenderMain": + # Max submit scenes by cameras for multiple camera + # submission, it results to include the camera name inside + # the original subset and i.e group_name subset_name = '{}'.format(group_name) else: if aov: From 1f2e32311f71448d2cc16348871d36ebf0093f04 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 30 Aug 2023 20:34:44 +0800 Subject: [PATCH 034/104] remove camera_name in aov if there is one --- openpype/pipeline/farm/pyblish_functions.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/openpype/pipeline/farm/pyblish_functions.py b/openpype/pipeline/farm/pyblish_functions.py index 0c5d6a2712..58ffeb937f 100644 --- a/openpype/pipeline/farm/pyblish_functions.py +++ b/openpype/pipeline/farm/pyblish_functions.py @@ -585,19 +585,13 @@ def _create_instances_for_aov(instance, skeleton, aov_filter, additional_data, cam = next((cam for cam in cameras if cam in col), None) if cam: if aov: + # if there is duplicatd camera name found in aov, + # it would be removed + if aov.startswith(cam): + aov = aov.replace(f"{cam}_", "") subset_name = '{}_{}_{}'.format(group_name, cam, aov) - if subset == "maxrenderMain": - # Max submit scenes by cameras for multiple camera - # submission, it results to include the camera name inside - # the original subset and i.e group_name - subset_name = '{}_{}'.format(group_name, aov) else: subset_name = '{}_{}'.format(group_name, cam) - if subset == "maxrenderMain": - # Max submit scenes by cameras for multiple camera - # submission, it results to include the camera name inside - # the original subset and i.e group_name - subset_name = '{}'.format(group_name) else: if aov: subset_name = '{}_{}'.format(group_name, aov) From 30ea0213b72237cdc9bd2920c691fb22cf184338 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Tue, 5 Sep 2023 18:40:07 +0800 Subject: [PATCH 035/104] add pattern for clique.assemble function to just iterate through frame ranges --- openpype/pipeline/farm/pyblish_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/pipeline/farm/pyblish_functions.py b/openpype/pipeline/farm/pyblish_functions.py index 58ffeb937f..3f19c3cc95 100644 --- a/openpype/pipeline/farm/pyblish_functions.py +++ b/openpype/pipeline/farm/pyblish_functions.py @@ -548,7 +548,7 @@ def _create_instances_for_aov(instance, skeleton, aov_filter, additional_data, instances = [] # go through AOVs in expected files for aov, files in exp_files[0].items(): - cols, rem = clique.assemble(files) + cols, rem = clique.assemble(files, patterns=[clique.PATTERNS['frames']]) # we shouldn't have any reminders. And if we do, it should # be just one item for single frame renders. if not cols and rem: From 44391391df926316b8c7585e526ebbaffc5ab3d6 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Tue, 5 Sep 2023 18:41:00 +0800 Subject: [PATCH 036/104] hound --- openpype/pipeline/farm/pyblish_functions.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openpype/pipeline/farm/pyblish_functions.py b/openpype/pipeline/farm/pyblish_functions.py index 3f19c3cc95..5713c13c4e 100644 --- a/openpype/pipeline/farm/pyblish_functions.py +++ b/openpype/pipeline/farm/pyblish_functions.py @@ -548,7 +548,8 @@ def _create_instances_for_aov(instance, skeleton, aov_filter, additional_data, instances = [] # go through AOVs in expected files for aov, files in exp_files[0].items(): - cols, rem = clique.assemble(files, patterns=[clique.PATTERNS['frames']]) + cols, rem = clique.assemble( + files, patterns=[clique.PATTERNS['frames']]) # we shouldn't have any reminders. And if we do, it should # be just one item for single frame renders. if not cols and rem: From 60e5eb74aeee01ad6a621554eac950a5852cdb90 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Tue, 5 Sep 2023 18:43:30 +0800 Subject: [PATCH 037/104] big roy's comments on the line 582-583 --- openpype/pipeline/farm/pyblish_functions.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/openpype/pipeline/farm/pyblish_functions.py b/openpype/pipeline/farm/pyblish_functions.py index 5713c13c4e..0bdc2b1339 100644 --- a/openpype/pipeline/farm/pyblish_functions.py +++ b/openpype/pipeline/farm/pyblish_functions.py @@ -579,11 +579,8 @@ def _create_instances_for_aov(instance, skeleton, aov_filter, additional_data, group_name = subset # if there are multiple cameras, we need to add camera name - if isinstance(col, (list, tuple)): - cam = next((c for c in cameras if c in col[0]), None) - else: - # in case of single frame - cam = next((cam for cam in cameras if cam in col), None) + expected_filepath = col[0] if isinstance(col, (list, tuple)) else col + cam = next((cam for cam in cameras if cam in expected_filepath), None) if cam: if aov: # if there is duplicatd camera name found in aov, From 75d17fcdffb6e10b049110be6defa023b6a5d68e Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Tue, 5 Sep 2023 18:56:45 +0800 Subject: [PATCH 038/104] restore the pattern for not breaking the submit publish job --- openpype/pipeline/farm/pyblish_functions.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openpype/pipeline/farm/pyblish_functions.py b/openpype/pipeline/farm/pyblish_functions.py index 0bdc2b1339..181aad6cb5 100644 --- a/openpype/pipeline/farm/pyblish_functions.py +++ b/openpype/pipeline/farm/pyblish_functions.py @@ -548,8 +548,7 @@ def _create_instances_for_aov(instance, skeleton, aov_filter, additional_data, instances = [] # go through AOVs in expected files for aov, files in exp_files[0].items(): - cols, rem = clique.assemble( - files, patterns=[clique.PATTERNS['frames']]) + cols, rem = clique.assemble(files) # we shouldn't have any reminders. And if we do, it should # be just one item for single frame renders. if not cols and rem: From dadc6fa85747cb4790b226e2279fdacd1744064c Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Tue, 26 Sep 2023 15:12:21 +0800 Subject: [PATCH 039/104] make sure render outputs with all cameras should be in the render publish folder --- openpype/pipeline/farm/pyblish_functions.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/openpype/pipeline/farm/pyblish_functions.py b/openpype/pipeline/farm/pyblish_functions.py index 181aad6cb5..5019d01be3 100644 --- a/openpype/pipeline/farm/pyblish_functions.py +++ b/openpype/pipeline/farm/pyblish_functions.py @@ -582,11 +582,13 @@ def _create_instances_for_aov(instance, skeleton, aov_filter, additional_data, cam = next((cam for cam in cameras if cam in expected_filepath), None) if cam: if aov: - # if there is duplicatd camera name found in aov, - # it would be removed - if aov.startswith(cam): - aov = aov.replace(f"{cam}_", "") - subset_name = '{}_{}_{}'.format(group_name, cam, aov) + # Multiple cameras publishing in some hosts such as 3dsMax + # have aov data set to "Camera001_beauty" to differentiate + # the render output files + if not aov.startswith(cam): + subset_name = '{}_{}_{}'.format(group_name, cam, aov) + else: + subset_name = '{}_{}'.format(group_name, aov) else: subset_name = '{}_{}'.format(group_name, cam) else: @@ -594,7 +596,6 @@ def _create_instances_for_aov(instance, skeleton, aov_filter, additional_data, subset_name = '{}_{}'.format(group_name, aov) else: subset_name = '{}'.format(group_name) - if isinstance(col, (list, tuple)): staging = os.path.dirname(col[0]) else: From 55555e3078e3289e663f13709334e0ed4e038e72 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 27 Sep 2023 22:00:38 +0800 Subject: [PATCH 040/104] iterate the camera list --- openpype/pipeline/farm/pyblish_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/pipeline/farm/pyblish_functions.py b/openpype/pipeline/farm/pyblish_functions.py index 5019d01be3..1a5cbbf3e2 100644 --- a/openpype/pipeline/farm/pyblish_functions.py +++ b/openpype/pipeline/farm/pyblish_functions.py @@ -579,7 +579,7 @@ def _create_instances_for_aov(instance, skeleton, aov_filter, additional_data, # if there are multiple cameras, we need to add camera name expected_filepath = col[0] if isinstance(col, (list, tuple)) else col - cam = next((cam for cam in cameras if cam in expected_filepath), None) + cam = next(iter(cam for cam in cameras if cam in expected_filepath), None) if cam: if aov: # Multiple cameras publishing in some hosts such as 3dsMax From 810b3259d1e7441bda9a147bdf4942a6a9fd101c Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 27 Sep 2023 22:29:41 +0800 Subject: [PATCH 041/104] hound --- openpype/pipeline/farm/pyblish_functions.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openpype/pipeline/farm/pyblish_functions.py b/openpype/pipeline/farm/pyblish_functions.py index 1a5cbbf3e2..e5530481d2 100644 --- a/openpype/pipeline/farm/pyblish_functions.py +++ b/openpype/pipeline/farm/pyblish_functions.py @@ -579,7 +579,8 @@ def _create_instances_for_aov(instance, skeleton, aov_filter, additional_data, # if there are multiple cameras, we need to add camera name expected_filepath = col[0] if isinstance(col, (list, tuple)) else col - cam = next(iter(cam for cam in cameras if cam in expected_filepath), None) + cam = next( + iter(cam for cam in cameras if cam in expected_filepath), None) if cam: if aov: # Multiple cameras publishing in some hosts such as 3dsMax From 824912dba1e1d6d793d872d93188312bb6e43309 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 28 Sep 2023 19:08:09 +0800 Subject: [PATCH 042/104] update camera subset name condition --- openpype/pipeline/farm/pyblish_functions.py | 22 ++++++++++----------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/openpype/pipeline/farm/pyblish_functions.py b/openpype/pipeline/farm/pyblish_functions.py index e5530481d2..f0d330da71 100644 --- a/openpype/pipeline/farm/pyblish_functions.py +++ b/openpype/pipeline/farm/pyblish_functions.py @@ -579,24 +579,22 @@ def _create_instances_for_aov(instance, skeleton, aov_filter, additional_data, # if there are multiple cameras, we need to add camera name expected_filepath = col[0] if isinstance(col, (list, tuple)) else col - cam = next( - iter(cam for cam in cameras if cam in expected_filepath), None) - if cam: - if aov: - # Multiple cameras publishing in some hosts such as 3dsMax - # have aov data set to "Camera001_beauty" to differentiate - # the render output files - if not aov.startswith(cam): - subset_name = '{}_{}_{}'.format(group_name, cam, aov) + cams = [cam for cam in cameras if cam in expected_filepath] + if cams: + for cam in cams: + if aov: + if not aov.startswith(cam): + subset_name = '{}_{}_{}'.format(group_name, cam, aov) + else: + subset_name = "{}_{}".format(group_name, aov) else: - subset_name = '{}_{}'.format(group_name, aov) - else: - subset_name = '{}_{}'.format(group_name, cam) + subset_name = '{}_{}'.format(group_name, cam) else: if aov: subset_name = '{}_{}'.format(group_name, aov) else: subset_name = '{}'.format(group_name) + if isinstance(col, (list, tuple)): staging = os.path.dirname(col[0]) else: From 5b2e5faccdbd0e425e0d9f438f0e82f96fe15c24 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 19 Oct 2023 18:30:03 +0800 Subject: [PATCH 043/104] remove if condition of cameras --- openpype/pipeline/farm/pyblish_functions.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/openpype/pipeline/farm/pyblish_functions.py b/openpype/pipeline/farm/pyblish_functions.py index f0d330da71..8ae46ae1a1 100644 --- a/openpype/pipeline/farm/pyblish_functions.py +++ b/openpype/pipeline/farm/pyblish_functions.py @@ -580,20 +580,17 @@ def _create_instances_for_aov(instance, skeleton, aov_filter, additional_data, # if there are multiple cameras, we need to add camera name expected_filepath = col[0] if isinstance(col, (list, tuple)) else col cams = [cam for cam in cameras if cam in expected_filepath] - if cams: - for cam in cams: - if aov: - if not aov.startswith(cam): - subset_name = '{}_{}_{}'.format(group_name, cam, aov) - else: - subset_name = "{}_{}".format(group_name, aov) - else: - subset_name = '{}_{}'.format(group_name, cam) - else: + for cam in cams: if aov: - subset_name = '{}_{}'.format(group_name, aov) + if aov.startswith(cam): + subset_name = '{}_{}_{}'.format(group_name, cam, aov) + else: + subset_name = "{}_{}".format(group_name, aov) else: - subset_name = '{}'.format(group_name) + if aov.startswith(cam): + subset_name = '{}_{}'.format(group_name, cam) + else: + subset_name = '{}'.format(group_name) if isinstance(col, (list, tuple)): staging = os.path.dirname(col[0]) From 5bb6f304d381938d1effa7cc089971ab85f46352 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 19 Oct 2023 19:26:42 +0800 Subject: [PATCH 044/104] use known publish error instead of runtime error --- openpype/hosts/max/plugins/publish/collect_render.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/max/plugins/publish/collect_render.py b/openpype/hosts/max/plugins/publish/collect_render.py index 78ab02ef5e..01d7cff32d 100644 --- a/openpype/hosts/max/plugins/publish/collect_render.py +++ b/openpype/hosts/max/plugins/publish/collect_render.py @@ -5,6 +5,7 @@ import pyblish.api from pymxs import runtime as rt from openpype.pipeline import get_current_asset_name +from openpype.pipeline.publish import KnownPublishError from openpype.hosts.max.api import colorspace from openpype.hosts.max.api.lib import get_max_version, get_current_renderer from openpype.hosts.max.api.lib_rendersettings import RenderSettings @@ -45,8 +46,8 @@ class CollectRender(pyblish.api.InstancePlugin): if instance.data.get("multiCamera"): cameras = instance.data.get("members") if not cameras: - raise RuntimeError("There should be at least" - " one renderable camera in container") + raise KnownPublishError("There should be at least" + " one renderable camera in container") sel_cam = [ c.name for c in cameras if rt.classOf(c) in rt.Camera.classes] From e3e8770ffefb25a2b89388f70f51d385a10b0cb5 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 19 Oct 2023 20:31:06 +0800 Subject: [PATCH 045/104] restore the function code for test --- openpype/pipeline/farm/pyblish_functions.py | 25 +++++++++++---------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/openpype/pipeline/farm/pyblish_functions.py b/openpype/pipeline/farm/pyblish_functions.py index 3254fbdfda..c9e013a09a 100644 --- a/openpype/pipeline/farm/pyblish_functions.py +++ b/openpype/pipeline/farm/pyblish_functions.py @@ -578,20 +578,21 @@ def _create_instances_for_aov(instance, skeleton, aov_filter, additional_data, else: group_name = subset - # if there are multiple cameras, we need to add camera name - expected_filepath = col[0] if isinstance(col, (list, tuple)) else col - cams = [cam for cam in cameras if cam in expected_filepath] - for cam in cams: + if isinstance(col, (list, tuple)): + cam = [c for c in cameras if c in col[0]] + else: + # in case of single frame + cam = [c for c in cameras if c in col] + if cam: if aov: - if aov.startswith(cam): - subset_name = '{}_{}_{}'.format(group_name, cam, aov) - else: - subset_name = "{}_{}".format(group_name, aov) + subset_name = '{}_{}_{}'.format(group_name, cam, aov) else: - if aov.startswith(cam): - subset_name = '{}_{}'.format(group_name, cam) - else: - subset_name = '{}'.format(group_name) + subset_name = '{}_{}'.format(group_name, cam) + else: + if aov: + subset_name = '{}_{}'.format(group_name, aov) + else: + subset_name = '{}'.format(group_name) if isinstance(col, (list, tuple)): staging = os.path.dirname(col[0]) From e9005c66184c5b6145a342e5258256c1929b111a Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Tue, 31 Oct 2023 12:59:24 +0800 Subject: [PATCH 046/104] make sure subset name conditions are applicable for other hosts such as maya --- openpype/pipeline/farm/pyblish_functions.py | 22 +++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/openpype/pipeline/farm/pyblish_functions.py b/openpype/pipeline/farm/pyblish_functions.py index c9e013a09a..6265449515 100644 --- a/openpype/pipeline/farm/pyblish_functions.py +++ b/openpype/pipeline/farm/pyblish_functions.py @@ -578,16 +578,18 @@ def _create_instances_for_aov(instance, skeleton, aov_filter, additional_data, else: group_name = subset - if isinstance(col, (list, tuple)): - cam = [c for c in cameras if c in col[0]] - else: - # in case of single frame - cam = [c for c in cameras if c in col] - if cam: - if aov: - subset_name = '{}_{}_{}'.format(group_name, cam, aov) - else: - subset_name = '{}_{}'.format(group_name, cam) + # if there are multiple cameras, we need to add camera name + expected_filepath = col[0] if isinstance(col, (list, tuple)) else col + cams = [cam for cam in cameras if cam in expected_filepath] + if cams: + for cam in cams: + if aov: + if not aov.startswith(cam): + subset_name = '{}_{}_{}'.format(group_name, cam, aov) + else: + subset_name = "{}_{}".format(group_name, aov) + else: + subset_name = '{}_{}'.format(group_name, cam) else: if aov: subset_name = '{}_{}'.format(group_name, aov) From 55dab6dc0c01cddf7b920e363e554e0439f78875 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 23 Nov 2023 19:29:39 +0800 Subject: [PATCH 047/104] add loader for redshift proxy family(contributed by big Roy) --- .../plugins/load/load_redshift_proxy.py | 131 ++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 openpype/hosts/houdini/plugins/load/load_redshift_proxy.py diff --git a/openpype/hosts/houdini/plugins/load/load_redshift_proxy.py b/openpype/hosts/houdini/plugins/load/load_redshift_proxy.py new file mode 100644 index 0000000000..914154be06 --- /dev/null +++ b/openpype/hosts/houdini/plugins/load/load_redshift_proxy.py @@ -0,0 +1,131 @@ +import os +from openpype.pipeline import ( + load, + get_representation_path, +) +from openpype.hosts.houdini.api import pipeline + +import clique +import hou + + +class RedshiftProxyLoader(load.LoaderPlugin): + """Load Redshift Proxy""" + + families = ["redshiftproxy"] + label = "Load Redshift Proxy" + representations = ["rs"] + order = -10 + icon = "code-fork" + color = "orange" + + def load(self, context, name=None, namespace=None, data=None): + + # Get the root node + obj = hou.node("/obj") + + # Define node name + namespace = namespace if namespace else context["asset"]["name"] + node_name = "{}_{}".format(namespace, name) if namespace else name + + # Create a new geo node + container = obj.createNode("geo", node_name=node_name) + + # Check whether the Redshift parameters exist - if not, then likely + # redshift is not set up or initialized correctly + if not container.parm("RS_objprop_proxy_enable"): + container.destroy() + raise RuntimeError("Unable to initialize geo node with Redshift " + "attributes. Make sure you have the Redshift " + "plug-in set up correctly for Houdini.") + + # Enable by default + container.setParms({ + "RS_objprop_proxy_enable": True, + "RS_objprop_proxy_file": self.format_path(self.fname) + }) + + # Remove the file node, it only loads static meshes + # Houdini 17 has removed the file node from the geo node + file_node = container.node("file1") + if file_node: + file_node.destroy() + + # Add this stub node inside so it previews ok + proxy_sop = container.createNode("redshift_proxySOP", + node_name=node_name) + proxy_sop.setDisplayFlag(True) + + nodes = [container, proxy_sop] + + self[:] = nodes + + return pipeline.containerise( + node_name, + namespace, + nodes, + context, + self.__class__.__name__, + suffix="", + ) + + def update(self, container, representation): + + # Update the file path + file_path = get_representation_path(representation) + + node = container["node"] + node.setParms({ + "RS_objprop_proxy_file": self.format_path(file_path) + }) + + # Update attribute + node.setParms({"representation": str(representation["_id"])}) + + def remove(self, container): + + node = container["node"] + node.destroy() + + def format_path(self, path): + """Format using $F{padding} token if sequence, otherwise just path.""" + + # Find all frames in the folder + ext = ".rs" + folder = os.path.dirname(path) + frames = [f for f in os.listdir(folder) if f.endswith(ext)] + + # Get the collection of frames to detect frame padding + patterns = [clique.PATTERNS["frames"]] + collections, remainder = clique.assemble(frames, + minimum_items=1, + patterns=patterns) + self.log.debug("Detected collections: {}".format(collections)) + self.log.debug("Detected remainder: {}".format(remainder)) + + if not collections and remainder: + if len(remainder) != 1: + raise ValueError("Frames not correctly detected " + "in: {}".format(remainder)) + + # A single frame without frame range detected + return os.path.normpath(path).replace("\\", "/") + + # Frames detected with a valid "frame" number pattern + # Then we don't want to have any remainder files found + assert len(collections) == 1 and not remainder + collection = collections[0] + + num_frames = len(collection.indexes) + if num_frames == 1: + # Return the input path without dynamic $F variable + result = path + else: + # More than a single frame detected - use $F{padding} + fname = "{}$F{}{}".format(collection.head, + collection.padding, + collection.tail) + result = os.path.join(folder, fname) + + # Format file name, Houdini only wants forward slashes + return os.path.normpath(result).replace("\\", "/") From 323d2409d349cbb5339457661d0ba4211f256722 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 24 Nov 2023 17:14:49 +0800 Subject: [PATCH 048/104] unified the code style of the loader with other loaders such as ass and bgeo loader --- .../plugins/load/load_redshift_proxy.py | 64 +++++++------------ 1 file changed, 22 insertions(+), 42 deletions(-) diff --git a/openpype/hosts/houdini/plugins/load/load_redshift_proxy.py b/openpype/hosts/houdini/plugins/load/load_redshift_proxy.py index 914154be06..8a3cc04eab 100644 --- a/openpype/hosts/houdini/plugins/load/load_redshift_proxy.py +++ b/openpype/hosts/houdini/plugins/load/load_redshift_proxy.py @@ -5,7 +5,6 @@ from openpype.pipeline import ( ) from openpype.hosts.houdini.api import pipeline -import clique import hou @@ -42,7 +41,8 @@ class RedshiftProxyLoader(load.LoaderPlugin): # Enable by default container.setParms({ "RS_objprop_proxy_enable": True, - "RS_objprop_proxy_file": self.format_path(self.fname) + "RS_objprop_proxy_file": self.format_path( + self.fname, context["representation"]) }) # Remove the file node, it only loads static meshes @@ -76,7 +76,8 @@ class RedshiftProxyLoader(load.LoaderPlugin): node = container["node"] node.setParms({ - "RS_objprop_proxy_file": self.format_path(file_path) + "RS_objprop_proxy_file": self.format_path( + file_path, representation) }) # Update attribute @@ -87,45 +88,24 @@ class RedshiftProxyLoader(load.LoaderPlugin): node = container["node"] node.destroy() - def format_path(self, path): - """Format using $F{padding} token if sequence, otherwise just path.""" + @staticmethod + def format_path(path, representation): + """Format file path correctly for single redshift proxy + or redshift proxy sequence.""" + import re + if not os.path.exists(path): + raise RuntimeError("Path does not exist: %s" % path) - # Find all frames in the folder - ext = ".rs" - folder = os.path.dirname(path) - frames = [f for f in os.listdir(folder) if f.endswith(ext)] - - # Get the collection of frames to detect frame padding - patterns = [clique.PATTERNS["frames"]] - collections, remainder = clique.assemble(frames, - minimum_items=1, - patterns=patterns) - self.log.debug("Detected collections: {}".format(collections)) - self.log.debug("Detected remainder: {}".format(remainder)) - - if not collections and remainder: - if len(remainder) != 1: - raise ValueError("Frames not correctly detected " - "in: {}".format(remainder)) - - # A single frame without frame range detected - return os.path.normpath(path).replace("\\", "/") - - # Frames detected with a valid "frame" number pattern - # Then we don't want to have any remainder files found - assert len(collections) == 1 and not remainder - collection = collections[0] - - num_frames = len(collection.indexes) - if num_frames == 1: - # Return the input path without dynamic $F variable - result = path + is_sequence = bool(representation["context"].get("frame")) + # The path is either a single file or sequence in a folder. + if not is_sequence: + filename = path else: - # More than a single frame detected - use $F{padding} - fname = "{}$F{}{}".format(collection.head, - collection.padding, - collection.tail) - result = os.path.join(folder, fname) + filename = re.sub(r"(.*)\.(\d+)\.(rs.*)", "\\1.$F4.\\3", path) - # Format file name, Houdini only wants forward slashes - return os.path.normpath(result).replace("\\", "/") + filename = os.path.join(path, filename) + + filename = os.path.normpath(filename) + filename = filename.replace("\\", "/") + + return filename From 9ae1e7950915adab798840520455618c32f18cf0 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 24 Nov 2023 18:35:07 +0800 Subject: [PATCH 049/104] replace deprecated self.fname by self.filepath_from_context --- .../plugins/load/load_redshift_proxy.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/openpype/hosts/houdini/plugins/load/load_redshift_proxy.py b/openpype/hosts/houdini/plugins/load/load_redshift_proxy.py index 8a3cc04eab..efd7c6d0ca 100644 --- a/openpype/hosts/houdini/plugins/load/load_redshift_proxy.py +++ b/openpype/hosts/houdini/plugins/load/load_redshift_proxy.py @@ -1,9 +1,11 @@ import os +import re from openpype.pipeline import ( load, get_representation_path, ) from openpype.hosts.houdini.api import pipeline +from openpype.pipeline.load import LoadError import hou @@ -34,15 +36,16 @@ class RedshiftProxyLoader(load.LoaderPlugin): # redshift is not set up or initialized correctly if not container.parm("RS_objprop_proxy_enable"): container.destroy() - raise RuntimeError("Unable to initialize geo node with Redshift " - "attributes. Make sure you have the Redshift " - "plug-in set up correctly for Houdini.") + raise LoadError("Unable to initialize geo node with Redshift " + "attributes. Make sure you have the Redshift " + "plug-in set up correctly for Houdini.") # Enable by default container.setParms({ "RS_objprop_proxy_enable": True, "RS_objprop_proxy_file": self.format_path( - self.fname, context["representation"]) + self.filepath_from_context(context), + context["representation"]) }) # Remove the file node, it only loads static meshes @@ -92,18 +95,16 @@ class RedshiftProxyLoader(load.LoaderPlugin): def format_path(path, representation): """Format file path correctly for single redshift proxy or redshift proxy sequence.""" - import re if not os.path.exists(path): raise RuntimeError("Path does not exist: %s" % path) is_sequence = bool(representation["context"].get("frame")) # The path is either a single file or sequence in a folder. - if not is_sequence: - filename = path - else: + if is_sequence: filename = re.sub(r"(.*)\.(\d+)\.(rs.*)", "\\1.$F4.\\3", path) - filename = os.path.join(path, filename) + else: + filename = path filename = os.path.normpath(filename) filename = filename.replace("\\", "/") From 57197cc37ab994ab814cbc1fc8b6368f64165ef7 Mon Sep 17 00:00:00 2001 From: Simone Barbieri Date: Mon, 18 Dec 2023 15:16:10 +0000 Subject: [PATCH 050/104] Use only the final part of folderPath in the instance name --- openpype/hosts/blender/api/plugin.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openpype/hosts/blender/api/plugin.py b/openpype/hosts/blender/api/plugin.py index 568d8f6695..18d2aa5362 100644 --- a/openpype/hosts/blender/api/plugin.py +++ b/openpype/hosts/blender/api/plugin.py @@ -226,7 +226,7 @@ class BaseCreator(Creator): # Create asset group if AYON_SERVER_ENABLED: - asset_name = instance_data["folderPath"] + asset_name = instance_data["folderPath"].split("/")[-1] else: asset_name = instance_data["asset"] @@ -311,6 +311,8 @@ class BaseCreator(Creator): or asset_name_key in changes.changed_keys ): asset_name = data[asset_name_key] + if AYON_SERVER_ENABLED: + asset_name = asset_name.split("/")[-1] name = prepare_scene_name( asset=asset_name, subset=data["subset"] ) From 73614e08a8de37018b0143edafed558c0cf8e879 Mon Sep 17 00:00:00 2001 From: Simone Barbieri Date: Mon, 18 Dec 2023 16:14:10 +0000 Subject: [PATCH 051/104] Add warning if name is too long for Blender --- openpype/hosts/blender/api/plugin.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/openpype/hosts/blender/api/plugin.py b/openpype/hosts/blender/api/plugin.py index 18d2aa5362..d50bfad53d 100644 --- a/openpype/hosts/blender/api/plugin.py +++ b/openpype/hosts/blender/api/plugin.py @@ -36,6 +36,12 @@ def prepare_scene_name( if namespace: name = f"{name}_{namespace}" name = f"{name}_{subset}" + + # Blender name for a collection or object cannot be longer than 63 + # characters. If the name is longer, it will raise an error. + if len(name) > 63: + raise ValueError(f"Asset name '{name}' is too long.") + return name From a8b93ec8fe5f30f1f15444df90b9bcb7f0d496f0 Mon Sep 17 00:00:00 2001 From: Simone Barbieri Date: Thu, 21 Dec 2023 10:15:05 +0000 Subject: [PATCH 052/104] Fixes long library names --- openpype/hosts/blender/plugins/load/load_animation.py | 7 ++++++- openpype/hosts/blender/plugins/load/load_blend.py | 7 ++++++- openpype/hosts/blender/plugins/load/load_blendscene.py | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/openpype/hosts/blender/plugins/load/load_animation.py b/openpype/hosts/blender/plugins/load/load_animation.py index 3e7f808903..0f968c75e5 100644 --- a/openpype/hosts/blender/plugins/load/load_animation.py +++ b/openpype/hosts/blender/plugins/load/load_animation.py @@ -61,5 +61,10 @@ class BlendAnimationLoader(plugin.AssetLoader): bpy.data.objects.remove(container) - library = bpy.data.libraries.get(bpy.path.basename(libpath)) + filepath = bpy.path.basename(libpath) + # Blender has a limit of 63 characters for any data name. + # If the filepath is longer, it will be truncated. + if len(filepath) > 63: + filepath = filepath[:63] + library = bpy.data.libraries.get(filepath) bpy.data.libraries.remove(library) diff --git a/openpype/hosts/blender/plugins/load/load_blend.py b/openpype/hosts/blender/plugins/load/load_blend.py index f437e66795..2d5ac18149 100644 --- a/openpype/hosts/blender/plugins/load/load_blend.py +++ b/openpype/hosts/blender/plugins/load/load_blend.py @@ -106,7 +106,12 @@ class BlendLoader(plugin.AssetLoader): bpy.context.scene.collection.objects.link(obj) # Remove the library from the blend file - library = bpy.data.libraries.get(bpy.path.basename(libpath)) + filepath = bpy.path.basename(libpath) + # Blender has a limit of 63 characters for any data name. + # If the filepath is longer, it will be truncated. + if len(filepath) > 63: + filepath = filepath[:63] + library = bpy.data.libraries.get(filepath) bpy.data.libraries.remove(library) return container, members diff --git a/openpype/hosts/blender/plugins/load/load_blendscene.py b/openpype/hosts/blender/plugins/load/load_blendscene.py index 6cc7f39d03..fba0245af1 100644 --- a/openpype/hosts/blender/plugins/load/load_blendscene.py +++ b/openpype/hosts/blender/plugins/load/load_blendscene.py @@ -60,7 +60,12 @@ class BlendSceneLoader(plugin.AssetLoader): bpy.context.scene.collection.children.link(container) # Remove the library from the blend file - library = bpy.data.libraries.get(bpy.path.basename(libpath)) + filepath = bpy.path.basename(libpath) + # Blender has a limit of 63 characters for any data name. + # If the filepath is longer, it will be truncated. + if len(filepath) > 63: + filepath = filepath[:63] + library = bpy.data.libraries.get(filepath) bpy.data.libraries.remove(library) return container, members From b012e169d413eb632fd347cdd8b52325034e7f50 Mon Sep 17 00:00:00 2001 From: Simone Barbieri Date: Thu, 21 Dec 2023 15:23:59 +0000 Subject: [PATCH 053/104] Changed error message Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- openpype/hosts/blender/api/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/hosts/blender/api/plugin.py b/openpype/hosts/blender/api/plugin.py index d50bfad53d..1037854a2d 100644 --- a/openpype/hosts/blender/api/plugin.py +++ b/openpype/hosts/blender/api/plugin.py @@ -40,7 +40,7 @@ def prepare_scene_name( # Blender name for a collection or object cannot be longer than 63 # characters. If the name is longer, it will raise an error. if len(name) > 63: - raise ValueError(f"Asset name '{name}' is too long.") + raise ValueError(f"Scene name '{name}' would be too long.") return name From 333433057ea2728f1646a20ee602b72c40e5c1ba Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 3 Jan 2024 21:48:38 +0800 Subject: [PATCH 054/104] cosmetic tweaks regarding to Ondrej's comment --- openpype/hosts/max/api/lib_rendersettings.py | 15 ++++++--------- .../plugins/publish/save_scenes_for_cameras.py | 7 +++---- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/openpype/hosts/max/api/lib_rendersettings.py b/openpype/hosts/max/api/lib_rendersettings.py index 166076f008..be50e296eb 100644 --- a/openpype/hosts/max/api/lib_rendersettings.py +++ b/openpype/hosts/max/api/lib_rendersettings.py @@ -80,7 +80,7 @@ class RenderSettings(object): )] except KeyError: aov_separator = "." - output_filename = "{0}..{1}".format(output, img_fmt) + output_filename = f"{output}..{img_fmt}" output_filename = output_filename.replace("{aov_separator}", aov_separator) rt.rendOutputFilename = output_filename @@ -146,13 +146,13 @@ class RenderSettings(object): for i in range(render_elem_num): renderlayer_name = render_elem.GetRenderElement(i) target, renderpass = str(renderlayer_name).split(":") - aov_name = "{0}_{1}..{2}".format(dir, renderpass, ext) + aov_name = f"{dir}_{renderpass}..{ext}" render_elem.SetRenderElementFileName(i, aov_name) def get_render_output(self, container, output_dir): output = os.path.join(output_dir, container) img_fmt = self._project_settings["max"]["RenderSettings"]["image_format"] # noqa - output_filename = "{0}..{1}".format(output, img_fmt) + output_filename = f"{output}..{img_fmt}" return output_filename def get_render_element(self): @@ -181,8 +181,7 @@ class RenderSettings(object): for i in range(render_elem_num): renderlayer_name = render_elem.GetRenderElement(i) target, renderpass = str(renderlayer_name).split(":") - aov_name = "{0}_{1}_{2}..{3}".format( - output, camera, renderpass, img_fmt) + aov_name = f"{output}_{camera}_{renderpass}..{img_fmt}" render_element_list.append(aov_name) return render_element_list @@ -205,8 +204,7 @@ class RenderSettings(object): for i in range(render_elem_num): renderlayer_name = render_elem.GetRenderElement(i) target, renderpass = str(renderlayer_name).split(":") - aov_name = "{0}_{1}_{2}..{3}".format( - directory, camera, renderpass, ext) + aov_name = f"{directory}_{camera}_{renderpass}..{ext}" render_elem.SetRenderElementFileName(i, aov_name) def batch_render_layer(self, container, @@ -224,7 +222,6 @@ class RenderSettings(object): renderlayer = rt.batchRenderMgr.GetView(layer_no) # use camera name as renderlayer name renderlayer.name = cam - renderlayer.outputFilename = "{0}_{1}..{2}".format( - output, cam, img_fmt) + renderlayer.outputFilename = f"{output}_{cam}..{img_fmt}" outputs.append(renderlayer.outputFilename) return outputs diff --git a/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py b/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py index 79e9088ac7..c39109417b 100644 --- a/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py +++ b/openpype/hosts/max/plugins/publish/save_scenes_for_cameras.py @@ -31,13 +31,12 @@ class SaveScenesForCamera(pyblish.api.InstancePlugin): cameras = instance.data.get("cameras") if not cameras: return - new_folder = "{}_{}".format(current_folder, filename) + new_folder = f"{current_folder}_{filename}" os.makedirs(new_folder, exist_ok=True) for camera in cameras: new_output = RenderSettings().get_batch_render_output(camera) # noqa new_output = new_output.replace("\\", "/") - new_filename = "{}_{}{}".format( - filename, camera, ext) + new_filename = f"{filename}_{camera}{ext}" new_filepath = os.path.join(new_folder, new_filename) new_filepath = new_filepath.replace("\\", "/") camera_scene_files.append(new_filepath) @@ -61,7 +60,7 @@ if render_elem_num > 0: for i in range(render_elem_num): renderlayer_name = render_elem.GetRenderElement(i) target, renderpass = str(renderlayer_name).split(":") - aov_name = directory + "_" + camera + "_" + renderpass + "." + "." + ext # noqa + aov_name = f"{{directory}}_{camera}_{{renderpass}}..{ext}" render_elem.SetRenderElementFileName(i, aov_name) rt.saveMaxFile(new_filepath) """).format(filename=instance.name, From 989ec8beb2947c8abef969c9e2922bea0eec2f8f Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 4 Jan 2024 18:03:05 +0800 Subject: [PATCH 055/104] make sure the default shader assigned to the redshift proxy --- openpype/hosts/maya/plugins/load/load_redshift_proxy.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/openpype/hosts/maya/plugins/load/load_redshift_proxy.py b/openpype/hosts/maya/plugins/load/load_redshift_proxy.py index b3fbfb2ed9..0ed09c6007 100644 --- a/openpype/hosts/maya/plugins/load/load_redshift_proxy.py +++ b/openpype/hosts/maya/plugins/load/load_redshift_proxy.py @@ -137,6 +137,14 @@ class RedshiftProxyLoader(load.LoaderPlugin): cmds.connectAttr("{}.outMesh".format(rs_mesh), "{}.inMesh".format(mesh_shape)) + # TODO: use the assigned shading group as shaders if existed + # assign default shader to redshift proxy + shader_grp = next( + (shader_group for shader_group in cmds.ls(type="shadingEngine") + if shader_group=="initialShadingGroup") + ) + cmds.sets(mesh_shape, forceElement=shader_grp) + group_node = cmds.group(empty=True, name="{}_GRP".format(name)) mesh_transform = cmds.listRelatives(mesh_shape, parent=True, fullPath=True) From fba52796d61c9968543a5ccaec3b4cf23459535d Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 4 Jan 2024 18:04:03 +0800 Subject: [PATCH 056/104] assign the textures when the initial shading group is located --- openpype/hosts/maya/plugins/load/load_redshift_proxy.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openpype/hosts/maya/plugins/load/load_redshift_proxy.py b/openpype/hosts/maya/plugins/load/load_redshift_proxy.py index 0ed09c6007..340533ccbd 100644 --- a/openpype/hosts/maya/plugins/load/load_redshift_proxy.py +++ b/openpype/hosts/maya/plugins/load/load_redshift_proxy.py @@ -143,7 +143,8 @@ class RedshiftProxyLoader(load.LoaderPlugin): (shader_group for shader_group in cmds.ls(type="shadingEngine") if shader_group=="initialShadingGroup") ) - cmds.sets(mesh_shape, forceElement=shader_grp) + if shader_grp: + cmds.sets(mesh_shape, forceElement=shader_grp) group_node = cmds.group(empty=True, name="{}_GRP".format(name)) mesh_transform = cmds.listRelatives(mesh_shape, From a7efe2ea759a6775c42bb0b53a3992201e0f00a3 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 4 Jan 2024 18:14:26 +0800 Subject: [PATCH 057/104] hound --- openpype/hosts/maya/plugins/load/load_redshift_proxy.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/openpype/hosts/maya/plugins/load/load_redshift_proxy.py b/openpype/hosts/maya/plugins/load/load_redshift_proxy.py index 340533ccbd..f67fe1c529 100644 --- a/openpype/hosts/maya/plugins/load/load_redshift_proxy.py +++ b/openpype/hosts/maya/plugins/load/load_redshift_proxy.py @@ -139,10 +139,9 @@ class RedshiftProxyLoader(load.LoaderPlugin): # TODO: use the assigned shading group as shaders if existed # assign default shader to redshift proxy - shader_grp = next( - (shader_group for shader_group in cmds.ls(type="shadingEngine") - if shader_group=="initialShadingGroup") - ) + shader_grp = next((shader_group for shader_group + in cmds.ls(type="shadingEngine") + if shader_group=="initialShadingGroup")) if shader_grp: cmds.sets(mesh_shape, forceElement=shader_grp) From 3af7795f19e93082824e0162f0436687f13dee51 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 4 Jan 2024 18:18:13 +0800 Subject: [PATCH 058/104] hound --- .../hosts/maya/plugins/load/load_redshift_proxy.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openpype/hosts/maya/plugins/load/load_redshift_proxy.py b/openpype/hosts/maya/plugins/load/load_redshift_proxy.py index f67fe1c529..7f88f1b152 100644 --- a/openpype/hosts/maya/plugins/load/load_redshift_proxy.py +++ b/openpype/hosts/maya/plugins/load/load_redshift_proxy.py @@ -139,11 +139,11 @@ class RedshiftProxyLoader(load.LoaderPlugin): # TODO: use the assigned shading group as shaders if existed # assign default shader to redshift proxy - shader_grp = next((shader_group for shader_group - in cmds.ls(type="shadingEngine") - if shader_group=="initialShadingGroup")) - if shader_grp: - cmds.sets(mesh_shape, forceElement=shader_grp) + shader_grp = next( + (shader_group for shader_group in cmds.ls(type="shadingEngine") + if shader_group == "initialShadingGroup") + ) + cmds.sets(mesh_shape, forceElement=shader_grp) group_node = cmds.group(empty=True, name="{}_GRP".format(name)) mesh_transform = cmds.listRelatives(mesh_shape, From bcea8967acab10bbc406fdfb0d7db4b12680f121 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 4 Jan 2024 19:18:33 +0800 Subject: [PATCH 059/104] code tweaks on shader_grp's variable --- openpype/hosts/maya/plugins/load/load_redshift_proxy.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/maya/plugins/load/load_redshift_proxy.py b/openpype/hosts/maya/plugins/load/load_redshift_proxy.py index 7f88f1b152..7b657f9184 100644 --- a/openpype/hosts/maya/plugins/load/load_redshift_proxy.py +++ b/openpype/hosts/maya/plugins/load/load_redshift_proxy.py @@ -140,8 +140,9 @@ class RedshiftProxyLoader(load.LoaderPlugin): # TODO: use the assigned shading group as shaders if existed # assign default shader to redshift proxy shader_grp = next( - (shader_group for shader_group in cmds.ls(type="shadingEngine") - if shader_group == "initialShadingGroup") + (shader_group for shader_group in + cmds.ls("initialShadingGroup", type="shadingEngine") + ) ) cmds.sets(mesh_shape, forceElement=shader_grp) From b40cba08016a9607d4e5f82ac534e0970079bae8 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 4 Jan 2024 19:20:43 +0800 Subject: [PATCH 060/104] hound --- openpype/hosts/maya/plugins/load/load_redshift_proxy.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/maya/plugins/load/load_redshift_proxy.py b/openpype/hosts/maya/plugins/load/load_redshift_proxy.py index 7b657f9184..33f39ebf38 100644 --- a/openpype/hosts/maya/plugins/load/load_redshift_proxy.py +++ b/openpype/hosts/maya/plugins/load/load_redshift_proxy.py @@ -140,8 +140,9 @@ class RedshiftProxyLoader(load.LoaderPlugin): # TODO: use the assigned shading group as shaders if existed # assign default shader to redshift proxy shader_grp = next( - (shader_group for shader_group in - cmds.ls("initialShadingGroup", type="shadingEngine") + ( + shader_group for shader_group in + cmds.ls("initialShadingGroup", type="shadingEngine") ) ) cmds.sets(mesh_shape, forceElement=shader_grp) From 584341dcef9a4d4185ba1d159d60fcba9d0dc755 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 4 Jan 2024 19:30:43 +0800 Subject: [PATCH 061/104] code tweaks on default shader grp --- openpype/hosts/maya/plugins/load/load_redshift_proxy.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/openpype/hosts/maya/plugins/load/load_redshift_proxy.py b/openpype/hosts/maya/plugins/load/load_redshift_proxy.py index 33f39ebf38..40385f34d6 100644 --- a/openpype/hosts/maya/plugins/load/load_redshift_proxy.py +++ b/openpype/hosts/maya/plugins/load/load_redshift_proxy.py @@ -139,13 +139,8 @@ class RedshiftProxyLoader(load.LoaderPlugin): # TODO: use the assigned shading group as shaders if existed # assign default shader to redshift proxy - shader_grp = next( - ( - shader_group for shader_group in - cmds.ls("initialShadingGroup", type="shadingEngine") - ) - ) - cmds.sets(mesh_shape, forceElement=shader_grp) + if cmds.ls("initialShadingGroup", type="shadingEngine"): + cmds.sets(mesh_shape, forceElement="initialShadingGroup") group_node = cmds.group(empty=True, name="{}_GRP".format(name)) mesh_transform = cmds.listRelatives(mesh_shape, From fd87751c36dc2c1fe1565dc8d782d8dcd786bf3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Sat, 6 Jan 2024 00:01:14 +0100 Subject: [PATCH 062/104] :art: add split export support for redshift --- .../plugins/publish/collect_redshift_rop.py | 19 +++++++++++++++++++ .../publish/submit_houdini_render_deadline.py | 10 ++++++++++ server_addon/deadline/server/version.py | 2 +- server_addon/houdini/server/version.py | 2 +- 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/houdini/plugins/publish/collect_redshift_rop.py b/openpype/hosts/houdini/plugins/publish/collect_redshift_rop.py index 0acddab011..cd3bb2bb7a 100644 --- a/openpype/hosts/houdini/plugins/publish/collect_redshift_rop.py +++ b/openpype/hosts/houdini/plugins/publish/collect_redshift_rop.py @@ -45,6 +45,25 @@ class CollectRedshiftROPRenderProducts(pyblish.api.InstancePlugin): beauty_suffix = rop.evalParm("RS_outputBeautyAOVSuffix") render_products = [] + # Store whether we are splitting the render job (export + render) + split_render = bool(rop.parm("RS_archive_enable").eval()) + instance.data["splitRender"] = split_render + export_prefix = None + export_products = [] + if split_render: + export_prefix = evalParmNoFrame( + rop, "RS_archive_file", pad_character="0" + ) + beauty_export_product = self.get_render_product_name( + prefix=export_prefix, + suffix=None) + export_products.append(beauty_export_product) + self.log.debug( + "Found export product: {}".format(beauty_export_product) + ) + instance.data["ifdFile"] = beauty_export_product + instance.data["exportFiles"] = list(export_products) + # Default beauty AOV beauty_product = self.get_render_product_name( prefix=default_prefix, suffix=beauty_suffix diff --git a/openpype/modules/deadline/plugins/publish/submit_houdini_render_deadline.py b/openpype/modules/deadline/plugins/publish/submit_houdini_render_deadline.py index c8960185b2..0bfb37ee1c 100644 --- a/openpype/modules/deadline/plugins/publish/submit_houdini_render_deadline.py +++ b/openpype/modules/deadline/plugins/publish/submit_houdini_render_deadline.py @@ -41,6 +41,11 @@ class VrayRenderPluginInfo(): SeparateFilesPerFrame = attr.ib(default=True) +@attr.s +class RedshiftRenderPluginInfo(): + SceneFile = attr.ib(default=None) + Version = attr.ib(default=None) + class HoudiniSubmitDeadline( abstract_submit_deadline.AbstractSubmitDeadline, OpenPypePyblishPluginMixin @@ -262,6 +267,11 @@ class HoudiniSubmitDeadline( plugin_info = VrayRenderPluginInfo( InputFilename=instance.data["ifdFile"], ) + elif family == "redshift_rop": + plugin_info = RedshiftRenderPluginInfo( + SceneFile=instance.data["ifdFile"], + Version=os.getenv("REDSHIFT_VERSION", "3.5.22"), + ) else: self.log.error( "Family '%s' not supported yet to split render job", diff --git a/server_addon/deadline/server/version.py b/server_addon/deadline/server/version.py index 1276d0254f..0a8da88258 100644 --- a/server_addon/deadline/server/version.py +++ b/server_addon/deadline/server/version.py @@ -1 +1 @@ -__version__ = "0.1.5" +__version__ = "0.1.6" diff --git a/server_addon/houdini/server/version.py b/server_addon/houdini/server/version.py index 6232f7ab18..5635676f6b 100644 --- a/server_addon/houdini/server/version.py +++ b/server_addon/houdini/server/version.py @@ -1 +1 @@ -__version__ = "0.2.10" +__version__ = "0.2.11" From 8f43b87d3628f1eb0ca97f5c017c64e0407bb3bb Mon Sep 17 00:00:00 2001 From: Ynbot Date: Sat, 6 Jan 2024 03:25:10 +0000 Subject: [PATCH 063/104] [Automated] Bump version --- openpype/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/version.py b/openpype/version.py index 4d7b8f372f..dba782ded4 100644 --- a/openpype/version.py +++ b/openpype/version.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- """Package declaring Pype version.""" -__version__ = "3.18.2" +__version__ = "3.18.3-nightly.1" From 9df4160595cd6678a6501bdc2dc79e40ba4b264b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 6 Jan 2024 03:25:49 +0000 Subject: [PATCH 064/104] chore(): update bug report / version --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 132e960885..2e854061d5 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -35,6 +35,7 @@ body: label: Version description: What version are you running? Look to OpenPype Tray options: + - 3.18.3-nightly.1 - 3.18.2 - 3.18.2-nightly.6 - 3.18.2-nightly.5 @@ -134,7 +135,6 @@ body: - 3.15.6-nightly.3 - 3.15.6-nightly.2 - 3.15.6-nightly.1 - - 3.15.5 validations: required: true - type: dropdown From 18e1f62ba29ff796e35b6e8da6bba3ce1f113e29 Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Mon, 8 Jan 2024 11:27:43 +0200 Subject: [PATCH 065/104] add split setting in redshift rop creator --- .../plugins/create/create_redshift_rop.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/openpype/hosts/houdini/plugins/create/create_redshift_rop.py b/openpype/hosts/houdini/plugins/create/create_redshift_rop.py index 1b8826a932..d790aaa340 100644 --- a/openpype/hosts/houdini/plugins/create/create_redshift_rop.py +++ b/openpype/hosts/houdini/plugins/create/create_redshift_rop.py @@ -15,6 +15,9 @@ class CreateRedshiftROP(plugin.HoudiniCreator): icon = "magic" ext = "exr" + # Default to split export and render jobs + split_render = True + def create(self, subset_name, instance_data, pre_create_data): instance_data.pop("active", None) @@ -76,6 +79,16 @@ class CreateRedshiftROP(plugin.HoudiniCreator): camera = node.path() parms.update({ "RS_renderCamera": camera or ""}) + + if pre_create_data.get("split_render"): + rs_filepath = \ + "{export_dir}{subset_name}/{subset_name}.$F4.rs".format( + export_dir=hou.text.expandString("$HIP/pyblish/rs/"), + subset_name=subset_name, + ) + parms["RS_archive_enable"] = 1 + parms["RS_archive_file"] = rs_filepath + instance_node.setParms(parms) # Lock some Avalon attributes @@ -102,6 +115,9 @@ class CreateRedshiftROP(plugin.HoudiniCreator): BoolDef("farm", label="Submitting to Farm", default=True), + BoolDef("split_render", + label="Split export and render jobs", + default=self.split_render), EnumDef("image_format", image_format_enum, default=self.ext, From 808a2b7031d0ec81516ee170fd3bcef1fa5e3b1c Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Mon, 8 Jan 2024 11:43:04 +0200 Subject: [PATCH 066/104] BigRoy's comments --- .../plugins/create/create_redshift_rop.py | 16 +++++++++------- .../plugins/publish/collect_redshift_rop.py | 1 - 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/openpype/hosts/houdini/plugins/create/create_redshift_rop.py b/openpype/hosts/houdini/plugins/create/create_redshift_rop.py index d790aaa340..097c703283 100644 --- a/openpype/hosts/houdini/plugins/create/create_redshift_rop.py +++ b/openpype/hosts/houdini/plugins/create/create_redshift_rop.py @@ -80,14 +80,16 @@ class CreateRedshiftROP(plugin.HoudiniCreator): parms.update({ "RS_renderCamera": camera or ""}) - if pre_create_data.get("split_render"): - rs_filepath = \ - "{export_dir}{subset_name}/{subset_name}.$F4.rs".format( - export_dir=hou.text.expandString("$HIP/pyblish/rs/"), - subset_name=subset_name, - ) + rs_filepath = \ + "{export_dir}{subset_name}/{subset_name}.$F4.rs".format( + export_dir=hou.text.expandString("$HIP/pyblish/rs/"), + subset_name=subset_name, + ) + parms["RS_archive_file"] = rs_filepath + + if pre_create_data.get("split_render", self.split_render): parms["RS_archive_enable"] = 1 - parms["RS_archive_file"] = rs_filepath + instance_node.setParms(parms) diff --git a/openpype/hosts/houdini/plugins/publish/collect_redshift_rop.py b/openpype/hosts/houdini/plugins/publish/collect_redshift_rop.py index cd3bb2bb7a..056684b3a3 100644 --- a/openpype/hosts/houdini/plugins/publish/collect_redshift_rop.py +++ b/openpype/hosts/houdini/plugins/publish/collect_redshift_rop.py @@ -48,7 +48,6 @@ class CollectRedshiftROPRenderProducts(pyblish.api.InstancePlugin): # Store whether we are splitting the render job (export + render) split_render = bool(rop.parm("RS_archive_enable").eval()) instance.data["splitRender"] = split_render - export_prefix = None export_products = [] if split_render: export_prefix = evalParmNoFrame( From 938d9126a2bf76df4f9a3e5ccde2231dfd6507c3 Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Mon, 8 Jan 2024 11:48:23 +0200 Subject: [PATCH 067/104] BigRoy's comment - stick to code style --- .../deadline/plugins/publish/submit_houdini_render_deadline.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openpype/modules/deadline/plugins/publish/submit_houdini_render_deadline.py b/openpype/modules/deadline/plugins/publish/submit_houdini_render_deadline.py index 0bfb37ee1c..8b03f682fc 100644 --- a/openpype/modules/deadline/plugins/publish/submit_houdini_render_deadline.py +++ b/openpype/modules/deadline/plugins/publish/submit_houdini_render_deadline.py @@ -46,6 +46,7 @@ class RedshiftRenderPluginInfo(): SceneFile = attr.ib(default=None) Version = attr.ib(default=None) + class HoudiniSubmitDeadline( abstract_submit_deadline.AbstractSubmitDeadline, OpenPypePyblishPluginMixin From 1e3fad27b0147691a3e535b9473ff330e84cfd51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Mon, 8 Jan 2024 10:57:05 +0100 Subject: [PATCH 068/104] :recycle: some code style changes --- .../plugins/create/create_redshift_rop.py | 25 ++++++++----------- .../plugins/publish/collect_redshift_rop.py | 13 ++++------ .../publish/submit_houdini_render_deadline.py | 1 + 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/openpype/hosts/houdini/plugins/create/create_redshift_rop.py b/openpype/hosts/houdini/plugins/create/create_redshift_rop.py index 097c703283..b36580f67e 100644 --- a/openpype/hosts/houdini/plugins/create/create_redshift_rop.py +++ b/openpype/hosts/houdini/plugins/create/create_redshift_rop.py @@ -39,12 +39,15 @@ class CreateRedshiftROP(plugin.HoudiniCreator): # Also create the linked Redshift IPR Rop try: ipr_rop = instance_node.parent().createNode( - "Redshift_IPR", node_name=basename + "_IPR" + "Redshift_IPR", node_name=f"{basename}_IPR" ) - except hou.OperationFailed: + except hou.OperationFailed as e: raise plugin.OpenPypeCreatorError( - ("Cannot create Redshift node. Is Redshift " - "installed and enabled?")) + ( + "Cannot create Redshift node. Is Redshift " + "installed and enabled?" + ) + ) from e # Move it to directly under the Redshift ROP ipr_rop.setPosition(instance_node.position() + hou.Vector2(0, -1)) @@ -77,22 +80,16 @@ class CreateRedshiftROP(plugin.HoudiniCreator): for node in self.selected_nodes: if node.type().name() == "cam": camera = node.path() - parms.update({ - "RS_renderCamera": camera or ""}) + parms["RS_renderCamera"] = camera or "" - rs_filepath = \ - "{export_dir}{subset_name}/{subset_name}.$F4.rs".format( - export_dir=hou.text.expandString("$HIP/pyblish/rs/"), - subset_name=subset_name, - ) + export_dir=hou.text.expandString("$HIP/pyblish/rs/") + rs_filepath = f"{export_dir}{subset_name}/{subset_name}.$F4.rs" parms["RS_archive_file"] = rs_filepath + instance_node.setParms(parms) if pre_create_data.get("split_render", self.split_render): parms["RS_archive_enable"] = 1 - - instance_node.setParms(parms) - # Lock some Avalon attributes to_lock = ["family", "id"] self.lock_parameters(instance_node, to_lock) diff --git a/openpype/hosts/houdini/plugins/publish/collect_redshift_rop.py b/openpype/hosts/houdini/plugins/publish/collect_redshift_rop.py index 056684b3a3..aec7e07fbc 100644 --- a/openpype/hosts/houdini/plugins/publish/collect_redshift_rop.py +++ b/openpype/hosts/houdini/plugins/publish/collect_redshift_rop.py @@ -31,7 +31,6 @@ class CollectRedshiftROPRenderProducts(pyblish.api.InstancePlugin): families = ["redshift_rop"] def process(self, instance): - rop = hou.node(instance.data.get("instance_node")) # Collect chunkSize @@ -43,8 +42,6 @@ class CollectRedshiftROPRenderProducts(pyblish.api.InstancePlugin): default_prefix = evalParmNoFrame(rop, "RS_outputFileNamePrefix") beauty_suffix = rop.evalParm("RS_outputBeautyAOVSuffix") - render_products = [] - # Store whether we are splitting the render job (export + render) split_render = bool(rop.parm("RS_archive_enable").eval()) instance.data["splitRender"] = split_render @@ -67,7 +64,7 @@ class CollectRedshiftROPRenderProducts(pyblish.api.InstancePlugin): beauty_product = self.get_render_product_name( prefix=default_prefix, suffix=beauty_suffix ) - render_products.append(beauty_product) + render_products = [beauty_product] files_by_aov = { "_": self.generate_expected_files(instance, beauty_product)} @@ -77,11 +74,11 @@ class CollectRedshiftROPRenderProducts(pyblish.api.InstancePlugin): i = index + 1 # Skip disabled AOVs - if not rop.evalParm("RS_aovEnable_%s" % i): + if not rop.evalParm(f"RS_aovEnable_{i}"): continue - aov_suffix = rop.evalParm("RS_aovSuffix_%s" % i) - aov_prefix = evalParmNoFrame(rop, "RS_aovCustomPrefix_%s" % i) + aov_suffix = rop.evalParm(f"RS_aovSuffix_{i}") + aov_prefix = evalParmNoFrame(rop, f"RS_aovCustomPrefix_{i}") if not aov_prefix: aov_prefix = default_prefix @@ -103,7 +100,7 @@ class CollectRedshiftROPRenderProducts(pyblish.api.InstancePlugin): instance.data["attachTo"] = [] # stub required data if "expectedFiles" not in instance.data: - instance.data["expectedFiles"] = list() + instance.data["expectedFiles"] = [] instance.data["expectedFiles"].append(files_by_aov) # update the colorspace data diff --git a/openpype/modules/deadline/plugins/publish/submit_houdini_render_deadline.py b/openpype/modules/deadline/plugins/publish/submit_houdini_render_deadline.py index 8b03f682fc..fd5e789d0e 100644 --- a/openpype/modules/deadline/plugins/publish/submit_houdini_render_deadline.py +++ b/openpype/modules/deadline/plugins/publish/submit_houdini_render_deadline.py @@ -15,6 +15,7 @@ from openpype.lib import ( NumberDef ) + @attr.s class DeadlinePluginInfo(): SceneFile = attr.ib(default=None) From 3e4b8a152217af7473d38e8de4dd6f11ec84170b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Mon, 8 Jan 2024 11:16:33 +0100 Subject: [PATCH 069/104] :dog: fix hound --- openpype/hosts/houdini/plugins/create/create_redshift_rop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/hosts/houdini/plugins/create/create_redshift_rop.py b/openpype/hosts/houdini/plugins/create/create_redshift_rop.py index b36580f67e..151fd26074 100644 --- a/openpype/hosts/houdini/plugins/create/create_redshift_rop.py +++ b/openpype/hosts/houdini/plugins/create/create_redshift_rop.py @@ -82,7 +82,7 @@ class CreateRedshiftROP(plugin.HoudiniCreator): camera = node.path() parms["RS_renderCamera"] = camera or "" - export_dir=hou.text.expandString("$HIP/pyblish/rs/") + export_dir = hou.text.expandString("$HIP/pyblish/rs/") rs_filepath = f"{export_dir}{subset_name}/{subset_name}.$F4.rs" parms["RS_archive_file"] = rs_filepath From 5d787d3fc3c77b2977f18b6da1ee7161610e4a8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Mon, 8 Jan 2024 11:17:12 +0100 Subject: [PATCH 070/104] :recycle: change how redshift version is passed --- .../plugins/publish/submit_houdini_render_deadline.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openpype/modules/deadline/plugins/publish/submit_houdini_render_deadline.py b/openpype/modules/deadline/plugins/publish/submit_houdini_render_deadline.py index fd5e789d0e..abcc3378da 100644 --- a/openpype/modules/deadline/plugins/publish/submit_houdini_render_deadline.py +++ b/openpype/modules/deadline/plugins/publish/submit_houdini_render_deadline.py @@ -271,9 +271,11 @@ class HoudiniSubmitDeadline( ) elif family == "redshift_rop": plugin_info = RedshiftRenderPluginInfo( - SceneFile=instance.data["ifdFile"], - Version=os.getenv("REDSHIFT_VERSION", "3.5.22"), + SceneFile=instance.data["ifdFile"] ) + if os.getenv("REDSHIFT_VERSION"): + plugin_info.Version = os.getenv("REDSHIFT_VERSION"), + else: self.log.error( "Family '%s' not supported yet to split render job", From 5f837d6f0b381f0ffc4db488c563bac10127b481 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 8 Jan 2024 11:51:28 +0100 Subject: [PATCH 071/104] AfterEffects: exposing Deadline pools fields in Publisher UI (#6079) * OP-6421 - added render family to families filter As published instances follow product type `render` now, fields wouldn't be shown for them. * OP-6421 - updated documentation * OP-6421 - added hosts filter Limits this with higher precision. --- .../deadline/plugins/publish/collect_pools.py | 40 +++++++++++++++---- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/openpype/modules/deadline/plugins/publish/collect_pools.py b/openpype/modules/deadline/plugins/publish/collect_pools.py index a25b149f11..9ee079b892 100644 --- a/openpype/modules/deadline/plugins/publish/collect_pools.py +++ b/openpype/modules/deadline/plugins/publish/collect_pools.py @@ -1,7 +1,4 @@ # -*- coding: utf-8 -*- -"""Collect Deadline pools. Choose default one from Settings - -""" import pyblish.api from openpype.lib import TextDef from openpype.pipeline.publish import OpenPypePyblishPluginMixin @@ -9,11 +6,35 @@ from openpype.pipeline.publish import OpenPypePyblishPluginMixin class CollectDeadlinePools(pyblish.api.InstancePlugin, OpenPypePyblishPluginMixin): - """Collect pools from instance if present, from Setting otherwise.""" + """Collect pools from instance or Publisher attributes, from Setting + otherwise. + + Pools are used to control which DL workers could render the job. + + Pools might be set: + - directly on the instance (set directly in DCC) + - from Publisher attributes + - from defaults from Settings. + + Publisher attributes could be shown even for instances that should be + rendered locally as visibility is driven by product type of the instance + (which will be `render` most likely). + (Might be resolved in the future and class attribute 'families' should + be cleaned up.) + + """ order = pyblish.api.CollectorOrder + 0.420 label = "Collect Deadline Pools" - families = ["rendering", + hosts = ["aftereffects", + "fusion", + "harmony" + "nuke", + "maya", + "max"] + + families = ["render", + "rendering", "render.farm", "renderFarm", "renderlayer", @@ -30,7 +51,6 @@ class CollectDeadlinePools(pyblish.api.InstancePlugin, cls.secondary_pool = settings.get("secondary_pool", None) def process(self, instance): - attr_values = self.get_attr_values_from_data(instance.data) if not instance.data.get("primaryPool"): instance.data["primaryPool"] = ( @@ -60,8 +80,12 @@ class CollectDeadlinePools(pyblish.api.InstancePlugin, return [ TextDef("primaryPool", label="Primary Pool", - default=cls.primary_pool), + default=cls.primary_pool, + tooltip="Deadline primary pool, " + "applicable for farm rendering"), TextDef("secondaryPool", label="Secondary Pool", - default=cls.secondary_pool) + default=cls.secondary_pool, + tooltip="Deadline secondary pool, " + "applicable for farm rendering") ] From cf17ea8377e21c4820756c83f03cd43f2eafeeeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Mon, 8 Jan 2024 12:09:06 +0100 Subject: [PATCH 072/104] :memo: add comment and warning about unspecified RS version --- .../publish/submit_houdini_render_deadline.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/openpype/modules/deadline/plugins/publish/submit_houdini_render_deadline.py b/openpype/modules/deadline/plugins/publish/submit_houdini_render_deadline.py index abcc3378da..bf7fb45a8b 100644 --- a/openpype/modules/deadline/plugins/publish/submit_houdini_render_deadline.py +++ b/openpype/modules/deadline/plugins/publish/submit_houdini_render_deadline.py @@ -273,8 +273,20 @@ class HoudiniSubmitDeadline( plugin_info = RedshiftRenderPluginInfo( SceneFile=instance.data["ifdFile"] ) + # Note: To use different versions of Redshift on Deadline + # set the `REDSHIFT_VERSION` env variable in the Tools + # settings in the AYON Application plugin. You will also + # need to set that version in `Redshift.param` file + # of the Redshift Deadline plugin: + # [Redshift_Executable_*] + # where * is the version number. if os.getenv("REDSHIFT_VERSION"): - plugin_info.Version = os.getenv("REDSHIFT_VERSION"), + plugin_info.Version = os.getenv("REDSHIFT_VERSION") + else: + self.log.warning(( + "REDSHIFT_VERSION env variable is not set" + " - using version configured in Deadline" + )) else: self.log.error( From 9d8378502436c1188fdb03be0185552cdfae2a92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Mon, 8 Jan 2024 12:41:22 +0100 Subject: [PATCH 073/104] :bug: fix render archive enable flag settings --- openpype/hosts/houdini/plugins/create/create_redshift_rop.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openpype/hosts/houdini/plugins/create/create_redshift_rop.py b/openpype/hosts/houdini/plugins/create/create_redshift_rop.py index 151fd26074..9d1c7bc90d 100644 --- a/openpype/hosts/houdini/plugins/create/create_redshift_rop.py +++ b/openpype/hosts/houdini/plugins/create/create_redshift_rop.py @@ -86,10 +86,11 @@ class CreateRedshiftROP(plugin.HoudiniCreator): rs_filepath = f"{export_dir}{subset_name}/{subset_name}.$F4.rs" parms["RS_archive_file"] = rs_filepath - instance_node.setParms(parms) if pre_create_data.get("split_render", self.split_render): parms["RS_archive_enable"] = 1 + instance_node.setParms(parms) + # Lock some Avalon attributes to_lock = ["family", "id"] self.lock_parameters(instance_node, to_lock) From 05cbb8b019d2e14fdcde07c38d4a7d80dfc2c3cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Mon, 8 Jan 2024 13:33:51 +0100 Subject: [PATCH 074/104] :wrench: fix and update pydocstyle configuration --- pyproject.toml | 5 +++++ setup.cfg | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 38236f88bc..ee8e8017e3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -181,3 +181,8 @@ reportMissingTypeStubs = false [tool.poetry.extras] docs = ["Sphinx", "furo", "sphinxcontrib-napoleon"] + +[tool.pydocstyle] +inherit = false +convetion = "google" +match = "(?!test_).*\\.py" diff --git a/setup.cfg b/setup.cfg index ead9b25164..f0f754fb24 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,10 +16,6 @@ max-complexity = 30 [pylint.'MESSAGES CONTROL'] disable = no-member -[pydocstyle] -convention = google -ignore = D107 - [coverage:run] branch = True omit = /tests From 86cf80027c039a9a353911760eaf13ae78279ea0 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 9 Jan 2024 11:16:28 +0100 Subject: [PATCH 075/104] Chore: Remove deprecated templates profiles (#6103) * do not use 'IntegrateAssetNew' settings which are not available anymore * don't use 'IntegrateHeroVersion' settings to get hero version template name * remove 'template_name_profiles' from 'IntegrateHeroVersion' * remove unused attribute --- openpype/pipeline/publish/lib.py | 55 +------------------ .../plugins/publish/integrate_hero_version.py | 1 - .../schemas/schema_global_publish.json | 43 --------------- .../core/server/settings/publish_plugins.py | 20 ------- 4 files changed, 2 insertions(+), 117 deletions(-) diff --git a/openpype/pipeline/publish/lib.py b/openpype/pipeline/publish/lib.py index 4ea2f932f1..40cb94e2bf 100644 --- a/openpype/pipeline/publish/lib.py +++ b/openpype/pipeline/publish/lib.py @@ -58,41 +58,13 @@ def get_template_name_profiles( if not project_settings: project_settings = get_project_settings(project_name) - profiles = ( + return copy.deepcopy( project_settings ["global"] ["tools"] ["publish"] ["template_name_profiles"] ) - if profiles: - return copy.deepcopy(profiles) - - # Use legacy approach for cases new settings are not filled yet for the - # project - legacy_profiles = ( - project_settings - ["global"] - ["publish"] - ["IntegrateAssetNew"] - ["template_name_profiles"] - ) - if legacy_profiles: - if not logger: - logger = Logger.get_logger("get_template_name_profiles") - - logger.warning(( - "Project \"{}\" is using legacy access to publish template." - " It is recommended to move settings to new location" - " 'project_settings/global/tools/publish/template_name_profiles'." - ).format(project_name)) - - # Replace "tasks" key with "task_names" - profiles = [] - for profile in copy.deepcopy(legacy_profiles): - profile["task_names"] = profile.pop("tasks", []) - profiles.append(profile) - return profiles def get_hero_template_name_profiles( @@ -121,36 +93,13 @@ def get_hero_template_name_profiles( if not project_settings: project_settings = get_project_settings(project_name) - profiles = ( + return copy.deepcopy( project_settings ["global"] ["tools"] ["publish"] ["hero_template_name_profiles"] ) - if profiles: - return copy.deepcopy(profiles) - - # Use legacy approach for cases new settings are not filled yet for the - # project - legacy_profiles = copy.deepcopy( - project_settings - ["global"] - ["publish"] - ["IntegrateHeroVersion"] - ["template_name_profiles"] - ) - if legacy_profiles: - if not logger: - logger = Logger.get_logger("get_hero_template_name_profiles") - - logger.warning(( - "Project \"{}\" is using legacy access to hero publish template." - " It is recommended to move settings to new location" - " 'project_settings/global/tools/publish/" - "hero_template_name_profiles'." - ).format(project_name)) - return legacy_profiles def get_publish_template_name( diff --git a/openpype/plugins/publish/integrate_hero_version.py b/openpype/plugins/publish/integrate_hero_version.py index 9f0f7fe7f3..59dc6b5c64 100644 --- a/openpype/plugins/publish/integrate_hero_version.py +++ b/openpype/plugins/publish/integrate_hero_version.py @@ -54,7 +54,6 @@ class IntegrateHeroVersion(pyblish.api.InstancePlugin): # permissions error on files (files were used or user didn't have perms) # *but all other plugins must be sucessfully completed - template_name_profiles = [] _default_template_name = "hero" def process(self, instance): diff --git a/openpype/settings/entities/schemas/projects_schema/schemas/schema_global_publish.json b/openpype/settings/entities/schemas/projects_schema/schemas/schema_global_publish.json index ac2d9e190d..64f292a140 100644 --- a/openpype/settings/entities/schemas/projects_schema/schemas/schema_global_publish.json +++ b/openpype/settings/entities/schemas/projects_schema/schemas/schema_global_publish.json @@ -1023,49 +1023,6 @@ { "type": "label", "label": "NOTE: Hero publish template profiles settings were moved to Tools/Publish/Hero template name profiles. Please move values there." - }, - { - "type": "list", - "key": "template_name_profiles", - "label": "Template name profiles (DEPRECATED)", - "use_label_wrap": true, - "object_type": { - "type": "dict", - "children": [ - { - "key": "families", - "label": "Families", - "type": "list", - "object_type": "text" - }, - { - "type": "hosts-enum", - "key": "hosts", - "label": "Hosts", - "multiselection": true - }, - { - "key": "task_types", - "label": "Task types", - "type": "task-types-enum" - }, - { - "key": "task_names", - "label": "Task names", - "type": "list", - "object_type": "text" - }, - { - "type": "separator" - }, - { - "type": "text", - "key": "template_name", - "label": "Template name", - "tooltip": "Name of template from Anatomy templates" - } - ] - } } ] }, diff --git a/server_addon/core/server/settings/publish_plugins.py b/server_addon/core/server/settings/publish_plugins.py index ef52416369..0c9b9c96ef 100644 --- a/server_addon/core/server/settings/publish_plugins.py +++ b/server_addon/core/server/settings/publish_plugins.py @@ -697,13 +697,6 @@ class IntegrateHeroVersionModel(BaseSettingsModel): optional: bool = Field(False, title="Optional") active: bool = Field(True, title="Active") families: list[str] = Field(default_factory=list, title="Families") - # TODO remove when removed from client code - template_name_profiles: list[IntegrateHeroTemplateNameProfileModel] = ( - Field( - default_factory=list, - title="Template name profiles" - ) - ) class CleanUpModel(BaseSettingsModel): @@ -1049,19 +1042,6 @@ DEFAULT_PUBLISH_VALUES = { "layout", "mayaScene", "simpleUnrealTexture" - ], - "template_name_profiles": [ - { - "product_types": [ - "simpleUnrealTexture" - ], - "hosts": [ - "standalonepublisher" - ], - "task_types": [], - "task_names": [], - "template_name": "simpleUnrealTextureHero" - } ] }, "CleanUp": { From faf22c7c6df76247af2ed7a653bbfe0b84220116 Mon Sep 17 00:00:00 2001 From: Ynbot Date: Wed, 10 Jan 2024 03:25:43 +0000 Subject: [PATCH 076/104] [Automated] Bump version --- openpype/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/version.py b/openpype/version.py index dba782ded4..279575d110 100644 --- a/openpype/version.py +++ b/openpype/version.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- """Package declaring Pype version.""" -__version__ = "3.18.3-nightly.1" +__version__ = "3.18.3-nightly.2" From 4aec54f577f42b08fb4006c657ff4c94e109fa27 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 10 Jan 2024 03:26:22 +0000 Subject: [PATCH 077/104] chore(): update bug report / version --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 2e854061d5..7d6c5650d1 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -35,6 +35,7 @@ body: label: Version description: What version are you running? Look to OpenPype Tray options: + - 3.18.3-nightly.2 - 3.18.3-nightly.1 - 3.18.2 - 3.18.2-nightly.6 @@ -134,7 +135,6 @@ body: - 3.15.6 - 3.15.6-nightly.3 - 3.15.6-nightly.2 - - 3.15.6-nightly.1 validations: required: true - type: dropdown From 0a6edc648c0b5866b6025d82e091494840b17878 Mon Sep 17 00:00:00 2001 From: Simone Barbieri Date: Wed, 10 Jan 2024 12:03:08 +0000 Subject: [PATCH 078/104] Fix problem with AVALON_CONTAINER collection and workfile instance --- openpype/hosts/blender/api/plugin.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/blender/api/plugin.py b/openpype/hosts/blender/api/plugin.py index 1037854a2d..b1ff3e4a09 100644 --- a/openpype/hosts/blender/api/plugin.py +++ b/openpype/hosts/blender/api/plugin.py @@ -311,11 +311,13 @@ class BaseCreator(Creator): ) return - # Rename the instance node in the scene if subset or asset changed + # Rename the instance node in the scene if subset or asset changed. + # Do not rename the instance if the family is workfile, as the + # workfile instance is included in the AVALON_CONTAINER collection. if ( "subset" in changes.changed_keys or asset_name_key in changes.changed_keys - ): + ) and created_instance.family != "workfile": asset_name = data[asset_name_key] if AYON_SERVER_ENABLED: asset_name = asset_name.split("/")[-1] From 399bb404c4d0deae30731db123be76dca1de38d8 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Wed, 10 Jan 2024 17:10:52 +0100 Subject: [PATCH 079/104] Fusion: automatic installation of PySide2 (#6111) * OP-7450 - WIP of new hook to install PySide2 Currently not working yet as subprocess is invoking wrong `pip` which causes issue about missing `dataclasses`. * OP-7450 - updates querying of PySide2 presence Cannot use pip list as wrong pip from .venv is used and it was causing issue about missing dataclass (not in Python3.6). This implementation is simpler and just tries to import PySide2. * OP-7450 - typo * OP-7450 - removed forgotten raise for debugging * OP-7450 - double quotes Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> * OP-7450 - return if error Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> * OP-7450 - return False Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> * OP-7450 - added optionality for InstallPySideToFusion New hook is controllable by Settings. * OP-7450 - updated querying of Qt This approach should be more generic, not tied to specific version of PySide2 * OP-7450 - fix unwanted change * OP-7450 - added settings for legacy OP * OP-7450 - use correct python executable name in Linux Because it is not "expected" python in blender but installed python, I would expect the executable is python3 on linux/macos rather than python. Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> * OP-7450 - headless installation in Windows It checks first that it would need admin privileges for installation, if not it installs headlessly. If yes, it will create separate dialog that will ask for admin privileges. * OP-7450 - Hound * Update openpype/hosts/fusion/hooks/pre_pyside_install.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --------- Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- .../hosts/fusion/hooks/pre_fusion_setup.py | 3 + .../hosts/fusion/hooks/pre_pyside_install.py | 186 ++++++++++++++++++ .../defaults/project_settings/fusion.json | 5 + .../schema_project_fusion.json | 23 +++ server_addon/fusion/server/settings.py | 49 +++-- server_addon/fusion/server/version.py | 2 +- 6 files changed, 253 insertions(+), 15 deletions(-) create mode 100644 openpype/hosts/fusion/hooks/pre_pyside_install.py diff --git a/openpype/hosts/fusion/hooks/pre_fusion_setup.py b/openpype/hosts/fusion/hooks/pre_fusion_setup.py index 576628e876..3da8968727 100644 --- a/openpype/hosts/fusion/hooks/pre_fusion_setup.py +++ b/openpype/hosts/fusion/hooks/pre_fusion_setup.py @@ -64,5 +64,8 @@ class FusionPrelaunch(PreLaunchHook): self.launch_context.env[py3_var] = py3_dir + # for hook installing PySide2 + self.data["fusion_python3_home"] = py3_dir + self.log.info(f"Setting OPENPYPE_FUSION: {FUSION_HOST_DIR}") self.launch_context.env["OPENPYPE_FUSION"] = FUSION_HOST_DIR diff --git a/openpype/hosts/fusion/hooks/pre_pyside_install.py b/openpype/hosts/fusion/hooks/pre_pyside_install.py new file mode 100644 index 0000000000..f98aeda233 --- /dev/null +++ b/openpype/hosts/fusion/hooks/pre_pyside_install.py @@ -0,0 +1,186 @@ +import os +import subprocess +import platform +import uuid + +from openpype.lib.applications import PreLaunchHook, LaunchTypes + + +class InstallPySideToFusion(PreLaunchHook): + """Automatically installs Qt binding to fusion's python packages. + + Check if fusion has installed PySide2 and will try to install if not. + + For pipeline implementation is required to have Qt binding installed in + fusion's python packages. + """ + + app_groups = {"fusion"} + order = 2 + launch_types = {LaunchTypes.local} + + def execute(self): + # Prelaunch hook is not crucial + try: + settings = self.data["project_settings"][self.host_name] + if not settings["hooks"]["InstallPySideToFusion"]["enabled"]: + return + self.inner_execute() + except Exception: + self.log.warning( + "Processing of {} crashed.".format(self.__class__.__name__), + exc_info=True + ) + + def inner_execute(self): + self.log.debug("Check for PySide2 installation.") + + fusion_python3_home = self.data.get("fusion_python3_home") + if not fusion_python3_home: + self.log.warning("'fusion_python3_home' was not provided. " + "Installation of PySide2 not possible") + return + + if platform.system().lower() == "windows": + exe_filenames = ["python.exe"] + else: + exe_filenames = ["python3", "python"] + + for exe_filename in exe_filenames: + python_executable = os.path.join(fusion_python3_home, exe_filename) + if os.path.exists(python_executable): + break + + if not os.path.exists(python_executable): + self.log.warning( + "Couldn't find python executable for fusion. {}".format( + python_executable + ) + ) + return + + # Check if PySide2 is installed and skip if yes + if self._is_pyside_installed(python_executable): + self.log.debug("Fusion has already installed PySide2.") + return + + self.log.debug("Installing PySide2.") + # Install PySide2 in fusion's python + if self._windows_require_permissions( + os.path.dirname(python_executable)): + result = self._install_pyside_windows(python_executable) + else: + result = self._install_pyside(python_executable) + + if result: + self.log.info("Successfully installed PySide2 module to fusion.") + else: + self.log.warning("Failed to install PySide2 module to fusion.") + + def _install_pyside_windows(self, python_executable): + """Install PySide2 python module to fusion's python. + + Installation requires administration rights that's why it is required + to use "pywin32" module which can execute command's and ask for + administration rights. + """ + try: + import win32api + import win32con + import win32process + import win32event + import pywintypes + from win32comext.shell.shell import ShellExecuteEx + from win32comext.shell import shellcon + except Exception: + self.log.warning("Couldn't import \"pywin32\" modules") + return False + + try: + # Parameters + # - use "-m pip" as module pip to install PySide2 and argument + # "--ignore-installed" is to force install module to fusion's + # site-packages and make sure it is binary compatible + parameters = "-m pip install --ignore-installed PySide2" + + # Execute command and ask for administrator's rights + process_info = ShellExecuteEx( + nShow=win32con.SW_SHOWNORMAL, + fMask=shellcon.SEE_MASK_NOCLOSEPROCESS, + lpVerb="runas", + lpFile=python_executable, + lpParameters=parameters, + lpDirectory=os.path.dirname(python_executable) + ) + process_handle = process_info["hProcess"] + win32event.WaitForSingleObject(process_handle, + win32event.INFINITE) + returncode = win32process.GetExitCodeProcess(process_handle) + return returncode == 0 + except pywintypes.error: + return False + + def _install_pyside(self, python_executable): + """Install PySide2 python module to fusion's python.""" + try: + # Parameters + # - use "-m pip" as module pip to install PySide2 and argument + # "--ignore-installed" is to force install module to fusion's + # site-packages and make sure it is binary compatible + env = dict(os.environ) + del env['PYTHONPATH'] + args = [ + python_executable, + "-m", + "pip", + "install", + "--ignore-installed", + "PySide2", + ] + process = subprocess.Popen( + args, stdout=subprocess.PIPE, universal_newlines=True, + env=env + ) + process.communicate() + return process.returncode == 0 + except PermissionError: + self.log.warning( + "Permission denied with command:" + "\"{}\".".format(" ".join(args)) + ) + except OSError as error: + self.log.warning(f"OS error has occurred: \"{error}\".") + except subprocess.SubprocessError: + pass + + def _is_pyside_installed(self, python_executable): + """Check if PySide2 module is in fusion's pip list.""" + args = [python_executable, "-c", "from qtpy import QtWidgets"] + process = subprocess.Popen(args, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + _, stderr = process.communicate() + stderr = stderr.decode() + if stderr: + return False + return True + + def _windows_require_permissions(self, dirpath): + if platform.system().lower() != "windows": + return False + + try: + # Attempt to create a temporary file in the folder + temp_file_path = os.path.join(dirpath, uuid.uuid4().hex) + with open(temp_file_path, "w"): + pass + os.remove(temp_file_path) # Clean up temporary file + return False + + except PermissionError: + return True + + except BaseException as exc: + print(("Failed to determine if root requires permissions." + "Unexpected error: {}").format(exc)) + return False diff --git a/openpype/settings/defaults/project_settings/fusion.json b/openpype/settings/defaults/project_settings/fusion.json index 0edcae060a..8579442625 100644 --- a/openpype/settings/defaults/project_settings/fusion.json +++ b/openpype/settings/defaults/project_settings/fusion.json @@ -15,6 +15,11 @@ "copy_status": false, "force_sync": false }, + "hooks": { + "InstallPySideToFusion": { + "enabled": true + } + }, "create": { "CreateSaver": { "temp_rendering_path_template": "{workdir}/renders/fusion/{subset}/{subset}.{frame}.{ext}", diff --git a/openpype/settings/entities/schemas/projects_schema/schema_project_fusion.json b/openpype/settings/entities/schemas/projects_schema/schema_project_fusion.json index 5177d8bc7c..fbd856b895 100644 --- a/openpype/settings/entities/schemas/projects_schema/schema_project_fusion.json +++ b/openpype/settings/entities/schemas/projects_schema/schema_project_fusion.json @@ -41,6 +41,29 @@ } ] }, + { + "type": "dict", + "collapsible": true, + "key": "hooks", + "label": "Hooks", + "children": [ + { + "type": "dict", + "collapsible": true, + "checkbox_key": "enabled", + "key": "InstallPySideToFusion", + "label": "Install PySide2", + "is_group": true, + "children": [ + { + "type": "boolean", + "key": "enabled", + "label": "Enabled" + } + ] + } + ] + }, { "type": "dict", "collapsible": true, diff --git a/server_addon/fusion/server/settings.py b/server_addon/fusion/server/settings.py index 1bc12773d2..21189b390e 100644 --- a/server_addon/fusion/server/settings.py +++ b/server_addon/fusion/server/settings.py @@ -25,16 +25,6 @@ def _create_saver_instance_attributes_enum(): ] -def _image_format_enum(): - return [ - {"value": "exr", "label": "exr"}, - {"value": "tga", "label": "tga"}, - {"value": "png", "label": "png"}, - {"value": "tif", "label": "tif"}, - {"value": "jpg", "label": "jpg"}, - ] - - class CreateSaverPluginModel(BaseSettingsModel): _isGroup = True temp_rendering_path_template: str = Field( @@ -49,9 +39,23 @@ class CreateSaverPluginModel(BaseSettingsModel): enum_resolver=_create_saver_instance_attributes_enum, title="Instance attributes" ) - image_format: str = Field( - enum_resolver=_image_format_enum, - title="Output Image Format" + output_formats: list[str] = Field( + default_factory=list, + title="Output formats" + ) + + +class HookOptionalModel(BaseSettingsModel): + enabled: bool = Field( + True, + title="Enabled" + ) + + +class HooksModel(BaseSettingsModel): + InstallPySideToFusion: HookOptionalModel = Field( + default_factory=HookOptionalModel, + title="Install PySide2" ) @@ -71,6 +75,10 @@ class FusionSettings(BaseSettingsModel): default_factory=CopyFusionSettingsModel, title="Local Fusion profile settings" ) + hooks: HooksModel = Field( + default_factory=HooksModel, + title="Hooks" + ) create: CreatPluginsModel = Field( default_factory=CreatPluginsModel, title="Creator plugins" @@ -93,6 +101,11 @@ DEFAULT_VALUES = { "copy_status": False, "force_sync": False }, + "hooks": { + "InstallPySideToFusion": { + "enabled": True + } + }, "create": { "CreateSaver": { "temp_rendering_path_template": "{workdir}/renders/fusion/{product[name]}/{product[name]}.{frame}.{ext}", @@ -104,7 +117,15 @@ DEFAULT_VALUES = { "reviewable", "farm_rendering" ], - "image_format": "exr" + "output_formats": [ + "exr", + "jpg", + "jpeg", + "jpg", + "tiff", + "png", + "tga" + ] } } } diff --git a/server_addon/fusion/server/version.py b/server_addon/fusion/server/version.py index 485f44ac21..b3f4756216 100644 --- a/server_addon/fusion/server/version.py +++ b/server_addon/fusion/server/version.py @@ -1 +1 @@ -__version__ = "0.1.1" +__version__ = "0.1.2" From aba61718b256ed9cafc7aedcd80ffe369570f0e6 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 11 Jan 2024 12:07:35 +0100 Subject: [PATCH 080/104] fix issue with parenting of widgets (#6106) --- openpype/hosts/nuke/api/pipeline.py | 8 ++------ openpype/tools/publisher/window.py | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/openpype/hosts/nuke/api/pipeline.py b/openpype/hosts/nuke/api/pipeline.py index 12562a6b6f..c2fc684c21 100644 --- a/openpype/hosts/nuke/api/pipeline.py +++ b/openpype/hosts/nuke/api/pipeline.py @@ -259,9 +259,7 @@ def _install_menu(): menu.addCommand( "Create...", lambda: host_tools.show_publisher( - parent=( - main_window if nuke.NUKE_VERSION_MAJOR >= 14 else None - ), + parent=main_window, tab="create" ) ) @@ -270,9 +268,7 @@ def _install_menu(): menu.addCommand( "Publish...", lambda: host_tools.show_publisher( - parent=( - main_window if nuke.NUKE_VERSION_MAJOR >= 14 else None - ), + parent=main_window, tab="publish" ) ) diff --git a/openpype/tools/publisher/window.py b/openpype/tools/publisher/window.py index b3138c3f45..20d9884788 100644 --- a/openpype/tools/publisher/window.py +++ b/openpype/tools/publisher/window.py @@ -189,7 +189,7 @@ class PublisherWindow(QtWidgets.QDialog): controller, content_stacked_widget ) - report_widget = ReportPageWidget(controller, parent) + report_widget = ReportPageWidget(controller, content_stacked_widget) # Details - Publish details publish_details_widget = PublishReportViewerWidget( From 4e704b1b0728a158ef824acef1601ede9d4162ee Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 11 Jan 2024 13:18:58 +0100 Subject: [PATCH 081/104] AYON: OpenPype addon dependencies (#6113) * click is required by openpype addon * removed Qt.py from dependencies * add six to openpype addon dependencies --- server_addon/openpype/client/pyproject.toml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server_addon/openpype/client/pyproject.toml b/server_addon/openpype/client/pyproject.toml index d8de9d4d96..b5978f0498 100644 --- a/server_addon/openpype/client/pyproject.toml +++ b/server_addon/openpype/client/pyproject.toml @@ -7,15 +7,16 @@ python = ">=3.9.1,<3.10" aiohttp_json_rpc = "*" # TVPaint server aiohttp-middlewares = "^2.0.0" wsrpc_aiohttp = "^3.1.1" # websocket server +Click = "^8" clique = "1.6.*" jsonschema = "^2.6.0" pymongo = "^3.11.2" log4mongo = "^1.7" pyblish-base = "^1.8.11" pynput = "^1.7.2" # Timers manager - TODO remove -"Qt.py" = "^1.3.3" -qtawesome = "0.7.3" speedcopy = "^2.1" +six = "^1.15" +qtawesome = "0.7.3" [ayon.runtimeDependencies] OpenTimelineIO = "0.14.1" From adb7e19c232adad1e9fb122ba5cffdd55970916b Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 11 Jan 2024 13:21:41 +0100 Subject: [PATCH 082/104] Publisher: Window is not always on top (#6107) * make publisher a window without always on top * put publisher window to the top on process * make sure screenshot window is active * removed unnecessary variable --- .../publisher/widgets/screenshot_widget.py | 8 +++- openpype/tools/publisher/window.py | 38 ++++++++++++++----- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/openpype/tools/publisher/widgets/screenshot_widget.py b/openpype/tools/publisher/widgets/screenshot_widget.py index 3504b419b4..37b958c1c7 100644 --- a/openpype/tools/publisher/widgets/screenshot_widget.py +++ b/openpype/tools/publisher/widgets/screenshot_widget.py @@ -18,10 +18,11 @@ class ScreenMarquee(QtWidgets.QDialog): super(ScreenMarquee, self).__init__(parent=parent) self.setWindowFlags( - QtCore.Qt.FramelessWindowHint + QtCore.Qt.Window + | QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.CustomizeWindowHint - | QtCore.Qt.Tool) + ) self.setAttribute(QtCore.Qt.WA_TranslucentBackground) self.setCursor(QtCore.Qt.CrossCursor) self.setMouseTracking(True) @@ -210,6 +211,9 @@ class ScreenMarquee(QtWidgets.QDialog): """ tool = cls() + # Activate so Escape event is not ignored. + tool.setWindowState(QtCore.Qt.WindowActive) + # Exec dialog and return captured pixmap. tool.exec_() return tool.get_captured_pixmap() diff --git a/openpype/tools/publisher/window.py b/openpype/tools/publisher/window.py index 20d9884788..5dd6998b24 100644 --- a/openpype/tools/publisher/window.py +++ b/openpype/tools/publisher/window.py @@ -42,7 +42,7 @@ from .widgets import ( ) -class PublisherWindow(QtWidgets.QDialog): +class PublisherWindow(QtWidgets.QWidget): """Main window of publisher.""" default_width = 1300 default_height = 800 @@ -50,7 +50,7 @@ class PublisherWindow(QtWidgets.QDialog): publish_footer_spacer = 2 def __init__(self, parent=None, controller=None, reset_on_show=None): - super(PublisherWindow, self).__init__(parent) + super(PublisherWindow, self).__init__() self.setObjectName("PublishWindow") @@ -64,17 +64,12 @@ class PublisherWindow(QtWidgets.QDialog): if reset_on_show is None: reset_on_show = True - if parent is None: - on_top_flag = QtCore.Qt.WindowStaysOnTopHint - else: - on_top_flag = QtCore.Qt.Dialog - self.setWindowFlags( - QtCore.Qt.WindowTitleHint + QtCore.Qt.Window + | QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowMaximizeButtonHint | QtCore.Qt.WindowMinimizeButtonHint | QtCore.Qt.WindowCloseButtonHint - | on_top_flag ) if controller is None: @@ -299,6 +294,12 @@ class PublisherWindow(QtWidgets.QDialog): controller.event_system.add_callback( "publish.process.stopped", self._on_publish_stop ) + controller.event_system.add_callback( + "publish.process.instance.changed", self._on_instance_change + ) + controller.event_system.add_callback( + "publish.process.plugin.changed", self._on_plugin_change + ) controller.event_system.add_callback( "show.card.message", self._on_overlay_message ) @@ -557,6 +558,18 @@ class PublisherWindow(QtWidgets.QDialog): self._reset_on_show = False self.reset() + def _make_sure_on_top(self): + """Raise window to top and activate it. + + This may not work for some DCCs without Qt. + """ + + if not self._window_is_visible: + self.show() + + self.setWindowState(QtCore.Qt.WindowActive) + self.raise_() + def _checks_before_save(self, explicit_save): """Save of changes may trigger some issues. @@ -869,6 +882,12 @@ class PublisherWindow(QtWidgets.QDialog): if self._is_on_create_tab(): self._go_to_publish_tab() + def _on_instance_change(self): + self._make_sure_on_top() + + def _on_plugin_change(self): + self._make_sure_on_top() + def _on_publish_validated_change(self, event): if event["value"]: self._validate_btn.setEnabled(False) @@ -879,6 +898,7 @@ class PublisherWindow(QtWidgets.QDialog): self._comment_input.setText("") def _on_publish_stop(self): + self._make_sure_on_top() self._set_publish_overlay_visibility(False) self._reset_btn.setEnabled(True) self._stop_btn.setEnabled(False) From dbf02e266f106c22e43c457705d0cb10acce5411 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 11 Jan 2024 21:10:13 +0800 Subject: [PATCH 083/104] create camera node with Camera4 instead of Camera2 in Nuke 14.0 --- openpype/hosts/nuke/api/lib.py | 17 +++++++++++++++++ .../hosts/nuke/plugins/create/create_camera.py | 5 ++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/openpype/hosts/nuke/api/lib.py b/openpype/hosts/nuke/api/lib.py index 88c587faf6..785727070d 100644 --- a/openpype/hosts/nuke/api/lib.py +++ b/openpype/hosts/nuke/api/lib.py @@ -3483,3 +3483,20 @@ def get_filenames_without_hash(filename, frame_start, frame_end): new_filename = filename_without_hashes.format(frame) filenames.append(new_filename) return filenames + + +def create_camera_node_by_version(): + """Function to create the camera with the latest node class + For Nuke version 14.0 or later, the Camera4 camera node class + would be used + For the version before, the Camera2 camera node class + would be used + Returns: + Node: camera node + """ + nuke_version = nuke.NUKE_VERSION_STRING + nuke_number_version = next(ver for ver in re.findall("\d+\.\d+", nuke_version)) + if float(nuke_number_version) >= 14.0: + return nuke.createNode("Camera4") + else: + return nuke.createNode("Camera2") diff --git a/openpype/hosts/nuke/plugins/create/create_camera.py b/openpype/hosts/nuke/plugins/create/create_camera.py index b84280b11b..be9c69213e 100644 --- a/openpype/hosts/nuke/plugins/create/create_camera.py +++ b/openpype/hosts/nuke/plugins/create/create_camera.py @@ -4,6 +4,9 @@ from openpype.hosts.nuke.api import ( NukeCreatorError, maintained_selection ) +from openpype.hosts.nuke.api.lib import ( + create_camera_node_by_version +) class CreateCamera(NukeCreator): @@ -32,7 +35,7 @@ class CreateCamera(NukeCreator): "Creator error: Select only camera node type") created_node = self.selected_nodes[0] else: - created_node = nuke.createNode("Camera2") + created_node = create_camera_node_by_version() created_node["tile_color"].setValue( int(self.node_color, 16)) From b51f61796d6cd40417575f14cf89be72bdbb2990 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 11 Jan 2024 21:17:22 +0800 Subject: [PATCH 084/104] hound shut --- openpype/hosts/nuke/api/lib.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openpype/hosts/nuke/api/lib.py b/openpype/hosts/nuke/api/lib.py index 785727070d..f408ff1a9d 100644 --- a/openpype/hosts/nuke/api/lib.py +++ b/openpype/hosts/nuke/api/lib.py @@ -3495,7 +3495,8 @@ def create_camera_node_by_version(): Node: camera node """ nuke_version = nuke.NUKE_VERSION_STRING - nuke_number_version = next(ver for ver in re.findall("\d+\.\d+", nuke_version)) + nuke_number_version = next(ver for ver in + re.findall("\d+\.\d+", nuke_version)) if float(nuke_number_version) >= 14.0: return nuke.createNode("Camera4") else: From ee8294824e821c3e8bb45f2f305c8bd9b961b614 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 11 Jan 2024 21:19:21 +0800 Subject: [PATCH 085/104] hound shut --- openpype/hosts/nuke/api/lib.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/nuke/api/lib.py b/openpype/hosts/nuke/api/lib.py index f408ff1a9d..b879c96c9e 100644 --- a/openpype/hosts/nuke/api/lib.py +++ b/openpype/hosts/nuke/api/lib.py @@ -3495,8 +3495,9 @@ def create_camera_node_by_version(): Node: camera node """ nuke_version = nuke.NUKE_VERSION_STRING - nuke_number_version = next(ver for ver in - re.findall("\d+\.\d+", nuke_version)) + nuke_number_version = next( + ver for ver in re.findall( + r"\d+\.\d+", nuke_version)) if float(nuke_number_version) >= 14.0: return nuke.createNode("Camera4") else: From 199ff9944b3371105933bfaa4756e8f03833f11e Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 11 Jan 2024 22:50:29 +0800 Subject: [PATCH 086/104] Jakub's comment - using nuke.NUKE_VERSION_MAJOR for version check instead --- openpype/hosts/nuke/api/lib.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/openpype/hosts/nuke/api/lib.py b/openpype/hosts/nuke/api/lib.py index b879c96c9e..7ba53caead 100644 --- a/openpype/hosts/nuke/api/lib.py +++ b/openpype/hosts/nuke/api/lib.py @@ -3494,11 +3494,8 @@ def create_camera_node_by_version(): Returns: Node: camera node """ - nuke_version = nuke.NUKE_VERSION_STRING - nuke_number_version = next( - ver for ver in re.findall( - r"\d+\.\d+", nuke_version)) - if float(nuke_number_version) >= 14.0: + nuke_number_version = nuke.NUKE_VERSION_MAJOR + if nuke_number_version >= 14: return nuke.createNode("Camera4") else: return nuke.createNode("Camera2") From 629b49c18209652f1c3a931e1f06b791b0180d92 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 11 Jan 2024 16:15:45 +0100 Subject: [PATCH 087/104] Blender: Workfile instance update fix (#6048) * make sure workfile instance has always available 'instance_node' * create CONTAINERS node if does not exist yet --- .../blender/plugins/create/create_workfile.py | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/openpype/hosts/blender/plugins/create/create_workfile.py b/openpype/hosts/blender/plugins/create/create_workfile.py index ceec3e0552..6b168f4c84 100644 --- a/openpype/hosts/blender/plugins/create/create_workfile.py +++ b/openpype/hosts/blender/plugins/create/create_workfile.py @@ -25,7 +25,7 @@ class CreateWorkfile(BaseCreator, AutoCreator): def create(self): """Create workfile instances.""" - existing_instance = next( + workfile_instance = next( ( instance for instance in self.create_context.instances if instance.creator_identifier == self.identifier @@ -39,14 +39,14 @@ class CreateWorkfile(BaseCreator, AutoCreator): host_name = self.create_context.host_name existing_asset_name = None - if existing_instance is not None: + if workfile_instance is not None: if AYON_SERVER_ENABLED: - existing_asset_name = existing_instance.get("folderPath") + existing_asset_name = workfile_instance.get("folderPath") if existing_asset_name is None: - existing_asset_name = existing_instance["asset"] + existing_asset_name = workfile_instance["asset"] - if not existing_instance: + if not workfile_instance: asset_doc = get_asset_by_name(project_name, asset_name) subset_name = self.get_subset_name( task_name, task_name, asset_doc, project_name, host_name @@ -66,19 +66,18 @@ class CreateWorkfile(BaseCreator, AutoCreator): asset_doc, project_name, host_name, - existing_instance, + workfile_instance, ) ) self.log.info("Auto-creating workfile instance...") - current_instance = CreatedInstance( + workfile_instance = CreatedInstance( self.family, subset_name, data, self ) - instance_node = bpy.data.collections.get(AVALON_CONTAINERS, {}) - current_instance.transient_data["instance_node"] = instance_node - self._add_instance_to_context(current_instance) + self._add_instance_to_context(workfile_instance) + elif ( existing_asset_name != asset_name - or existing_instance["task"] != task_name + or workfile_instance["task"] != task_name ): # Update instance context if it's different asset_doc = get_asset_by_name(project_name, asset_name) @@ -86,12 +85,17 @@ class CreateWorkfile(BaseCreator, AutoCreator): task_name, task_name, asset_doc, project_name, host_name ) if AYON_SERVER_ENABLED: - existing_instance["folderPath"] = asset_name + workfile_instance["folderPath"] = asset_name else: - existing_instance["asset"] = asset_name + workfile_instance["asset"] = asset_name - existing_instance["task"] = task_name - existing_instance["subset"] = subset_name + workfile_instance["task"] = task_name + workfile_instance["subset"] = subset_name + + instance_node = bpy.data.collections.get(AVALON_CONTAINERS) + if not instance_node: + instance_node = bpy.data.collections.new(name=AVALON_CONTAINERS) + workfile_instance.transient_data["instance_node"] = instance_node def collect_instances(self): From 47cf95ed69a4bb4ad4f5a9f2b5b09f145a94bc23 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 12 Jan 2024 10:13:20 +0100 Subject: [PATCH 088/104] Chore: Template data for editorial publishing (#6120) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * start with anatomy data without anatomy updates * added ability to fill template data for editorial instances too * do not autofix editorial data in collect resources path * fix childs access --------- Co-authored-by: Jakub Ježek --- .../publish/collect_anatomy_instance_data.py | 211 ++++++++++++++---- .../plugins/publish/collect_resources_path.py | 13 -- 2 files changed, 168 insertions(+), 56 deletions(-) diff --git a/openpype/plugins/publish/collect_anatomy_instance_data.py b/openpype/plugins/publish/collect_anatomy_instance_data.py index 1b4b44e40e..0a34848166 100644 --- a/openpype/plugins/publish/collect_anatomy_instance_data.py +++ b/openpype/plugins/publish/collect_anatomy_instance_data.py @@ -190,47 +190,18 @@ class CollectAnatomyInstanceData(pyblish.api.ContextPlugin): project_task_types = project_doc["config"]["tasks"] for instance in context: - asset_doc = instance.data.get("assetEntity") - anatomy_updates = { + anatomy_data = copy.deepcopy(context.data["anatomyData"]) + anatomy_data.update({ "family": instance.data["family"], "subset": instance.data["subset"], - } - if asset_doc: - parents = asset_doc["data"].get("parents") or list() - parent_name = project_doc["name"] - if parents: - parent_name = parents[-1] + }) - hierarchy = "/".join(parents) - anatomy_updates.update({ - "asset": asset_doc["name"], - "hierarchy": hierarchy, - "parent": parent_name, - "folder": { - "name": asset_doc["name"], - }, - }) - - # Task - task_type = None - task_name = instance.data.get("task") - if task_name: - asset_tasks = asset_doc["data"]["tasks"] - task_type = asset_tasks.get(task_name, {}).get("type") - task_code = ( - project_task_types - .get(task_type, {}) - .get("short_name") - ) - anatomy_updates["task"] = { - "name": task_name, - "type": task_type, - "short": task_code - } + self._fill_asset_data(instance, project_doc, anatomy_data) + self._fill_task_data(instance, project_task_types, anatomy_data) # Define version if self.follow_workfile_version: - version_number = context.data('version') + version_number = context.data("version") else: version_number = instance.data.get("version") @@ -242,6 +213,9 @@ class CollectAnatomyInstanceData(pyblish.api.ContextPlugin): # If version is not specified for instance or context if version_number is None: + task_data = anatomy_data.get("task") or {} + task_name = task_data.get("name") + task_type = task_data.get("type") version_number = get_versioning_start( context.data["projectName"], instance.context.data["hostName"], @@ -250,29 +224,26 @@ class CollectAnatomyInstanceData(pyblish.api.ContextPlugin): family=instance.data["family"], subset=instance.data["subset"] ) - anatomy_updates["version"] = version_number + anatomy_data["version"] = version_number # Additional data resolution_width = instance.data.get("resolutionWidth") if resolution_width: - anatomy_updates["resolution_width"] = resolution_width + anatomy_data["resolution_width"] = resolution_width resolution_height = instance.data.get("resolutionHeight") if resolution_height: - anatomy_updates["resolution_height"] = resolution_height + anatomy_data["resolution_height"] = resolution_height pixel_aspect = instance.data.get("pixelAspect") if pixel_aspect: - anatomy_updates["pixel_aspect"] = float( + anatomy_data["pixel_aspect"] = float( "{:0.2f}".format(float(pixel_aspect)) ) fps = instance.data.get("fps") if fps: - anatomy_updates["fps"] = float("{:0.2f}".format(float(fps))) - - anatomy_data = copy.deepcopy(context.data["anatomyData"]) - anatomy_data.update(anatomy_updates) + anatomy_data["fps"] = float("{:0.2f}".format(float(fps))) # Store anatomy data instance.data["projectEntity"] = project_doc @@ -288,3 +259,157 @@ class CollectAnatomyInstanceData(pyblish.api.ContextPlugin): instance_name, json.dumps(anatomy_data, indent=4) )) + + def _fill_asset_data(self, instance, project_doc, anatomy_data): + # QUESTION should we make sure that all asset data are poped if asset + # data cannot be found? + # - 'asset', 'hierarchy', 'parent', 'folder' + asset_doc = instance.data.get("assetEntity") + if asset_doc: + parents = asset_doc["data"].get("parents") or list() + parent_name = project_doc["name"] + if parents: + parent_name = parents[-1] + + hierarchy = "/".join(parents) + anatomy_data.update({ + "asset": asset_doc["name"], + "hierarchy": hierarchy, + "parent": parent_name, + "folder": { + "name": asset_doc["name"], + }, + }) + return + + if instance.data.get("newAssetPublishing"): + hierarchy = instance.data["hierarchy"] + anatomy_data["hierarchy"] = hierarchy + + parent_name = project_doc["name"] + if hierarchy: + parent_name = hierarchy.split("/")[-1] + + asset_name = instance.data["asset"].split("/")[-1] + anatomy_data.update({ + "asset": asset_name, + "hierarchy": hierarchy, + "parent": parent_name, + "folder": { + "name": asset_name, + }, + }) + + def _fill_task_data(self, instance, project_task_types, anatomy_data): + # QUESTION should we make sure that all task data are poped if task + # data cannot be resolved? + # - 'task' + + # Skip if there is no task + task_name = instance.data.get("task") + if not task_name: + return + + # Find task data based on asset entity + asset_doc = instance.data.get("assetEntity") + task_data = self._get_task_data_from_asset( + asset_doc, task_name, project_task_types + ) + if task_data: + # Fill task data + # - if we're in editorial, make sure the task type is filled + if ( + not instance.data.get("newAssetPublishing") + or task_data["type"] + ): + anatomy_data["task"] = task_data + return + + # New hierarchy is not created, so we can only skip rest of the logic + if not instance.data.get("newAssetPublishing"): + return + + # Try to find task data based on hierarchy context and asset name + hierarchy_context = instance.context.data.get("hierarchyContext") + asset_name = instance.data.get("asset") + if not hierarchy_context or not asset_name: + return + + project_name = instance.context.data["projectName"] + # OpenPype approach vs AYON approach + if "/" not in asset_name: + tasks_info = self._find_tasks_info_in_hierarchy( + hierarchy_context, asset_name + ) + else: + current_data = hierarchy_context.get(project_name, {}) + for key in asset_name.split("/"): + if key: + current_data = current_data.get("childs", {}).get(key, {}) + tasks_info = current_data.get("tasks", {}) + + task_info = tasks_info.get(task_name, {}) + task_type = task_info.get("type") + task_code = ( + project_task_types + .get(task_type, {}) + .get("short_name") + ) + anatomy_data["task"] = { + "name": task_name, + "type": task_type, + "short": task_code + } + + def _get_task_data_from_asset( + self, asset_doc, task_name, project_task_types + ): + """ + + Args: + asset_doc (Union[dict[str, Any], None]): Asset document. + task_name (Union[str, None]): Task name. + project_task_types (dict[str, dict[str, Any]]): Project task + types. + + Returns: + Union[dict[str, str], None]: Task data or None if not found. + """ + + if not asset_doc or not task_name: + return None + + asset_tasks = asset_doc["data"]["tasks"] + task_type = asset_tasks.get(task_name, {}).get("type") + task_code = ( + project_task_types + .get(task_type, {}) + .get("short_name") + ) + return { + "name": task_name, + "type": task_type, + "short": task_code + } + + def _find_tasks_info_in_hierarchy(self, hierarchy_context, asset_name): + """Find tasks info for an asset in editorial hierarchy. + + Args: + hierarchy_context (dict[str, Any]): Editorial hierarchy context. + asset_name (str): Asset name. + + Returns: + dict[str, dict[str, Any]]: Tasks info by name. + """ + + hierarchy_queue = collections.deque() + hierarchy_queue.append(hierarchy_context) + while hierarchy_queue: + item = hierarchy_context.popleft() + if asset_name in item: + return item[asset_name].get("tasks") or {} + + for subitem in item.values(): + hierarchy_queue.extend(subitem.get("childs") or []) + return {} diff --git a/openpype/plugins/publish/collect_resources_path.py b/openpype/plugins/publish/collect_resources_path.py index c8b67a3d05..6a871124f1 100644 --- a/openpype/plugins/publish/collect_resources_path.py +++ b/openpype/plugins/publish/collect_resources_path.py @@ -79,19 +79,6 @@ class CollectResourcesPath(pyblish.api.InstancePlugin): "representation": "TEMP" }) - # Add fill keys for editorial publishing creating new entity - # TODO handle in editorial plugin - if instance.data.get("newAssetPublishing"): - if "hierarchy" not in template_data: - template_data["hierarchy"] = instance.data["hierarchy"] - - if "asset" not in template_data: - asset_name = instance.data["asset"].split("/")[-1] - template_data["asset"] = asset_name - template_data["folder"] = { - "name": asset_name - } - publish_templates = anatomy.templates_obj["publish"] if "folder" in publish_templates: publish_folder = publish_templates["folder"].format_strict( From 046154037bc3514ef30d0448e2c7c1006d56970f Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Fri, 12 Jan 2024 10:44:01 +0100 Subject: [PATCH 089/104] Site Sync: small fixes in Loader (#6119) * Fix usage of correct values Returned item is dictionary of version_id: links, previous loop was looping through [[]]. * Fix usage of studio icon local and studio have both same provider, local_drive. Both of them should be differentiate by icon though. * Fix - pull only paths from icon_def Icon_def is dictionary with `type` and `path` keys, not directly 'path'. It must be massaged first. * Revert back, fixed in different PR Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> * Fix looping Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --------- Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- openpype/client/server/entity_links.py | 23 ++++++++++--------- .../tools/ayon_loader/models/site_sync.py | 15 ++++++++---- .../ayon_sceneinventory/models/site_sync.py | 4 ++-- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/openpype/client/server/entity_links.py b/openpype/client/server/entity_links.py index 368dcdcb9d..7fb9fbde6f 100644 --- a/openpype/client/server/entity_links.py +++ b/openpype/client/server/entity_links.py @@ -124,23 +124,24 @@ def get_linked_representation_id( if not versions_to_check: break - links = con.get_versions_links( + versions_links = con.get_versions_links( project_name, versions_to_check, link_types=link_types, link_direction="out") versions_to_check = set() - for link in links: - # Care only about version links - if link["entityType"] != "version": - continue - entity_id = link["entityId"] - # Skip already found linked version ids - if entity_id in linked_version_ids: - continue - linked_version_ids.add(entity_id) - versions_to_check.add(entity_id) + for links in versions_links.values(): + for link in links: + # Care only about version links + if link["entityType"] != "version": + continue + entity_id = link["entityId"] + # Skip already found linked version ids + if entity_id in linked_version_ids: + continue + linked_version_ids.add(entity_id) + versions_to_check.add(entity_id) linked_version_ids.remove(version_id) if not linked_version_ids: diff --git a/openpype/tools/ayon_loader/models/site_sync.py b/openpype/tools/ayon_loader/models/site_sync.py index 90852b6954..4b7ddee481 100644 --- a/openpype/tools/ayon_loader/models/site_sync.py +++ b/openpype/tools/ayon_loader/models/site_sync.py @@ -140,12 +140,10 @@ class SiteSyncModel: Union[dict[str, Any], None]: Site icon definition. """ - if not project_name: + if not project_name or not self.is_site_sync_enabled(project_name): return None - active_site = self.get_active_site(project_name) - provider = self._get_provider_for_site(project_name, active_site) - return self._get_provider_icon(provider) + return self._get_site_icon_def(project_name, active_site) def get_remote_site_icon_def(self, project_name): """Remote site icon definition. @@ -160,7 +158,14 @@ class SiteSyncModel: if not project_name or not self.is_site_sync_enabled(project_name): return None remote_site = self.get_remote_site(project_name) - provider = self._get_provider_for_site(project_name, remote_site) + return self._get_site_icon_def(project_name, remote_site) + + def _get_site_icon_def(self, project_name, site_name): + # use different icon for studio even if provider is 'local_drive' + if site_name == self._site_sync_addon.DEFAULT_SITE: + provider = "studio" + else: + provider = self._get_provider_for_site(project_name, site_name) return self._get_provider_icon(provider) def get_version_sync_availability(self, project_name, version_ids): diff --git a/openpype/tools/ayon_sceneinventory/models/site_sync.py b/openpype/tools/ayon_sceneinventory/models/site_sync.py index 1297137cb0..0101f6c88e 100644 --- a/openpype/tools/ayon_sceneinventory/models/site_sync.py +++ b/openpype/tools/ayon_sceneinventory/models/site_sync.py @@ -42,8 +42,8 @@ class SiteSyncModel: if not self.is_sync_server_enabled(): return {} - site_sync = self._get_sync_server_module() - return site_sync.get_site_icons() + site_sync_addon = self._get_sync_server_module() + return site_sync_addon.get_site_icons() def get_sites_information(self): return { From df7b8683716ff5bb2ab6b648ab22a62e2a555fd3 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 12 Jan 2024 18:32:42 +0800 Subject: [PATCH 090/104] bugfix the thumbnail error when publishing with emissive map & maps without RGB channel --- openpype/hosts/substancepainter/api/lib.py | 50 +++++++++++++++++++ .../publish/collect_textureset_images.py | 20 +++++--- 2 files changed, 62 insertions(+), 8 deletions(-) diff --git a/openpype/hosts/substancepainter/api/lib.py b/openpype/hosts/substancepainter/api/lib.py index 1cb480b552..f46426388b 100644 --- a/openpype/hosts/substancepainter/api/lib.py +++ b/openpype/hosts/substancepainter/api/lib.py @@ -643,3 +643,53 @@ def prompt_new_file_with_mesh(mesh_filepath): return return project_mesh + + +def has_rgb_channel_in_texture_set(texture_set_name, map_identifier): + """Function to check whether the texture has RGB channel. + + Args: + texture_set_name (str): Name of Texture Set + map_identifier (str): Map identifier + + Returns: + colorspace_dict: A dictionary which stores the boolean + value of textures having RGB channels + """ + texture_stack = substance_painter.textureset.Stack.from_name(texture_set_name) + # 2D_View is always True as it exports all texture maps + colorspace_dict = {"2D_View": True} + colorspace_dict["BaseColor"] = texture_stack.get_channel( + substance_painter.textureset.ChannelType.BaseColor).is_color() + colorspace_dict["Roughness"] = texture_stack.get_channel( + substance_painter.textureset.ChannelType.Roughness).is_color() + colorspace_dict["Metallic"] = texture_stack.get_channel( + substance_painter.textureset.ChannelType.Metallic).is_color() + colorspace_dict["Height"] = texture_stack.get_channel( + substance_painter.textureset.ChannelType.Height).is_color() + colorspace_dict["Normal"] = texture_stack.get_channel( + substance_painter.textureset.ChannelType.Normal).is_color() + return colorspace_dict.get(map_identifier, False) + + +def texture_set_filtering(texture_set_same, template): + """Function to check whether some specific textures(e.g. Emissive) + are parts of the texture stack in Substance Painter + + Args: + texture_set_same (str): Name of Texture Set + template (str): texture template name + + Returns: + texture_filter: A dictionary which stores the boolean + value of whether the texture exist in the channel. + """ + texture_filter = {} + channel_stack = substance_painter.textureset.Stack.from_name( + texture_set_same) + has_emissive = channel_stack.has_channel( + substance_painter.textureset.ChannelType.Emissive) + map_identifier = strip_template(template) + if map_identifier == "Emissive": + texture_filter[map_identifier] = has_emissive + return texture_filter.get(map_identifier, True) diff --git a/openpype/hosts/substancepainter/plugins/publish/collect_textureset_images.py b/openpype/hosts/substancepainter/plugins/publish/collect_textureset_images.py index 316f72509e..4c3398d5b4 100644 --- a/openpype/hosts/substancepainter/plugins/publish/collect_textureset_images.py +++ b/openpype/hosts/substancepainter/plugins/publish/collect_textureset_images.py @@ -7,7 +7,9 @@ from openpype.pipeline import publish import substance_painter.textureset from openpype.hosts.substancepainter.api.lib import ( get_parsed_export_maps, - strip_template + strip_template, + has_rgb_channel_in_texture_set, + texture_set_filtering ) from openpype.pipeline.create import get_subset_name from openpype.client import get_asset_by_name @@ -39,11 +41,12 @@ class CollectTextureSet(pyblish.api.InstancePlugin): for (texture_set_name, stack_name), template_maps in maps.items(): self.log.info(f"Processing {texture_set_name}/{stack_name}") for template, outputs in template_maps.items(): - self.log.info(f"Processing {template}") - self.create_image_instance(instance, template, outputs, - asset_doc=asset_doc, - texture_set_name=texture_set_name, - stack_name=stack_name) + if texture_set_filtering(texture_set_name, template): + self.log.info(f"Processing {template}") + self.create_image_instance(instance, template, outputs, + asset_doc=asset_doc, + texture_set_name=texture_set_name, + stack_name=stack_name) def create_image_instance(self, instance, template, outputs, asset_doc, texture_set_name, stack_name): @@ -78,7 +81,6 @@ class CollectTextureSet(pyblish.api.InstancePlugin): # Always include the map identifier map_identifier = strip_template(template) suffix += f".{map_identifier}" - image_subset = get_subset_name( # TODO: The family actually isn't 'texture' currently but for now # this is only done so the subset name starts with 'texture' @@ -132,7 +134,9 @@ class CollectTextureSet(pyblish.api.InstancePlugin): # Store color space with the instance # Note: The extractor will assign it to the representation colorspace = outputs[0].get("colorSpace") - if colorspace: + has_rgb_channel = has_rgb_channel_in_texture_set( + texture_set_name, map_identifier) + if colorspace and has_rgb_channel: self.log.debug(f"{image_subset} colorspace: {colorspace}") image_instance.data["colorspace"] = colorspace From 72848657af4e52aa6d037fbf1f35c2b4548efeee Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 12 Jan 2024 18:44:18 +0800 Subject: [PATCH 091/104] hound shut --- openpype/hosts/substancepainter/api/lib.py | 6 ++++-- .../plugins/publish/collect_textureset_images.py | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/openpype/hosts/substancepainter/api/lib.py b/openpype/hosts/substancepainter/api/lib.py index f46426388b..67229a75bf 100644 --- a/openpype/hosts/substancepainter/api/lib.py +++ b/openpype/hosts/substancepainter/api/lib.py @@ -656,7 +656,9 @@ def has_rgb_channel_in_texture_set(texture_set_name, map_identifier): colorspace_dict: A dictionary which stores the boolean value of textures having RGB channels """ - texture_stack = substance_painter.textureset.Stack.from_name(texture_set_name) + texture_stack = ( + substance_painter.textureset.Stack.from_name(texture_set_name) + ) # 2D_View is always True as it exports all texture maps colorspace_dict = {"2D_View": True} colorspace_dict["BaseColor"] = texture_stack.get_channel( @@ -686,7 +688,7 @@ def texture_set_filtering(texture_set_same, template): """ texture_filter = {} channel_stack = substance_painter.textureset.Stack.from_name( - texture_set_same) + texture_set_same) has_emissive = channel_stack.has_channel( substance_painter.textureset.ChannelType.Emissive) map_identifier = strip_template(template) diff --git a/openpype/hosts/substancepainter/plugins/publish/collect_textureset_images.py b/openpype/hosts/substancepainter/plugins/publish/collect_textureset_images.py index 4c3398d5b4..f535bfa2a6 100644 --- a/openpype/hosts/substancepainter/plugins/publish/collect_textureset_images.py +++ b/openpype/hosts/substancepainter/plugins/publish/collect_textureset_images.py @@ -44,9 +44,9 @@ class CollectTextureSet(pyblish.api.InstancePlugin): if texture_set_filtering(texture_set_name, template): self.log.info(f"Processing {template}") self.create_image_instance(instance, template, outputs, - asset_doc=asset_doc, - texture_set_name=texture_set_name, - stack_name=stack_name) + asset_doc=asset_doc, + texture_set_name=texture_set_name, + stack_name=stack_name) def create_image_instance(self, instance, template, outputs, asset_doc, texture_set_name, stack_name): From 6410f381f34625defa91250a8e529e47cb40a8a6 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 12 Jan 2024 18:45:40 +0800 Subject: [PATCH 092/104] hound shut --- .../plugins/publish/collect_textureset_images.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/openpype/hosts/substancepainter/plugins/publish/collect_textureset_images.py b/openpype/hosts/substancepainter/plugins/publish/collect_textureset_images.py index f535bfa2a6..9d6aa06872 100644 --- a/openpype/hosts/substancepainter/plugins/publish/collect_textureset_images.py +++ b/openpype/hosts/substancepainter/plugins/publish/collect_textureset_images.py @@ -43,10 +43,11 @@ class CollectTextureSet(pyblish.api.InstancePlugin): for template, outputs in template_maps.items(): if texture_set_filtering(texture_set_name, template): self.log.info(f"Processing {template}") - self.create_image_instance(instance, template, outputs, - asset_doc=asset_doc, - texture_set_name=texture_set_name, - stack_name=stack_name) + self.create_image_instance( + instance, template, outputs, + asset_doc=asset_doc, + texture_set_name=texture_set_name, + stack_name=stack_name) def create_image_instance(self, instance, template, outputs, asset_doc, texture_set_name, stack_name): From 1eb7e59b931e146481253af9fab501120d1d6156 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 12 Jan 2024 12:25:00 +0100 Subject: [PATCH 093/104] Kitsu clear credentials are safe (#6116) --- openpype/modules/kitsu/utils/credentials.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/openpype/modules/kitsu/utils/credentials.py b/openpype/modules/kitsu/utils/credentials.py index 941343cc8d..c471b56907 100644 --- a/openpype/modules/kitsu/utils/credentials.py +++ b/openpype/modules/kitsu/utils/credentials.py @@ -64,8 +64,10 @@ def clear_credentials(): user_registry = OpenPypeSecureRegistry("kitsu_user") # Set local settings - user_registry.delete_item("login") - user_registry.delete_item("password") + if user_registry.get_item("login", None) is not None: + user_registry.delete_item("login") + if user_registry.get_item("password", None) is not None: + user_registry.delete_item("password") def save_credentials(login: str, password: str): @@ -92,8 +94,9 @@ def load_credentials() -> Tuple[str, str]: # Get user registry user_registry = OpenPypeSecureRegistry("kitsu_user") - return user_registry.get_item("login", None), user_registry.get_item( - "password", None + return ( + user_registry.get_item("login", None), + user_registry.get_item("password", None) ) From f88ab85cc1d586e71e6a4ccfb975ed7d5c75aef8 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 12 Jan 2024 13:50:34 +0100 Subject: [PATCH 094/104] SceneInventory: Fix site sync icon conversion (#6123) * use 'get_qt_icon' to convert icon definition * check if site sync is enabled before getting sites info * convert containers to list * Fix wrong method name --------- Co-authored-by: Petr Kalis --- openpype/tools/ayon_sceneinventory/control.py | 4 ++-- openpype/tools/ayon_sceneinventory/model.py | 5 +++-- openpype/tools/ayon_sceneinventory/models/site_sync.py | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/openpype/tools/ayon_sceneinventory/control.py b/openpype/tools/ayon_sceneinventory/control.py index 6111d7e43b..3b063ff72e 100644 --- a/openpype/tools/ayon_sceneinventory/control.py +++ b/openpype/tools/ayon_sceneinventory/control.py @@ -84,9 +84,9 @@ class SceneInventoryController: def get_containers(self): host = self._host if isinstance(host, ILoadHost): - return host.get_containers() + return list(host.get_containers()) elif hasattr(host, "ls"): - return host.ls() + return list(host.ls()) return [] # Site Sync methods diff --git a/openpype/tools/ayon_sceneinventory/model.py b/openpype/tools/ayon_sceneinventory/model.py index 16924b0a7e..f4450f0ac3 100644 --- a/openpype/tools/ayon_sceneinventory/model.py +++ b/openpype/tools/ayon_sceneinventory/model.py @@ -23,6 +23,7 @@ from openpype.pipeline import ( ) from openpype.style import get_default_entity_icon_color from openpype.tools.utils.models import TreeModel, Item +from openpype.tools.ayon_utils.widgets import get_qt_icon def walk_hierarchy(node): @@ -71,8 +72,8 @@ class InventoryModel(TreeModel): site_icons = self._controller.get_site_provider_icons() self._site_icons = { - provider: QtGui.QIcon(icon_path) - for provider, icon_path in site_icons.items() + provider: get_qt_icon(icon_def) + for provider, icon_def in site_icons.items() } def outdated(self, item): diff --git a/openpype/tools/ayon_sceneinventory/models/site_sync.py b/openpype/tools/ayon_sceneinventory/models/site_sync.py index 0101f6c88e..bd65ad1778 100644 --- a/openpype/tools/ayon_sceneinventory/models/site_sync.py +++ b/openpype/tools/ayon_sceneinventory/models/site_sync.py @@ -150,23 +150,23 @@ class SiteSyncModel: return self._remote_site_provider def _cache_sites(self): - site_sync = self._get_sync_server_module() active_site = None remote_site = None active_site_provider = None remote_site_provider = None - if site_sync is not None: + if self.is_sync_server_enabled(): + site_sync = self._get_sync_server_module() project_name = self._controller.get_current_project_name() active_site = site_sync.get_active_site(project_name) remote_site = site_sync.get_remote_site(project_name) active_site_provider = "studio" remote_site_provider = "studio" if active_site != "studio": - active_site_provider = site_sync.get_active_provider( + active_site_provider = site_sync.get_provider_for_site( project_name, active_site ) if remote_site != "studio": - remote_site_provider = site_sync.get_active_provider( + remote_site_provider = site_sync.get_provider_for_site( project_name, remote_site ) From 946b9318b66b96c1606e9d3805024a431e5be2a1 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 12 Jan 2024 13:51:08 +0100 Subject: [PATCH 095/104] add 'outputName' to thumbnail representation (#6114) --- openpype/plugins/publish/extract_thumbnail_from_source.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openpype/plugins/publish/extract_thumbnail_from_source.py b/openpype/plugins/publish/extract_thumbnail_from_source.py index 401a5d615d..33cbf6d9bf 100644 --- a/openpype/plugins/publish/extract_thumbnail_from_source.py +++ b/openpype/plugins/publish/extract_thumbnail_from_source.py @@ -65,7 +65,8 @@ class ExtractThumbnailFromSource(pyblish.api.InstancePlugin): "files": dst_filename, "stagingDir": dst_staging, "thumbnail": True, - "tags": ["thumbnail"] + "tags": ["thumbnail"], + "outputName": "thumbnail", } # adding representation From c506813c345429873e54e10c0cc42fa20517bdab Mon Sep 17 00:00:00 2001 From: Ynbot Date: Fri, 12 Jan 2024 12:59:28 +0000 Subject: [PATCH 096/104] [Automated] Release --- CHANGELOG.md | 256 ++++++++++++++++++++++++++++++++++++++++++++ openpype/version.py | 2 +- pyproject.toml | 2 +- 3 files changed, 258 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a21882008..7b51fade6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,262 @@ # Changelog +## [3.18.3](https://github.com/ynput/OpenPype/tree/3.18.3) + + +[Full Changelog](https://github.com/ynput/OpenPype/compare/3.18.2...3.18.3) + +### **🚀 Enhancements** + + +
+Maya: Apply initial viewport shader for Redshift Proxy after loading #6102 + +When the published redshift proxy is being loaded, the shader of the proxy is missing. This is different from the manual load through creating redshift proxy for files. This PR is to assign the default lambert to the redshift proxy, which replicates the same approach when the user manually loads the proxy with filepath. + + +___ + +
+ + +
+General: We should keep current subset version when we switch only the representation type #4629 + +When we switch only the representation type of subsets, we should not get the representation from the last version of the subset. + + +___ + +
+ + +
+Houdini: Add loader for redshift proxy family #5948 + +Loader for Redshift Proxy in Houdini (Thanks for @BigRoy contribution) + + +___ + +
+ + +
+AfterEffects: exposing Deadline pools fields in Publisher UI #6079 + +Deadline pools might be adhoc set by an artist during publishing. AfterEffects implementation wasn't providing this. + + +___ + +
+ + +
+Chore: Event callbacks can have order #6080 + +Event callbacks can have order in which are called, and fixed issue with getting function name and file when using `partial` function as callback. + + +___ + +
+ + +
+AYON: OpenPype addon defines runtime dependencies #6095 + +Moved runtime dependencies from ayon-launcher to openpype addon. + + +___ + +
+ + +
+Max: User's setting for scene unit scale #6097 + +Options for users to set the default scene unit scale for their scenes.AYONLegacy OP + + +___ + +
+ + +
+Chore: Remove deprecated templates profiles #6103 + +Remove deprecated usage of template profiles from settings. + + +___ + +
+ + +
+Publisher: Window is not always on top #6107 + +Goal of this PR is to avoid using `WindowStaysOnTopHint` which causes issues, especially in cases when DCC shows a popup dialog that is behind the window, in that case both Publisher and DCC are frozen and there is nothing to do. + + +___ + +
+ + +
+Houdini: add split job export support for Redshift ROP #6108 + +This is adding support for splitting of export and render jobs for Redshift as is already implemented for Vray, Mantra and Arnold. + + +___ + +
+ + +
+Fusion: automatic installation of PySide2 #6111 + +This PR adds hook which tries to check if PySide2 is installed in Python used by Fusion and if not, it tries to install it automatically. + + +___ + +
+ + +
+AYON: OpenPype addon dependencies #6113 + +Added `click` and `six` to requirements of openpype addon, and removed `Qt.py` requirement, which is not used anywhere. + + +___ + +
+ + +
+Chore: Thumbnail representation has 'outputName' #6114 + +Add thumbnail output name to thumbnail representation to prevent same output filename during integration. + + +___ + +
+ + +
+Kitsu: Clear credentials is safe #6116 + +Do not remove not existing keyring items. + + +___ + +
+ +### **🐛 Bug fixes** + + +
+Maya: bug fix the playblast without textures #5942 + +Bug fix the texture not being displayed when users enable texture placement in the OP/AYON setting + + +___ + +
+ + +
+Blender: Workfile instance update fix #6048 + +Make sure workfile instance has always available 'instance_node' in transient data. + + +___ + +
+ + +
+Publisher: Fix issue with parenting of widgets #6106 + +Don't use publisher window parent (usually main DCC window) as parent for report widget. + + +___ + +
+ + +
+:wrench: fix and update pydocstyle configuration #6109 + +Fix pydocstyle configuration and move it to `pyproject.toml` + + +___ + +
+ + +
+Nuke: Create camera node with the latest camera node class in Nuke 14 #6118 + +Creating instance fails for certain cameras, and it seems to only exist in Nuke 14. The reason of causing that contributes to the new camera node class `Camera4` while the camera creator is working with the `Camera2` class. + + +___ + +
+ + +
+Site Sync: small fixes in Loader #6119 + +Resolves issue: +- local and studio icons were same, they should be different +- `TypeError: string indices must be integers` error when downloading/uploading workfiles + + +___ + +
+ + +
+Chore: Template data for editorial publishing #6120 + +Template data for editorial publishing are filled during `CollectInstanceAnatomyData`. The structure for editorial is determined, as it's required for ExtractHierarchy AYON/OpenPype plugins. + + +___ + +
+ + +
+SceneInventory: Fix site sync icon conversion #6123 + +Use 'get_qt_icon' to convert icon definitions from site sync. + + +___ + +
+ + + + ## [3.18.2](https://github.com/ynput/OpenPype/tree/3.18.2) diff --git a/openpype/version.py b/openpype/version.py index 279575d110..c87c143ea3 100644 --- a/openpype/version.py +++ b/openpype/version.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- """Package declaring Pype version.""" -__version__ = "3.18.3-nightly.2" +__version__ = "3.18.3" diff --git a/pyproject.toml b/pyproject.toml index ee8e8017e3..bad481c889 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "OpenPype" -version = "3.18.2" # OpenPype +version = "3.18.3" # OpenPype description = "Open VFX and Animation pipeline with support." authors = ["OpenPype Team "] license = "MIT License" From b5b85f7b7fe533e19c2a08ebb5d277ec819d6c2c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 12 Jan 2024 13:00:24 +0000 Subject: [PATCH 097/104] chore(): update bug report / version --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 7d6c5650d1..3f762bd2d8 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -35,6 +35,7 @@ body: label: Version description: What version are you running? Look to OpenPype Tray options: + - 3.18.3 - 3.18.3-nightly.2 - 3.18.3-nightly.1 - 3.18.2 @@ -134,7 +135,6 @@ body: - 3.15.7-nightly.1 - 3.15.6 - 3.15.6-nightly.3 - - 3.15.6-nightly.2 validations: required: true - type: dropdown From e9d38f24f49784021bccd19f18b189fc47e91276 Mon Sep 17 00:00:00 2001 From: Simone Barbieri Date: Fri, 12 Jan 2024 15:03:47 +0000 Subject: [PATCH 098/104] Renamed variable --- openpype/hosts/blender/plugins/load/load_animation.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openpype/hosts/blender/plugins/load/load_animation.py b/openpype/hosts/blender/plugins/load/load_animation.py index 0f968c75e5..fd087553f0 100644 --- a/openpype/hosts/blender/plugins/load/load_animation.py +++ b/openpype/hosts/blender/plugins/load/load_animation.py @@ -61,10 +61,10 @@ class BlendAnimationLoader(plugin.AssetLoader): bpy.data.objects.remove(container) - filepath = bpy.path.basename(libpath) + filename = bpy.path.basename(libpath) # Blender has a limit of 63 characters for any data name. - # If the filepath is longer, it will be truncated. - if len(filepath) > 63: - filepath = filepath[:63] - library = bpy.data.libraries.get(filepath) + # If the filename is longer, it will be truncated. + if len(filename) > 63: + filename = filename[:63] + library = bpy.data.libraries.get(filename) bpy.data.libraries.remove(library) From 00eb748b4b64339b00799b5fa4c41ad42426f73c Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Sat, 13 Jan 2024 00:15:46 +0800 Subject: [PATCH 099/104] code tweaks on has_rgb_channel_in_texture_set function & add publish data into the imageinstance --- openpype/hosts/substancepainter/api/lib.py | 48 +++++-------------- .../publish/collect_textureset_images.py | 12 ++--- .../plugins/publish/validate_ouput_maps.py | 1 + 3 files changed, 19 insertions(+), 42 deletions(-) diff --git a/openpype/hosts/substancepainter/api/lib.py b/openpype/hosts/substancepainter/api/lib.py index 67229a75bf..896cca79b0 100644 --- a/openpype/hosts/substancepainter/api/lib.py +++ b/openpype/hosts/substancepainter/api/lib.py @@ -653,45 +653,23 @@ def has_rgb_channel_in_texture_set(texture_set_name, map_identifier): map_identifier (str): Map identifier Returns: - colorspace_dict: A dictionary which stores the boolean - value of textures having RGB channels + bool: Whether the channel type identifier has RGB channel or not + in the texture stack. """ + + # 2D_View is always True as it exports all texture maps texture_stack = ( substance_painter.textureset.Stack.from_name(texture_set_name) ) # 2D_View is always True as it exports all texture maps - colorspace_dict = {"2D_View": True} - colorspace_dict["BaseColor"] = texture_stack.get_channel( - substance_painter.textureset.ChannelType.BaseColor).is_color() - colorspace_dict["Roughness"] = texture_stack.get_channel( - substance_painter.textureset.ChannelType.Roughness).is_color() - colorspace_dict["Metallic"] = texture_stack.get_channel( - substance_painter.textureset.ChannelType.Metallic).is_color() - colorspace_dict["Height"] = texture_stack.get_channel( - substance_painter.textureset.ChannelType.Height).is_color() - colorspace_dict["Normal"] = texture_stack.get_channel( - substance_painter.textureset.ChannelType.Normal).is_color() - return colorspace_dict.get(map_identifier, False) + if map_identifier == "2D_View": + return True + channel_type = getattr( + substance_painter.textureset.ChannelType, map_identifier, None) + if channel_type is None: + return False + if not texture_stack.has_channel(channel_type): + return False -def texture_set_filtering(texture_set_same, template): - """Function to check whether some specific textures(e.g. Emissive) - are parts of the texture stack in Substance Painter - - Args: - texture_set_same (str): Name of Texture Set - template (str): texture template name - - Returns: - texture_filter: A dictionary which stores the boolean - value of whether the texture exist in the channel. - """ - texture_filter = {} - channel_stack = substance_painter.textureset.Stack.from_name( - texture_set_same) - has_emissive = channel_stack.has_channel( - substance_painter.textureset.ChannelType.Emissive) - map_identifier = strip_template(template) - if map_identifier == "Emissive": - texture_filter[map_identifier] = has_emissive - return texture_filter.get(map_identifier, True) + return texture_stack.get_channel(channel_type).is_color() diff --git a/openpype/hosts/substancepainter/plugins/publish/collect_textureset_images.py b/openpype/hosts/substancepainter/plugins/publish/collect_textureset_images.py index 9d6aa06872..4468602392 100644 --- a/openpype/hosts/substancepainter/plugins/publish/collect_textureset_images.py +++ b/openpype/hosts/substancepainter/plugins/publish/collect_textureset_images.py @@ -41,13 +41,11 @@ class CollectTextureSet(pyblish.api.InstancePlugin): for (texture_set_name, stack_name), template_maps in maps.items(): self.log.info(f"Processing {texture_set_name}/{stack_name}") for template, outputs in template_maps.items(): - if texture_set_filtering(texture_set_name, template): - self.log.info(f"Processing {template}") - self.create_image_instance( - instance, template, outputs, - asset_doc=asset_doc, - texture_set_name=texture_set_name, - stack_name=stack_name) + self.log.info(f"Processing {template}") + self.create_image_instance(instance, template, outputs, + asset_doc=asset_doc, + texture_set_name=texture_set_name, + stack_name=stack_name) def create_image_instance(self, instance, template, outputs, asset_doc, texture_set_name, stack_name): diff --git a/openpype/hosts/substancepainter/plugins/publish/validate_ouput_maps.py b/openpype/hosts/substancepainter/plugins/publish/validate_ouput_maps.py index b57cf4c5a2..252683b6c8 100644 --- a/openpype/hosts/substancepainter/plugins/publish/validate_ouput_maps.py +++ b/openpype/hosts/substancepainter/plugins/publish/validate_ouput_maps.py @@ -80,6 +80,7 @@ class ValidateOutputMaps(pyblish.api.InstancePlugin): self.log.warning(f"Disabling texture instance: " f"{image_instance}") image_instance.data["active"] = False + image_instance.data["publish"] = False image_instance.data["integrate"] = False representation.setdefault("tags", []).append("delete") continue From 00ab2bc9f69916ab19ddd15d018dc38cba624991 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Sat, 13 Jan 2024 00:19:03 +0800 Subject: [PATCH 100/104] remove unused function --- .../plugins/publish/collect_textureset_images.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openpype/hosts/substancepainter/plugins/publish/collect_textureset_images.py b/openpype/hosts/substancepainter/plugins/publish/collect_textureset_images.py index 4468602392..370e72f34b 100644 --- a/openpype/hosts/substancepainter/plugins/publish/collect_textureset_images.py +++ b/openpype/hosts/substancepainter/plugins/publish/collect_textureset_images.py @@ -8,8 +8,7 @@ import substance_painter.textureset from openpype.hosts.substancepainter.api.lib import ( get_parsed_export_maps, strip_template, - has_rgb_channel_in_texture_set, - texture_set_filtering + has_rgb_channel_in_texture_set ) from openpype.pipeline.create import get_subset_name from openpype.client import get_asset_by_name From 494a1dd4a6d3cc39e4cad6d6b7e98c8598dd8cd9 Mon Sep 17 00:00:00 2001 From: Ynbot Date: Sat, 13 Jan 2024 03:25:27 +0000 Subject: [PATCH 101/104] [Automated] Bump version --- openpype/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/version.py b/openpype/version.py index c87c143ea3..5981cb657a 100644 --- a/openpype/version.py +++ b/openpype/version.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- """Package declaring Pype version.""" -__version__ = "3.18.3" +__version__ = "3.18.4-nightly.1" From 8afd06233797bb0b949658a323bcbd0aeb3ffbd2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 13 Jan 2024 03:26:00 +0000 Subject: [PATCH 102/104] chore(): update bug report / version --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 3f762bd2d8..e9b68a54f1 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -35,6 +35,7 @@ body: label: Version description: What version are you running? Look to OpenPype Tray options: + - 3.18.4-nightly.1 - 3.18.3 - 3.18.3-nightly.2 - 3.18.3-nightly.1 @@ -134,7 +135,6 @@ body: - 3.15.7-nightly.2 - 3.15.7-nightly.1 - 3.15.6 - - 3.15.6-nightly.3 validations: required: true - type: dropdown From 7d94fb92c23d7ef055329f71d0333ab490a0055c Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 15 Jan 2024 10:32:39 +0100 Subject: [PATCH 103/104] Fusion: new creator for image product type (#6057) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Introduced image product type 'image' product type should result in single frame output, 'render' should be more focused on multiple frames. * Updated logging * Refactor moved generic creaor class to better location * Update openpype/settings/entities/schemas/projects_schema/schema_project_fusion.json Co-authored-by: Jakub Ježek * Change label It might be movie type not only image sequence. * OP-7470 - fix name * OP-7470 - update docstring There were objections for setting up this creator as it seems unnecessary. There is currently no other way how to implement customer requirement but this, but in the future 'alias' product types implementation might solve this. * Implementing changes from #6060 https://github.com/ynput/OpenPype/pull/6060 * Update openpype/settings/defaults/project_settings/fusion.json Co-authored-by: Jakub Ježek * Update server_addon/fusion/server/settings.py Co-authored-by: Jakub Ježek * Update openpype/hosts/fusion/api/plugin.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> * OP-7470 - added explicit frame field Artist can insert specific frame from which `image` instance should be created. * OP-7470 - fix name and logging Prints better message even in debug mode. * OP-7470 - update instance label It contained original frames which was confusing. * Update openpype/hosts/fusion/plugins/create/create_image_saver.py Co-authored-by: Roy Nieterau * OP-7470 - fix documentation * OP-7470 - moved frame range resolution earlier This approach is safer, as frame range is resolved sooner. * OP-7470 - added new validator for single frame * OP-7470 - Hound * OP-7470 - removed unnecessary as label * OP-7470 - use internal class anatomy * OP-7470 - add explicit settings_category to propagete values from Setting correctly apply_settings is replaced by correct value in `settings_category` * OP-7470 - typo * OP-7470 - update docstring * OP-7470 - update formatting data This probably fixes issue with missing product key in intermediate product name. * OP-7470 - moved around only proper fields Some fields (frame and frame_range) are making sense only in specific creator. * OP-7470 - added defaults to Settings * OP-7470 - fixed typo * OP-7470 - bumped up version Settings changed, so addon version should change too. 0.1.2 is in develop * Update openpype/hosts/fusion/plugins/publish/collect_instances.py Co-authored-by: Roy Nieterau * OP-7470 - removed unnecessary variables There was logic intended to use those, deemed not necessary. * OP-7470 - update to error message * OP-7470 - removed unneded method --------- Co-authored-by: Jakub Ježek Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Co-authored-by: Roy Nieterau --- openpype/hosts/fusion/api/plugin.py | 221 +++++++++++++++ .../plugins/create/create_image_saver.py | 64 +++++ .../fusion/plugins/create/create_saver.py | 257 ++---------------- .../fusion/plugins/publish/collect_inputs.py | 2 +- .../plugins/publish/collect_instances.py | 12 + .../fusion/plugins/publish/collect_render.py | 4 +- .../fusion/plugins/publish/save_scene.py | 2 +- .../publish/validate_background_depth.py | 2 +- .../plugins/publish/validate_comp_saved.py | 2 +- .../publish/validate_create_folder_checked.py | 2 +- .../validate_filename_has_extension.py | 2 +- .../plugins/publish/validate_image_frame.py | 27 ++ .../publish/validate_instance_frame_range.py | 4 +- .../publish/validate_saver_has_input.py | 2 +- .../publish/validate_saver_passthrough.py | 2 +- .../publish/validate_saver_resolution.py | 2 +- .../publish/validate_unique_subsets.py | 2 +- .../defaults/project_settings/fusion.json | 12 + .../schema_project_fusion.json | 51 +++- server_addon/fusion/server/settings.py | 67 ++++- server_addon/fusion/server/version.py | 2 +- 21 files changed, 482 insertions(+), 259 deletions(-) create mode 100644 openpype/hosts/fusion/api/plugin.py create mode 100644 openpype/hosts/fusion/plugins/create/create_image_saver.py create mode 100644 openpype/hosts/fusion/plugins/publish/validate_image_frame.py diff --git a/openpype/hosts/fusion/api/plugin.py b/openpype/hosts/fusion/api/plugin.py new file mode 100644 index 0000000000..63a74fbdb5 --- /dev/null +++ b/openpype/hosts/fusion/api/plugin.py @@ -0,0 +1,221 @@ +from copy import deepcopy +import os + +from openpype.hosts.fusion.api import ( + get_current_comp, + comp_lock_and_undo_chunk, +) + +from openpype.lib import ( + BoolDef, + EnumDef, +) +from openpype.pipeline import ( + legacy_io, + Creator, + CreatedInstance +) + + +class GenericCreateSaver(Creator): + default_variants = ["Main", "Mask"] + description = "Fusion Saver to generate image sequence" + icon = "fa5.eye" + + instance_attributes = [ + "reviewable" + ] + + settings_category = "fusion" + + image_format = "exr" + + # TODO: This should be renamed together with Nuke so it is aligned + temp_rendering_path_template = ( + "{workdir}/renders/fusion/{subset}/{subset}.{frame}.{ext}") + + def create(self, subset_name, instance_data, pre_create_data): + self.pass_pre_attributes_to_instance(instance_data, pre_create_data) + + instance = CreatedInstance( + family=self.family, + subset_name=subset_name, + data=instance_data, + creator=self, + ) + data = instance.data_to_store() + comp = get_current_comp() + with comp_lock_and_undo_chunk(comp): + args = (-32768, -32768) # Magical position numbers + saver = comp.AddTool("Saver", *args) + + self._update_tool_with_data(saver, data=data) + + # Register the CreatedInstance + self._imprint(saver, data) + + # Insert the transient data + instance.transient_data["tool"] = saver + + self._add_instance_to_context(instance) + + return instance + + def collect_instances(self): + comp = get_current_comp() + tools = comp.GetToolList(False, "Saver").values() + for tool in tools: + data = self.get_managed_tool_data(tool) + if not data: + continue + + # Add instance + created_instance = CreatedInstance.from_existing(data, self) + + # Collect transient data + created_instance.transient_data["tool"] = tool + + self._add_instance_to_context(created_instance) + + def update_instances(self, update_list): + for created_inst, _changes in update_list: + new_data = created_inst.data_to_store() + tool = created_inst.transient_data["tool"] + self._update_tool_with_data(tool, new_data) + self._imprint(tool, new_data) + + def remove_instances(self, instances): + for instance in instances: + # Remove the tool from the scene + + tool = instance.transient_data["tool"] + if tool: + tool.Delete() + + # Remove the collected CreatedInstance to remove from UI directly + self._remove_instance_from_context(instance) + + def _imprint(self, tool, data): + # Save all data in a "openpype.{key}" = value data + + # Instance id is the tool's name so we don't need to imprint as data + data.pop("instance_id", None) + + active = data.pop("active", None) + if active is not None: + # Use active value to set the passthrough state + tool.SetAttrs({"TOOLB_PassThrough": not active}) + + for key, value in data.items(): + tool.SetData(f"openpype.{key}", value) + + def _update_tool_with_data(self, tool, data): + """Update tool node name and output path based on subset data""" + if "subset" not in data: + return + + original_subset = tool.GetData("openpype.subset") + original_format = tool.GetData( + "openpype.creator_attributes.image_format" + ) + + subset = data["subset"] + if ( + original_subset != subset + or original_format != data["creator_attributes"]["image_format"] + ): + self._configure_saver_tool(data, tool, subset) + + def _configure_saver_tool(self, data, tool, subset): + formatting_data = deepcopy(data) + + # get frame padding from anatomy templates + frame_padding = self.project_anatomy.templates["frame_padding"] + + # get output format + ext = data["creator_attributes"]["image_format"] + + # Subset change detected + workdir = os.path.normpath(legacy_io.Session["AVALON_WORKDIR"]) + formatting_data.update({ + "workdir": workdir, + "frame": "0" * frame_padding, + "ext": ext, + "product": { + "name": formatting_data["subset"], + "type": formatting_data["family"], + }, + }) + + # build file path to render + filepath = self.temp_rendering_path_template.format(**formatting_data) + + comp = get_current_comp() + tool["Clip"] = comp.ReverseMapPath(os.path.normpath(filepath)) + + # Rename tool + if tool.Name != subset: + print(f"Renaming {tool.Name} -> {subset}") + tool.SetAttrs({"TOOLS_Name": subset}) + + def get_managed_tool_data(self, tool): + """Return data of the tool if it matches creator identifier""" + data = tool.GetData("openpype") + if not isinstance(data, dict): + return + + required = { + "id": "pyblish.avalon.instance", + "creator_identifier": self.identifier, + } + for key, value in required.items(): + if key not in data or data[key] != value: + return + + # Get active state from the actual tool state + attrs = tool.GetAttrs() + passthrough = attrs["TOOLB_PassThrough"] + data["active"] = not passthrough + + # Override publisher's UUID generation because tool names are + # already unique in Fusion in a comp + data["instance_id"] = tool.Name + + return data + + def get_instance_attr_defs(self): + """Settings for publish page""" + return self.get_pre_create_attr_defs() + + def pass_pre_attributes_to_instance(self, instance_data, pre_create_data): + creator_attrs = instance_data["creator_attributes"] = {} + for pass_key in pre_create_data.keys(): + creator_attrs[pass_key] = pre_create_data[pass_key] + + def _get_render_target_enum(self): + rendering_targets = { + "local": "Local machine rendering", + "frames": "Use existing frames", + } + if "farm_rendering" in self.instance_attributes: + rendering_targets["farm"] = "Farm rendering" + + return EnumDef( + "render_target", items=rendering_targets, label="Render target" + ) + + def _get_reviewable_bool(self): + return BoolDef( + "review", + default=("reviewable" in self.instance_attributes), + label="Review", + ) + + def _get_image_format_enum(self): + image_format_options = ["exr", "tga", "tif", "png", "jpg"] + return EnumDef( + "image_format", + items=image_format_options, + default=self.image_format, + label="Output Image Format", + ) diff --git a/openpype/hosts/fusion/plugins/create/create_image_saver.py b/openpype/hosts/fusion/plugins/create/create_image_saver.py new file mode 100644 index 0000000000..490228d488 --- /dev/null +++ b/openpype/hosts/fusion/plugins/create/create_image_saver.py @@ -0,0 +1,64 @@ +from openpype.lib import NumberDef + +from openpype.hosts.fusion.api.plugin import GenericCreateSaver +from openpype.hosts.fusion.api import get_current_comp + + +class CreateImageSaver(GenericCreateSaver): + """Fusion Saver to generate single image. + + Created to explicitly separate single ('image') or + multi frame('render) outputs. + + This might be temporary creator until 'alias' functionality will be + implemented to limit creation of additional product types with similar, but + not the same workflows. + """ + identifier = "io.openpype.creators.fusion.imagesaver" + label = "Image (saver)" + name = "image" + family = "image" + description = "Fusion Saver to generate image" + + default_frame = 0 + + def get_detail_description(self): + return """Fusion Saver to generate single image. + + This creator is expected for publishing of single frame `image` product + type. + + Artist should provide frame number (integer) to specify which frame + should be published. It must be inside of global timeline frame range. + + Supports local and deadline rendering. + + Supports selection from predefined set of output file extensions: + - exr + - tga + - png + - tif + - jpg + + Created to explicitly separate single frame ('image') or + multi frame ('render') outputs. + """ + + def get_pre_create_attr_defs(self): + """Settings for create page""" + attr_defs = [ + self._get_render_target_enum(), + self._get_reviewable_bool(), + self._get_frame_int(), + self._get_image_format_enum(), + ] + return attr_defs + + def _get_frame_int(self): + return NumberDef( + "frame", + default=self.default_frame, + label="Frame", + tooltip="Set frame to be rendered, must be inside of global " + "timeline range" + ) diff --git a/openpype/hosts/fusion/plugins/create/create_saver.py b/openpype/hosts/fusion/plugins/create/create_saver.py index 5870828b41..3a8ffe890b 100644 --- a/openpype/hosts/fusion/plugins/create/create_saver.py +++ b/openpype/hosts/fusion/plugins/create/create_saver.py @@ -1,187 +1,42 @@ -from copy import deepcopy -import os +from openpype.lib import EnumDef -from openpype.hosts.fusion.api import ( - get_current_comp, - comp_lock_and_undo_chunk, -) - -from openpype.lib import ( - BoolDef, - EnumDef, -) -from openpype.pipeline import ( - legacy_io, - Creator as NewCreator, - CreatedInstance, - Anatomy, -) +from openpype.hosts.fusion.api.plugin import GenericCreateSaver -class CreateSaver(NewCreator): +class CreateSaver(GenericCreateSaver): + """Fusion Saver to generate image sequence of 'render' product type. + + Original Saver creator targeted for 'render' product type. It uses + original not to descriptive name because of values in Settings. + """ identifier = "io.openpype.creators.fusion.saver" label = "Render (saver)" name = "render" family = "render" - default_variants = ["Main", "Mask"] description = "Fusion Saver to generate image sequence" - icon = "fa5.eye" - instance_attributes = ["reviewable"] - image_format = "exr" + default_frame_range_option = "asset_db" - # TODO: This should be renamed together with Nuke so it is aligned - temp_rendering_path_template = ( - "{workdir}/renders/fusion/{subset}/{subset}.{frame}.{ext}" - ) + def get_detail_description(self): + return """Fusion Saver to generate image sequence. - def create(self, subset_name, instance_data, pre_create_data): - self.pass_pre_attributes_to_instance(instance_data, pre_create_data) + This creator is expected for publishing of image sequences for 'render' + product type. (But can publish even single frame 'render'.) - instance_data.update( - {"id": "pyblish.avalon.instance", "subset": subset_name} - ) + Select what should be source of render range: + - "Current asset context" - values set on Asset in DB (Ftrack) + - "From render in/out" - from node itself + - "From composition timeline" - from timeline - comp = get_current_comp() - with comp_lock_and_undo_chunk(comp): - args = (-32768, -32768) # Magical position numbers - saver = comp.AddTool("Saver", *args) + Supports local and farm rendering. - self._update_tool_with_data(saver, data=instance_data) - - # Register the CreatedInstance - instance = CreatedInstance( - family=self.family, - subset_name=subset_name, - data=instance_data, - creator=self, - ) - data = instance.data_to_store() - self._imprint(saver, data) - - # Insert the transient data - instance.transient_data["tool"] = saver - - self._add_instance_to_context(instance) - - return instance - - def collect_instances(self): - comp = get_current_comp() - tools = comp.GetToolList(False, "Saver").values() - for tool in tools: - data = self.get_managed_tool_data(tool) - if not data: - continue - - # Add instance - created_instance = CreatedInstance.from_existing(data, self) - - # Collect transient data - created_instance.transient_data["tool"] = tool - - self._add_instance_to_context(created_instance) - - def update_instances(self, update_list): - for created_inst, _changes in update_list: - new_data = created_inst.data_to_store() - tool = created_inst.transient_data["tool"] - self._update_tool_with_data(tool, new_data) - self._imprint(tool, new_data) - - def remove_instances(self, instances): - for instance in instances: - # Remove the tool from the scene - - tool = instance.transient_data["tool"] - if tool: - tool.Delete() - - # Remove the collected CreatedInstance to remove from UI directly - self._remove_instance_from_context(instance) - - def _imprint(self, tool, data): - # Save all data in a "openpype.{key}" = value data - - # Instance id is the tool's name so we don't need to imprint as data - data.pop("instance_id", None) - - active = data.pop("active", None) - if active is not None: - # Use active value to set the passthrough state - tool.SetAttrs({"TOOLB_PassThrough": not active}) - - for key, value in data.items(): - tool.SetData(f"openpype.{key}", value) - - def _update_tool_with_data(self, tool, data): - """Update tool node name and output path based on subset data""" - if "subset" not in data: - return - - original_subset = tool.GetData("openpype.subset") - original_format = tool.GetData( - "openpype.creator_attributes.image_format" - ) - - subset = data["subset"] - if ( - original_subset != subset - or original_format != data["creator_attributes"]["image_format"] - ): - self._configure_saver_tool(data, tool, subset) - - def _configure_saver_tool(self, data, tool, subset): - formatting_data = deepcopy(data) - - # get frame padding from anatomy templates - anatomy = Anatomy() - frame_padding = anatomy.templates["frame_padding"] - - # get output format - ext = data["creator_attributes"]["image_format"] - - # Subset change detected - workdir = os.path.normpath(legacy_io.Session["AVALON_WORKDIR"]) - formatting_data.update( - {"workdir": workdir, "frame": "0" * frame_padding, "ext": ext} - ) - - # build file path to render - filepath = self.temp_rendering_path_template.format(**formatting_data) - - comp = get_current_comp() - tool["Clip"] = comp.ReverseMapPath(os.path.normpath(filepath)) - - # Rename tool - if tool.Name != subset: - print(f"Renaming {tool.Name} -> {subset}") - tool.SetAttrs({"TOOLS_Name": subset}) - - def get_managed_tool_data(self, tool): - """Return data of the tool if it matches creator identifier""" - data = tool.GetData("openpype") - if not isinstance(data, dict): - return - - required = { - "id": "pyblish.avalon.instance", - "creator_identifier": self.identifier, - } - for key, value in required.items(): - if key not in data or data[key] != value: - return - - # Get active state from the actual tool state - attrs = tool.GetAttrs() - passthrough = attrs["TOOLB_PassThrough"] - data["active"] = not passthrough - - # Override publisher's UUID generation because tool names are - # already unique in Fusion in a comp - data["instance_id"] = tool.Name - - return data + Supports selection from predefined set of output file extensions: + - exr + - tga + - png + - tif + - jpg + """ def get_pre_create_attr_defs(self): """Settings for create page""" @@ -193,29 +48,6 @@ class CreateSaver(NewCreator): ] return attr_defs - def get_instance_attr_defs(self): - """Settings for publish page""" - return self.get_pre_create_attr_defs() - - def pass_pre_attributes_to_instance(self, instance_data, pre_create_data): - creator_attrs = instance_data["creator_attributes"] = {} - for pass_key in pre_create_data.keys(): - creator_attrs[pass_key] = pre_create_data[pass_key] - - # These functions below should be moved to another file - # so it can be used by other plugins. plugin.py ? - def _get_render_target_enum(self): - rendering_targets = { - "local": "Local machine rendering", - "frames": "Use existing frames", - } - if "farm_rendering" in self.instance_attributes: - rendering_targets["farm"] = "Farm rendering" - - return EnumDef( - "render_target", items=rendering_targets, label="Render target" - ) - def _get_frame_range_enum(self): frame_range_options = { "asset_db": "Current asset context", @@ -227,42 +59,5 @@ class CreateSaver(NewCreator): "frame_range_source", items=frame_range_options, label="Frame range source", - ) - - def _get_reviewable_bool(self): - return BoolDef( - "review", - default=("reviewable" in self.instance_attributes), - label="Review", - ) - - def _get_image_format_enum(self): - image_format_options = ["exr", "tga", "tif", "png", "jpg"] - return EnumDef( - "image_format", - items=image_format_options, - default=self.image_format, - label="Output Image Format", - ) - - def apply_settings(self, project_settings): - """Method called on initialization of plugin to apply settings.""" - - # plugin settings - plugin_settings = project_settings["fusion"]["create"][ - self.__class__.__name__ - ] - - # individual attributes - self.instance_attributes = plugin_settings.get( - "instance_attributes", self.instance_attributes - ) - self.default_variants = plugin_settings.get( - "default_variants", self.default_variants - ) - self.temp_rendering_path_template = plugin_settings.get( - "temp_rendering_path_template", self.temp_rendering_path_template - ) - self.image_format = plugin_settings.get( - "image_format", self.image_format + default=self.default_frame_range_option ) diff --git a/openpype/hosts/fusion/plugins/publish/collect_inputs.py b/openpype/hosts/fusion/plugins/publish/collect_inputs.py index a6628300db..f23e4d0268 100644 --- a/openpype/hosts/fusion/plugins/publish/collect_inputs.py +++ b/openpype/hosts/fusion/plugins/publish/collect_inputs.py @@ -95,7 +95,7 @@ class CollectUpstreamInputs(pyblish.api.InstancePlugin): label = "Collect Inputs" order = pyblish.api.CollectorOrder + 0.2 hosts = ["fusion"] - families = ["render"] + families = ["render", "image"] def process(self, instance): diff --git a/openpype/hosts/fusion/plugins/publish/collect_instances.py b/openpype/hosts/fusion/plugins/publish/collect_instances.py index 4d6da79b77..a0131248e8 100644 --- a/openpype/hosts/fusion/plugins/publish/collect_instances.py +++ b/openpype/hosts/fusion/plugins/publish/collect_instances.py @@ -57,6 +57,18 @@ class CollectInstanceData(pyblish.api.InstancePlugin): start_with_handle = comp_start end_with_handle = comp_end + frame = instance.data["creator_attributes"].get("frame") + # explicitly publishing only single frame + if frame is not None: + frame = int(frame) + + start = frame + end = frame + handle_start = 0 + handle_end = 0 + start_with_handle = frame + end_with_handle = frame + # Include start and end render frame in label subset = instance.data["subset"] label = ( diff --git a/openpype/hosts/fusion/plugins/publish/collect_render.py b/openpype/hosts/fusion/plugins/publish/collect_render.py index a7daa0b64c..366eaa905c 100644 --- a/openpype/hosts/fusion/plugins/publish/collect_render.py +++ b/openpype/hosts/fusion/plugins/publish/collect_render.py @@ -50,7 +50,7 @@ class CollectFusionRender( continue family = inst.data["family"] - if family != "render": + if family not in ["render", "image"]: continue task_name = context.data["task"] @@ -59,7 +59,7 @@ class CollectFusionRender( instance_families = inst.data.get("families", []) subset_name = inst.data["subset"] instance = FusionRenderInstance( - family="render", + family=family, tool=tool, workfileComp=comp, families=instance_families, diff --git a/openpype/hosts/fusion/plugins/publish/save_scene.py b/openpype/hosts/fusion/plugins/publish/save_scene.py index 0798e7c8b7..da9b6ce41f 100644 --- a/openpype/hosts/fusion/plugins/publish/save_scene.py +++ b/openpype/hosts/fusion/plugins/publish/save_scene.py @@ -7,7 +7,7 @@ class FusionSaveComp(pyblish.api.ContextPlugin): label = "Save current file" order = pyblish.api.ExtractorOrder - 0.49 hosts = ["fusion"] - families = ["render", "workfile"] + families = ["render", "image", "workfile"] def process(self, context): diff --git a/openpype/hosts/fusion/plugins/publish/validate_background_depth.py b/openpype/hosts/fusion/plugins/publish/validate_background_depth.py index 6908889eb4..e268f8adec 100644 --- a/openpype/hosts/fusion/plugins/publish/validate_background_depth.py +++ b/openpype/hosts/fusion/plugins/publish/validate_background_depth.py @@ -17,7 +17,7 @@ class ValidateBackgroundDepth( order = pyblish.api.ValidatorOrder label = "Validate Background Depth 32 bit" hosts = ["fusion"] - families = ["render"] + families = ["render", "image"] optional = True actions = [SelectInvalidAction, publish.RepairAction] diff --git a/openpype/hosts/fusion/plugins/publish/validate_comp_saved.py b/openpype/hosts/fusion/plugins/publish/validate_comp_saved.py index 748047e8cf..6e6d10e09a 100644 --- a/openpype/hosts/fusion/plugins/publish/validate_comp_saved.py +++ b/openpype/hosts/fusion/plugins/publish/validate_comp_saved.py @@ -9,7 +9,7 @@ class ValidateFusionCompSaved(pyblish.api.ContextPlugin): order = pyblish.api.ValidatorOrder label = "Validate Comp Saved" - families = ["render"] + families = ["render", "image"] hosts = ["fusion"] def process(self, context): diff --git a/openpype/hosts/fusion/plugins/publish/validate_create_folder_checked.py b/openpype/hosts/fusion/plugins/publish/validate_create_folder_checked.py index 35c92163eb..d5c618af58 100644 --- a/openpype/hosts/fusion/plugins/publish/validate_create_folder_checked.py +++ b/openpype/hosts/fusion/plugins/publish/validate_create_folder_checked.py @@ -15,7 +15,7 @@ class ValidateCreateFolderChecked(pyblish.api.InstancePlugin): order = pyblish.api.ValidatorOrder label = "Validate Create Folder Checked" - families = ["render"] + families = ["render", "image"] hosts = ["fusion"] actions = [RepairAction, SelectInvalidAction] diff --git a/openpype/hosts/fusion/plugins/publish/validate_filename_has_extension.py b/openpype/hosts/fusion/plugins/publish/validate_filename_has_extension.py index 537e43c875..38cd578ff2 100644 --- a/openpype/hosts/fusion/plugins/publish/validate_filename_has_extension.py +++ b/openpype/hosts/fusion/plugins/publish/validate_filename_has_extension.py @@ -17,7 +17,7 @@ class ValidateFilenameHasExtension(pyblish.api.InstancePlugin): order = pyblish.api.ValidatorOrder label = "Validate Filename Has Extension" - families = ["render"] + families = ["render", "image"] hosts = ["fusion"] actions = [SelectInvalidAction] diff --git a/openpype/hosts/fusion/plugins/publish/validate_image_frame.py b/openpype/hosts/fusion/plugins/publish/validate_image_frame.py new file mode 100644 index 0000000000..734203f31c --- /dev/null +++ b/openpype/hosts/fusion/plugins/publish/validate_image_frame.py @@ -0,0 +1,27 @@ +import pyblish.api + +from openpype.pipeline import PublishValidationError + + +class ValidateImageFrame(pyblish.api.InstancePlugin): + """Validates that `image` product type contains only single frame.""" + + order = pyblish.api.ValidatorOrder + label = "Validate Image Frame" + families = ["image"] + hosts = ["fusion"] + + def process(self, instance): + render_start = instance.data["frameStartHandle"] + render_end = instance.data["frameEndHandle"] + too_many_frames = (isinstance(instance.data["expectedFiles"], list) + and len(instance.data["expectedFiles"]) > 1) + + if render_end - render_start > 0 or too_many_frames: + desc = ("Trying to render multiple frames. 'image' product type " + "is meant for single frame. Please use 'render' creator.") + raise PublishValidationError( + title="Frame range outside of comp range", + message=desc, + description=desc + ) diff --git a/openpype/hosts/fusion/plugins/publish/validate_instance_frame_range.py b/openpype/hosts/fusion/plugins/publish/validate_instance_frame_range.py index 06cd0ca186..edf219e752 100644 --- a/openpype/hosts/fusion/plugins/publish/validate_instance_frame_range.py +++ b/openpype/hosts/fusion/plugins/publish/validate_instance_frame_range.py @@ -7,8 +7,8 @@ class ValidateInstanceFrameRange(pyblish.api.InstancePlugin): """Validate instance frame range is within comp's global render range.""" order = pyblish.api.ValidatorOrder - label = "Validate Filename Has Extension" - families = ["render"] + label = "Validate Frame Range" + families = ["render", "image"] hosts = ["fusion"] def process(self, instance): diff --git a/openpype/hosts/fusion/plugins/publish/validate_saver_has_input.py b/openpype/hosts/fusion/plugins/publish/validate_saver_has_input.py index faf2102a8b..0103e990fb 100644 --- a/openpype/hosts/fusion/plugins/publish/validate_saver_has_input.py +++ b/openpype/hosts/fusion/plugins/publish/validate_saver_has_input.py @@ -13,7 +13,7 @@ class ValidateSaverHasInput(pyblish.api.InstancePlugin): order = pyblish.api.ValidatorOrder label = "Validate Saver Has Input" - families = ["render"] + families = ["render", "image"] hosts = ["fusion"] actions = [SelectInvalidAction] diff --git a/openpype/hosts/fusion/plugins/publish/validate_saver_passthrough.py b/openpype/hosts/fusion/plugins/publish/validate_saver_passthrough.py index 9004976dc5..6019bee93a 100644 --- a/openpype/hosts/fusion/plugins/publish/validate_saver_passthrough.py +++ b/openpype/hosts/fusion/plugins/publish/validate_saver_passthrough.py @@ -9,7 +9,7 @@ class ValidateSaverPassthrough(pyblish.api.ContextPlugin): order = pyblish.api.ValidatorOrder label = "Validate Saver Passthrough" - families = ["render"] + families = ["render", "image"] hosts = ["fusion"] actions = [SelectInvalidAction] diff --git a/openpype/hosts/fusion/plugins/publish/validate_saver_resolution.py b/openpype/hosts/fusion/plugins/publish/validate_saver_resolution.py index efa7295d11..f6aba170c0 100644 --- a/openpype/hosts/fusion/plugins/publish/validate_saver_resolution.py +++ b/openpype/hosts/fusion/plugins/publish/validate_saver_resolution.py @@ -64,7 +64,7 @@ class ValidateSaverResolution( order = pyblish.api.ValidatorOrder label = "Validate Asset Resolution" - families = ["render"] + families = ["render", "image"] hosts = ["fusion"] optional = True actions = [SelectInvalidAction] diff --git a/openpype/hosts/fusion/plugins/publish/validate_unique_subsets.py b/openpype/hosts/fusion/plugins/publish/validate_unique_subsets.py index 5b6ceb2fdb..d1693ef3dc 100644 --- a/openpype/hosts/fusion/plugins/publish/validate_unique_subsets.py +++ b/openpype/hosts/fusion/plugins/publish/validate_unique_subsets.py @@ -11,7 +11,7 @@ class ValidateUniqueSubsets(pyblish.api.ContextPlugin): order = pyblish.api.ValidatorOrder label = "Validate Unique Subsets" - families = ["render"] + families = ["render", "image"] hosts = ["fusion"] actions = [SelectInvalidAction] diff --git a/openpype/settings/defaults/project_settings/fusion.json b/openpype/settings/defaults/project_settings/fusion.json index 8579442625..15b6bfc09b 100644 --- a/openpype/settings/defaults/project_settings/fusion.json +++ b/openpype/settings/defaults/project_settings/fusion.json @@ -32,6 +32,18 @@ "farm_rendering" ], "image_format": "exr" + }, + "CreateImageSaver": { + "temp_rendering_path_template": "{workdir}/renders/fusion/{subset}/{subset}.{ext}", + "default_variants": [ + "Main", + "Mask" + ], + "instance_attributes": [ + "reviewable", + "farm_rendering" + ], + "image_format": "exr" } }, "publish": { diff --git a/openpype/settings/entities/schemas/projects_schema/schema_project_fusion.json b/openpype/settings/entities/schemas/projects_schema/schema_project_fusion.json index fbd856b895..8669842087 100644 --- a/openpype/settings/entities/schemas/projects_schema/schema_project_fusion.json +++ b/openpype/settings/entities/schemas/projects_schema/schema_project_fusion.json @@ -74,7 +74,56 @@ "type": "dict", "collapsible": true, "key": "CreateSaver", - "label": "Create Saver", + "label": "Create Render Saver", + "is_group": true, + "children": [ + { + "type": "text", + "key": "temp_rendering_path_template", + "label": "Temporary rendering path template" + }, + { + "type": "list", + "key": "default_variants", + "label": "Default variants", + "object_type": { + "type": "text" + } + }, + { + "key": "instance_attributes", + "label": "Instance attributes", + "type": "enum", + "multiselection": true, + "enum_items": [ + { + "reviewable": "Reviewable" + }, + { + "farm_rendering": "Farm rendering" + } + ] + }, + { + "key": "image_format", + "label": "Output Image Format", + "type": "enum", + "multiselect": false, + "enum_items": [ + {"exr": "exr"}, + {"tga": "tga"}, + {"png": "png"}, + {"tif": "tif"}, + {"jpg": "jpg"} + ] + } + ] + }, + { + "type": "dict", + "collapsible": true, + "key": "CreateImageSaver", + "label": "Create Image Saver", "is_group": true, "children": [ { diff --git a/server_addon/fusion/server/settings.py b/server_addon/fusion/server/settings.py index 21189b390e..bf295f3064 100644 --- a/server_addon/fusion/server/settings.py +++ b/server_addon/fusion/server/settings.py @@ -25,6 +25,24 @@ def _create_saver_instance_attributes_enum(): ] +def _image_format_enum(): + return [ + {"value": "exr", "label": "exr"}, + {"value": "tga", "label": "tga"}, + {"value": "png", "label": "png"}, + {"value": "tif", "label": "tif"}, + {"value": "jpg", "label": "jpg"}, + ] + + +def _frame_range_options_enum(): + return [ + {"value": "asset_db", "label": "Current asset context"}, + {"value": "render_range", "label": "From render in/out"}, + {"value": "comp_range", "label": "From composition timeline"}, + ] + + class CreateSaverPluginModel(BaseSettingsModel): _isGroup = True temp_rendering_path_template: str = Field( @@ -59,10 +77,29 @@ class HooksModel(BaseSettingsModel): ) +class CreateSaverModel(CreateSaverPluginModel): + default_frame_range_option: str = Field( + default="asset_db", + enum_resolver=_frame_range_options_enum, + title="Default frame range source" + ) + + +class CreateImageSaverModel(CreateSaverPluginModel): + default_frame: int = Field( + 0, + title="Default rendered frame" + ) class CreatPluginsModel(BaseSettingsModel): - CreateSaver: CreateSaverPluginModel = Field( - default_factory=CreateSaverPluginModel, - title="Create Saver" + CreateSaver: CreateSaverModel = Field( + default_factory=CreateSaverModel, + title="Create Saver", + description="Creator for render product type (eg. sequence)" + ) + CreateImageSaver: CreateImageSaverModel = Field( + default_factory=CreateImageSaverModel, + title="Create Image Saver", + description="Creator for image product type (eg. single)" ) @@ -117,15 +154,21 @@ DEFAULT_VALUES = { "reviewable", "farm_rendering" ], - "output_formats": [ - "exr", - "jpg", - "jpeg", - "jpg", - "tiff", - "png", - "tga" - ] + "image_format": "exr", + "default_frame_range_option": "asset_db" + }, + "CreateImageSaver": { + "temp_rendering_path_template": "{workdir}/renders/fusion/{product[name]}/{product[name]}.{ext}", + "default_variants": [ + "Main", + "Mask" + ], + "instance_attributes": [ + "reviewable", + "farm_rendering" + ], + "image_format": "exr", + "default_frame": 0 } } } diff --git a/server_addon/fusion/server/version.py b/server_addon/fusion/server/version.py index b3f4756216..ae7362549b 100644 --- a/server_addon/fusion/server/version.py +++ b/server_addon/fusion/server/version.py @@ -1 +1 @@ -__version__ = "0.1.2" +__version__ = "0.1.3" From 1ac89d2efa55792e11023419e3ac5914e7b57480 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Mon, 15 Jan 2024 19:17:12 +0800 Subject: [PATCH 104/104] restore some of the codes on lib and collect images --- openpype/hosts/substancepainter/api/lib.py | 30 ------------------- .../publish/collect_textureset_images.py | 8 ++--- 2 files changed, 3 insertions(+), 35 deletions(-) diff --git a/openpype/hosts/substancepainter/api/lib.py b/openpype/hosts/substancepainter/api/lib.py index 896cca79b0..1cb480b552 100644 --- a/openpype/hosts/substancepainter/api/lib.py +++ b/openpype/hosts/substancepainter/api/lib.py @@ -643,33 +643,3 @@ def prompt_new_file_with_mesh(mesh_filepath): return return project_mesh - - -def has_rgb_channel_in_texture_set(texture_set_name, map_identifier): - """Function to check whether the texture has RGB channel. - - Args: - texture_set_name (str): Name of Texture Set - map_identifier (str): Map identifier - - Returns: - bool: Whether the channel type identifier has RGB channel or not - in the texture stack. - """ - - # 2D_View is always True as it exports all texture maps - texture_stack = ( - substance_painter.textureset.Stack.from_name(texture_set_name) - ) - # 2D_View is always True as it exports all texture maps - if map_identifier == "2D_View": - return True - - channel_type = getattr( - substance_painter.textureset.ChannelType, map_identifier, None) - if channel_type is None: - return False - if not texture_stack.has_channel(channel_type): - return False - - return texture_stack.get_channel(channel_type).is_color() diff --git a/openpype/hosts/substancepainter/plugins/publish/collect_textureset_images.py b/openpype/hosts/substancepainter/plugins/publish/collect_textureset_images.py index 370e72f34b..316f72509e 100644 --- a/openpype/hosts/substancepainter/plugins/publish/collect_textureset_images.py +++ b/openpype/hosts/substancepainter/plugins/publish/collect_textureset_images.py @@ -7,8 +7,7 @@ from openpype.pipeline import publish import substance_painter.textureset from openpype.hosts.substancepainter.api.lib import ( get_parsed_export_maps, - strip_template, - has_rgb_channel_in_texture_set + strip_template ) from openpype.pipeline.create import get_subset_name from openpype.client import get_asset_by_name @@ -79,6 +78,7 @@ class CollectTextureSet(pyblish.api.InstancePlugin): # Always include the map identifier map_identifier = strip_template(template) suffix += f".{map_identifier}" + image_subset = get_subset_name( # TODO: The family actually isn't 'texture' currently but for now # this is only done so the subset name starts with 'texture' @@ -132,9 +132,7 @@ class CollectTextureSet(pyblish.api.InstancePlugin): # Store color space with the instance # Note: The extractor will assign it to the representation colorspace = outputs[0].get("colorSpace") - has_rgb_channel = has_rgb_channel_in_texture_set( - texture_set_name, map_identifier) - if colorspace and has_rgb_channel: + if colorspace: self.log.debug(f"{image_subset} colorspace: {colorspace}") image_instance.data["colorspace"] = colorspace