From 2811eaddb8696ab3816370f9f78699d8dfa9795c Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Sun, 28 Apr 2024 22:00:21 +0100 Subject: [PATCH 01/15] Working version --- client/ayon_core/hosts/nuke/api/pipeline.py | 6 + .../hosts/nuke/api/push_to_project.py | 116 ++++++++++++++++++ .../tools/push_to_project/control.py | 5 +- .../ayon_core/tools/push_to_project/main.py | 16 ++- .../tools/push_to_project/ui/window.py | 43 +++++-- 5 files changed, 170 insertions(+), 16 deletions(-) create mode 100644 client/ayon_core/hosts/nuke/api/push_to_project.py diff --git a/client/ayon_core/hosts/nuke/api/pipeline.py b/client/ayon_core/hosts/nuke/api/pipeline.py index 0d44aba2f9..23d06c4609 100644 --- a/client/ayon_core/hosts/nuke/api/pipeline.py +++ b/client/ayon_core/hosts/nuke/api/pipeline.py @@ -68,6 +68,7 @@ from .workio import ( current_file ) from .constants import ASSIST +from . import push_to_project log = Logger.get_logger(__name__) @@ -339,6 +340,11 @@ def _install_menu(): lambda: update_placeholder() ) + menu.addCommand( + "Push to Project", + lambda: push_to_project.main() + ) + menu.addSeparator() menu.addCommand( "Experimental tools...", diff --git a/client/ayon_core/hosts/nuke/api/push_to_project.py b/client/ayon_core/hosts/nuke/api/push_to_project.py new file mode 100644 index 0000000000..a67a032179 --- /dev/null +++ b/client/ayon_core/hosts/nuke/api/push_to_project.py @@ -0,0 +1,116 @@ +from collections import defaultdict +import shutil +import os + +from ayon_api import get_project, get_folder_by_id, get_task_by_id +from ayon_core.settings import get_ayon_settings, get_project_settings +from ayon_core.pipeline import Anatomy, registered_host +from ayon_core.pipeline.template_data import get_template_data +from ayon_core.pipeline.workfile import get_workdir_with_workdir_data +from ayon_core.tools.push_to_project.main import main_show + +from .utils import bake_gizmos_recursively + +import nuke + + +def bake_container(container): + """Bake containers to read nodes.""" + + node = container["node"] + + # Fetch knobs to remove in order. + knobs_to_remove = [] + remove = False + for count in range(0, node.numKnobs()): + knob = node.knob(count) + + # All knobs from "OpenPype" tab knob onwards. + if knob.name() == "AYON": + remove = True + + if remove: + knobs_to_remove.append(knob) + + # Dont remove knobs from "containerId" onwards. + if knob.name() == "containerId": + remove = False + + # Knobs needs to be remove in reverse order, because child knobs needs to + # be remove first. + for knob in reversed(knobs_to_remove): + node.removeKnob(knob) + + node["tile_color"].setValue(0) + + +def main(): + context = main_show("", "", False, True) + + if context is None: + return + + # Get workfile path to save to. + project_name = context["project_name"] + project = get_project(project_name) + folder = get_folder_by_id(project_name, context["folder_id"]) + task = get_task_by_id(project_name, context["task_id"]) + host = registered_host() + ayon_settings = get_ayon_settings() + project_settings = get_project_settings(project_name) + anatomy = Anatomy(project_name) + + workdir_data = get_template_data( + project, folder, task, host.name, ayon_settings + ) + + workdir = get_workdir_with_workdir_data( + workdir_data, + project_name, + anatomy, + project_settings=project_settings + ) + + # Save current workfile. + current_file = host.current_file() + host.save_file(current_file) + + for container in host.ls(): + bake_container(container) + + # Bake gizmos. + bake_gizmos_recursively() + + # Copy all read node files to "resources" folder next to workfile and + # change file path. + first_frame = int(nuke.root()["first_frame"].value()) + last_frame = int(nuke.root()["last_frame"].value()) + files_by_node_name = defaultdict(set) + nodes_by_name = {} + for count in range(first_frame, last_frame + 1): + nuke.frame(count) + for node in nuke.allNodes(filter="Read"): + files_by_node_name[node.name()].add( + nuke.filename(node, nuke.REPLACE) + ) + nodes_by_name[node.name()] = node + + resources_dir = os.path.join(workdir, "resources") + for name, files in files_by_node_name.items(): + dir = os.path.join(resources_dir, name) + if not os.path.exists(dir): + os.makedirs(dir) + + for f in files: + shutil.copy(f, os.path.join(dir, os.path.basename(f))) + + node = nodes_by_name[name] + path = node["file"].value().replace(os.path.dirname(f), dir) + node["file"].setValue(path.replace("\\", "/")) + + # Save current workfile to new context. + basename = os.path.basename(current_file) + host.save_file(os.path.join(workdir, basename)) + + # Open current contex workfile. + host.open_file(current_file) diff --git a/client/ayon_core/tools/push_to_project/control.py b/client/ayon_core/tools/push_to_project/control.py index 58447a8389..96792a2e9b 100644 --- a/client/ayon_core/tools/push_to_project/control.py +++ b/client/ayon_core/tools/push_to_project/control.py @@ -169,13 +169,16 @@ class PushToContextController: return self._integrate_model.get_item_status(item_id) # Processing methods - def submit(self, wait=True): + def submit(self, wait=True, context_only=False): if not self._submission_enabled: return if self._process_thread is not None: return + if context_only: + return + item_id = self._integrate_model.create_process_item( self._src_project_name, self._src_version_id, diff --git a/client/ayon_core/tools/push_to_project/main.py b/client/ayon_core/tools/push_to_project/main.py index a6ff38c16f..d230f6a660 100644 --- a/client/ayon_core/tools/push_to_project/main.py +++ b/client/ayon_core/tools/push_to_project/main.py @@ -4,14 +4,20 @@ from ayon_core.tools.utils import get_ayon_qt_app from ayon_core.tools.push_to_project.ui import PushToContextSelectWindow -def main_show(project_name, version_id): - app = get_ayon_qt_app() - - window = PushToContextSelectWindow() +def main_show(project_name, version_id, library_filter, context_only): + window = PushToContextSelectWindow( + library_filter=library_filter, context_only=context_only + ) window.show() window.set_source(project_name, version_id) - app.exec_() + if __name__ == "__main__": + app = get_ayon_qt_app() + app.exec_() + else: + window.exec_() + + return window.context @click.command() diff --git a/client/ayon_core/tools/push_to_project/ui/window.py b/client/ayon_core/tools/push_to_project/ui/window.py index 4d64509afd..2a26388221 100644 --- a/client/ayon_core/tools/push_to_project/ui/window.py +++ b/client/ayon_core/tools/push_to_project/ui/window.py @@ -14,12 +14,16 @@ from ayon_core.tools.push_to_project.control import ( ) -class PushToContextSelectWindow(QtWidgets.QWidget): - def __init__(self, controller=None): +class PushToContextSelectWindow(QtWidgets.QDialog): + def __init__( + self, controller=None, library_filter=True, context_only=False + ): super(PushToContextSelectWindow, self).__init__() if controller is None: controller = PushToContextController() self._controller = controller + self.context_only = context_only + self.context = None self.setWindowTitle("Push to project (select context)") self.setWindowIcon(QtGui.QIcon(get_app_icon_path())) @@ -45,7 +49,9 @@ class PushToContextSelectWindow(QtWidgets.QWidget): projects_combobox = ProjectsCombobox(controller, context_widget) projects_combobox.set_select_item_visible(True) - projects_combobox.set_standard_filter_enabled(True) + projects_combobox.set_standard_filter_enabled(False) + if library_filter: + projects_combobox.set_standard_filter_enabled(True) context_splitter = QtWidgets.QSplitter( QtCore.Qt.Vertical, context_widget @@ -89,13 +95,13 @@ class PushToContextSelectWindow(QtWidgets.QWidget): # --- Buttons widget --- btns_widget = QtWidgets.QWidget(self) cancel_btn = QtWidgets.QPushButton("Cancel", btns_widget) - publish_btn = QtWidgets.QPushButton("Publish", btns_widget) + push_btn = QtWidgets.QPushButton("Push", btns_widget) btns_layout = QtWidgets.QHBoxLayout(btns_widget) btns_layout.setContentsMargins(0, 0, 0, 0) btns_layout.addStretch(1) btns_layout.addWidget(cancel_btn, 0) - btns_layout.addWidget(publish_btn, 0) + btns_layout.addWidget(push_btn, 0) sep_1 = SeparatorWidget(parent=main_context_widget) sep_2 = SeparatorWidget(parent=main_context_widget) @@ -160,7 +166,7 @@ class PushToContextSelectWindow(QtWidgets.QWidget): variant_input.textChanged.connect(self._on_variant_change) comment_input.textChanged.connect(self._on_comment_change) - publish_btn.clicked.connect(self._on_select_click) + push_btn.clicked.connect(self._on_select_click) cancel_btn.clicked.connect(self._on_close_click) overlay_close_btn.clicked.connect(self._on_close_click) overlay_try_btn.clicked.connect(self._on_try_again_click) @@ -206,7 +212,7 @@ class PushToContextSelectWindow(QtWidgets.QWidget): self._folder_name_input = folder_name_input self._comment_input = comment_input - self._publish_btn = publish_btn + self._push_btn = push_btn self._overlay_widget = overlay_widget self._overlay_close_btn = overlay_close_btn @@ -234,7 +240,7 @@ class PushToContextSelectWindow(QtWidgets.QWidget): self._variant_is_valid = None self._folder_is_valid = None - publish_btn.setEnabled(False) + push_btn.setEnabled(False) overlay_close_btn.setVisible(False) overlay_try_btn.setVisible(False) @@ -372,13 +378,30 @@ class PushToContextSelectWindow(QtWidgets.QWidget): set_style_property(self._variant_input, "state", state) def _on_submission_change(self, event): - self._publish_btn.setEnabled(event["enabled"]) + self._push_btn.setEnabled(event["enabled"]) def _on_close_click(self): self.close() def _on_select_click(self): - self._process_item_id = self._controller.submit(wait=False) + result = self._controller.submit( + wait=True, context_only=self.context_only + ) + + if self.context_only: + user_values = self._controller.get_user_values() + selection_model = self._controller._selection_model + self.context = { + "project_name": selection_model._project_name, + "folder_id": selection_model._folder_id, + "task_id": selection_model._task_id, + "variant": user_values["variant"], + "comment": user_values["comment"], + "folder_name": user_values["new_folder_name"] + } + self.close() + + self._process_item = result def _on_try_again_click(self): self._process_item_id = None From e0ad6af4fb841a5ca923e0fa59295ce4880f48aa Mon Sep 17 00:00:00 2001 From: Toke Jepsen Date: Tue, 30 Apr 2024 16:34:28 +0100 Subject: [PATCH 02/15] Update client/ayon_core/hosts/nuke/api/push_to_project.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/hosts/nuke/api/push_to_project.py | 1 - 1 file changed, 1 deletion(-) diff --git a/client/ayon_core/hosts/nuke/api/push_to_project.py b/client/ayon_core/hosts/nuke/api/push_to_project.py index a67a032179..b58dd99734 100644 --- a/client/ayon_core/hosts/nuke/api/push_to_project.py +++ b/client/ayon_core/hosts/nuke/api/push_to_project.py @@ -56,7 +56,6 @@ def main(): folder = get_folder_by_id(project_name, context["folder_id"]) task = get_task_by_id(project_name, context["task_id"]) host = registered_host() - ayon_settings = get_ayon_settings() project_settings = get_project_settings(project_name) anatomy = Anatomy(project_name) From 81a75f7788f3debd781a851a48c23ce539ba1f36 Mon Sep 17 00:00:00 2001 From: Toke Jepsen Date: Tue, 30 Apr 2024 16:34:42 +0100 Subject: [PATCH 03/15] Update client/ayon_core/hosts/nuke/api/push_to_project.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/hosts/nuke/api/push_to_project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/hosts/nuke/api/push_to_project.py b/client/ayon_core/hosts/nuke/api/push_to_project.py index b58dd99734..cd7e522d06 100644 --- a/client/ayon_core/hosts/nuke/api/push_to_project.py +++ b/client/ayon_core/hosts/nuke/api/push_to_project.py @@ -60,7 +60,7 @@ def main(): anatomy = Anatomy(project_name) workdir_data = get_template_data( - project, folder, task, host.name, ayon_settings + project, folder, task, host.name, project_settings ) workdir = get_workdir_with_workdir_data( From 5f858139a7ffb57f65a93d904fc7c71cfb408094 Mon Sep 17 00:00:00 2001 From: Toke Jepsen Date: Tue, 30 Apr 2024 16:34:51 +0100 Subject: [PATCH 04/15] Update client/ayon_core/hosts/nuke/api/push_to_project.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/hosts/nuke/api/push_to_project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/hosts/nuke/api/push_to_project.py b/client/ayon_core/hosts/nuke/api/push_to_project.py index cd7e522d06..75ce08fb71 100644 --- a/client/ayon_core/hosts/nuke/api/push_to_project.py +++ b/client/ayon_core/hosts/nuke/api/push_to_project.py @@ -25,7 +25,7 @@ def bake_container(container): for count in range(0, node.numKnobs()): knob = node.knob(count) - # All knobs from "OpenPype" tab knob onwards. + # All knobs from "AYON" tab knob onwards. if knob.name() == "AYON": remove = True From 7411f2181c8ae4ec6e31639eb588e693b3f9554a Mon Sep 17 00:00:00 2001 From: Toke Jepsen Date: Tue, 30 Apr 2024 16:35:53 +0100 Subject: [PATCH 05/15] Update client/ayon_core/hosts/nuke/api/push_to_project.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/hosts/nuke/api/push_to_project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/hosts/nuke/api/push_to_project.py b/client/ayon_core/hosts/nuke/api/push_to_project.py index 75ce08fb71..2f14f4e5f4 100644 --- a/client/ayon_core/hosts/nuke/api/push_to_project.py +++ b/client/ayon_core/hosts/nuke/api/push_to_project.py @@ -26,7 +26,7 @@ def bake_container(container): knob = node.knob(count) # All knobs from "AYON" tab knob onwards. - if knob.name() == "AYON": + if knob.name() == MENU_LABEL: remove = True if remove: From 80f340cb6ce2cd3ab1bd51238660c36d6f32db31 Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Tue, 30 Apr 2024 16:49:13 +0100 Subject: [PATCH 06/15] Separate show method --- .../hosts/nuke/api/push_to_project.py | 7 ++++--- .../ayon_core/tools/push_to_project/main.py | 20 +++++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/client/ayon_core/hosts/nuke/api/push_to_project.py b/client/ayon_core/hosts/nuke/api/push_to_project.py index 2f14f4e5f4..b26e7f9aff 100644 --- a/client/ayon_core/hosts/nuke/api/push_to_project.py +++ b/client/ayon_core/hosts/nuke/api/push_to_project.py @@ -3,13 +3,14 @@ import shutil import os from ayon_api import get_project, get_folder_by_id, get_task_by_id -from ayon_core.settings import get_ayon_settings, get_project_settings +from ayon_core.settings import get_project_settings from ayon_core.pipeline import Anatomy, registered_host from ayon_core.pipeline.template_data import get_template_data from ayon_core.pipeline.workfile import get_workdir_with_workdir_data -from ayon_core.tools.push_to_project.main import main_show +from ayon_core.tools.push_to_project.main import show from .utils import bake_gizmos_recursively +from .lib import MENU_LABEL import nuke @@ -45,7 +46,7 @@ def bake_container(container): def main(): - context = main_show("", "", False, True) + context = show("", "", False, True) if context is None: return diff --git a/client/ayon_core/tools/push_to_project/main.py b/client/ayon_core/tools/push_to_project/main.py index d230f6a660..bfb921a2b7 100644 --- a/client/ayon_core/tools/push_to_project/main.py +++ b/client/ayon_core/tools/push_to_project/main.py @@ -4,22 +4,26 @@ from ayon_core.tools.utils import get_ayon_qt_app from ayon_core.tools.push_to_project.ui import PushToContextSelectWindow -def main_show(project_name, version_id, library_filter, context_only): +def show(project_name, version_id, library_filter, context_only): window = PushToContextSelectWindow( library_filter=library_filter, context_only=context_only ) window.show() window.set_source(project_name, version_id) - - if __name__ == "__main__": - app = get_ayon_qt_app() - app.exec_() - else: - window.exec_() - + window.exec_() return window.context +def main_show(project_name, version_id): + app = get_ayon_qt_app() + + window = PushToContextSelectWindow() + window.show() + window.set_source(project_name, version_id) + + app.exec_() + + @click.command() @click.option("--project", help="Source project name") @click.option("--version", help="Source version id") From 5564f07a37aba1688b2e7e5b7988ceacfc4314c0 Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Tue, 7 May 2024 14:09:39 +0100 Subject: [PATCH 07/15] Use context_dialog --- client/ayon_core/hosts/nuke/api/push_to_project.py | 4 ++-- client/ayon_core/tools/context_dialog/__init__.py | 3 ++- client/ayon_core/tools/context_dialog/window.py | 14 +++++++++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/client/ayon_core/hosts/nuke/api/push_to_project.py b/client/ayon_core/hosts/nuke/api/push_to_project.py index b26e7f9aff..7d6bfa0f32 100644 --- a/client/ayon_core/hosts/nuke/api/push_to_project.py +++ b/client/ayon_core/hosts/nuke/api/push_to_project.py @@ -7,7 +7,7 @@ from ayon_core.settings import get_project_settings from ayon_core.pipeline import Anatomy, registered_host from ayon_core.pipeline.template_data import get_template_data from ayon_core.pipeline.workfile import get_workdir_with_workdir_data -from ayon_core.tools.push_to_project.main import show +from ayon_core.tools.context_dialog import show from .utils import bake_gizmos_recursively from .lib import MENU_LABEL @@ -46,7 +46,7 @@ def bake_container(container): def main(): - context = show("", "", False, True) + context = show() if context is None: return diff --git a/client/ayon_core/tools/context_dialog/__init__.py b/client/ayon_core/tools/context_dialog/__init__.py index 4fb912fb62..66920c583c 100644 --- a/client/ayon_core/tools/context_dialog/__init__.py +++ b/client/ayon_core/tools/context_dialog/__init__.py @@ -1,7 +1,8 @@ -from .window import ContextDialog, main +from .window import ContextDialog, main, show __all__ = ( "ContextDialog", "main", + "show" ) diff --git a/client/ayon_core/tools/context_dialog/window.py b/client/ayon_core/tools/context_dialog/window.py index 828d771142..f235aa85d8 100644 --- a/client/ayon_core/tools/context_dialog/window.py +++ b/client/ayon_core/tools/context_dialog/window.py @@ -343,7 +343,7 @@ class ContextDialogController: def store_output(self): if not self._output_path: - return + return self.get_selected_context() dirpath = os.path.dirname(self._output_path) os.makedirs(dirpath, exist_ok=True) @@ -791,3 +791,15 @@ def main( window.show() app.exec_() controller.store_output() + + +def show( + strict=True +): + controller = ContextDialogController() + controller.set_strict(strict) + window = ContextDialog(controller=controller) + window.show() + window.exec_() + + return controller.store_output() From 7dd6f28e8dda2e41b4443577e1456aa415cf160a Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Tue, 7 May 2024 14:12:39 +0100 Subject: [PATCH 08/15] Revert changes to push_to_project --- .../tools/push_to_project/control.py | 5 +-- .../ayon_core/tools/push_to_project/main.py | 10 ----- .../tools/push_to_project/ui/window.py | 43 +++++-------------- 3 files changed, 11 insertions(+), 47 deletions(-) diff --git a/client/ayon_core/tools/push_to_project/control.py b/client/ayon_core/tools/push_to_project/control.py index 96792a2e9b..58447a8389 100644 --- a/client/ayon_core/tools/push_to_project/control.py +++ b/client/ayon_core/tools/push_to_project/control.py @@ -169,16 +169,13 @@ class PushToContextController: return self._integrate_model.get_item_status(item_id) # Processing methods - def submit(self, wait=True, context_only=False): + def submit(self, wait=True): if not self._submission_enabled: return if self._process_thread is not None: return - if context_only: - return - item_id = self._integrate_model.create_process_item( self._src_project_name, self._src_version_id, diff --git a/client/ayon_core/tools/push_to_project/main.py b/client/ayon_core/tools/push_to_project/main.py index bfb921a2b7..a6ff38c16f 100644 --- a/client/ayon_core/tools/push_to_project/main.py +++ b/client/ayon_core/tools/push_to_project/main.py @@ -4,16 +4,6 @@ from ayon_core.tools.utils import get_ayon_qt_app from ayon_core.tools.push_to_project.ui import PushToContextSelectWindow -def show(project_name, version_id, library_filter, context_only): - window = PushToContextSelectWindow( - library_filter=library_filter, context_only=context_only - ) - window.show() - window.set_source(project_name, version_id) - window.exec_() - return window.context - - def main_show(project_name, version_id): app = get_ayon_qt_app() diff --git a/client/ayon_core/tools/push_to_project/ui/window.py b/client/ayon_core/tools/push_to_project/ui/window.py index 2a26388221..4d64509afd 100644 --- a/client/ayon_core/tools/push_to_project/ui/window.py +++ b/client/ayon_core/tools/push_to_project/ui/window.py @@ -14,16 +14,12 @@ from ayon_core.tools.push_to_project.control import ( ) -class PushToContextSelectWindow(QtWidgets.QDialog): - def __init__( - self, controller=None, library_filter=True, context_only=False - ): +class PushToContextSelectWindow(QtWidgets.QWidget): + def __init__(self, controller=None): super(PushToContextSelectWindow, self).__init__() if controller is None: controller = PushToContextController() self._controller = controller - self.context_only = context_only - self.context = None self.setWindowTitle("Push to project (select context)") self.setWindowIcon(QtGui.QIcon(get_app_icon_path())) @@ -49,9 +45,7 @@ class PushToContextSelectWindow(QtWidgets.QDialog): projects_combobox = ProjectsCombobox(controller, context_widget) projects_combobox.set_select_item_visible(True) - projects_combobox.set_standard_filter_enabled(False) - if library_filter: - projects_combobox.set_standard_filter_enabled(True) + projects_combobox.set_standard_filter_enabled(True) context_splitter = QtWidgets.QSplitter( QtCore.Qt.Vertical, context_widget @@ -95,13 +89,13 @@ class PushToContextSelectWindow(QtWidgets.QDialog): # --- Buttons widget --- btns_widget = QtWidgets.QWidget(self) cancel_btn = QtWidgets.QPushButton("Cancel", btns_widget) - push_btn = QtWidgets.QPushButton("Push", btns_widget) + publish_btn = QtWidgets.QPushButton("Publish", btns_widget) btns_layout = QtWidgets.QHBoxLayout(btns_widget) btns_layout.setContentsMargins(0, 0, 0, 0) btns_layout.addStretch(1) btns_layout.addWidget(cancel_btn, 0) - btns_layout.addWidget(push_btn, 0) + btns_layout.addWidget(publish_btn, 0) sep_1 = SeparatorWidget(parent=main_context_widget) sep_2 = SeparatorWidget(parent=main_context_widget) @@ -166,7 +160,7 @@ class PushToContextSelectWindow(QtWidgets.QDialog): variant_input.textChanged.connect(self._on_variant_change) comment_input.textChanged.connect(self._on_comment_change) - push_btn.clicked.connect(self._on_select_click) + publish_btn.clicked.connect(self._on_select_click) cancel_btn.clicked.connect(self._on_close_click) overlay_close_btn.clicked.connect(self._on_close_click) overlay_try_btn.clicked.connect(self._on_try_again_click) @@ -212,7 +206,7 @@ class PushToContextSelectWindow(QtWidgets.QDialog): self._folder_name_input = folder_name_input self._comment_input = comment_input - self._push_btn = push_btn + self._publish_btn = publish_btn self._overlay_widget = overlay_widget self._overlay_close_btn = overlay_close_btn @@ -240,7 +234,7 @@ class PushToContextSelectWindow(QtWidgets.QDialog): self._variant_is_valid = None self._folder_is_valid = None - push_btn.setEnabled(False) + publish_btn.setEnabled(False) overlay_close_btn.setVisible(False) overlay_try_btn.setVisible(False) @@ -378,30 +372,13 @@ class PushToContextSelectWindow(QtWidgets.QDialog): set_style_property(self._variant_input, "state", state) def _on_submission_change(self, event): - self._push_btn.setEnabled(event["enabled"]) + self._publish_btn.setEnabled(event["enabled"]) def _on_close_click(self): self.close() def _on_select_click(self): - result = self._controller.submit( - wait=True, context_only=self.context_only - ) - - if self.context_only: - user_values = self._controller.get_user_values() - selection_model = self._controller._selection_model - self.context = { - "project_name": selection_model._project_name, - "folder_id": selection_model._folder_id, - "task_id": selection_model._task_id, - "variant": user_values["variant"], - "comment": user_values["comment"], - "folder_name": user_values["new_folder_name"] - } - self.close() - - self._process_item = result + self._process_item_id = self._controller.submit(wait=False) def _on_try_again_click(self): self._process_item_id = None From 2082214b356671d9a28854ad7ee2a32e2509d1db Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Tue, 7 May 2024 21:11:29 +0100 Subject: [PATCH 09/15] BigRoy feedback --- client/ayon_core/hosts/nuke/api/push_to_project.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/hosts/nuke/api/push_to_project.py b/client/ayon_core/hosts/nuke/api/push_to_project.py index 7d6bfa0f32..fde26bfe81 100644 --- a/client/ayon_core/hosts/nuke/api/push_to_project.py +++ b/client/ayon_core/hosts/nuke/api/push_to_project.py @@ -7,7 +7,7 @@ from ayon_core.settings import get_project_settings from ayon_core.pipeline import Anatomy, registered_host from ayon_core.pipeline.template_data import get_template_data from ayon_core.pipeline.workfile import get_workdir_with_workdir_data -from ayon_core.tools.context_dialog import show +from ayon_core.tools import context_dialog from .utils import bake_gizmos_recursively from .lib import MENU_LABEL @@ -46,7 +46,7 @@ def bake_container(container): def main(): - context = show() + context = context_dialog.show() if context is None: return From 92f9fda546c09f097479bc3fc9db1fd642ced0e5 Mon Sep 17 00:00:00 2001 From: Toke Jepsen Date: Thu, 23 May 2024 23:02:28 +0100 Subject: [PATCH 10/15] Update client/ayon_core/tools/context_dialog/window.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/tools/context_dialog/window.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/client/ayon_core/tools/context_dialog/window.py b/client/ayon_core/tools/context_dialog/window.py index f235aa85d8..532bfe878e 100644 --- a/client/ayon_core/tools/context_dialog/window.py +++ b/client/ayon_core/tools/context_dialog/window.py @@ -793,13 +793,10 @@ def main( controller.store_output() -def show( - strict=True -): +def ask_for_context(strict=True): controller = ContextDialogController() controller.set_strict(strict) window = ContextDialog(controller=controller) - window.show() window.exec_() - return controller.store_output() + return controller.get_selected_context() From f73d0a544d746ad1dd8f252c11720404912eb271 Mon Sep 17 00:00:00 2001 From: Toke Jepsen Date: Thu, 23 May 2024 23:02:34 +0100 Subject: [PATCH 11/15] Update client/ayon_core/tools/context_dialog/window.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/tools/context_dialog/window.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/tools/context_dialog/window.py b/client/ayon_core/tools/context_dialog/window.py index 532bfe878e..ea5fdfbaec 100644 --- a/client/ayon_core/tools/context_dialog/window.py +++ b/client/ayon_core/tools/context_dialog/window.py @@ -343,7 +343,7 @@ class ContextDialogController: def store_output(self): if not self._output_path: - return self.get_selected_context() + return dirpath = os.path.dirname(self._output_path) os.makedirs(dirpath, exist_ok=True) From 71471cf72592d8a155a2384ff07a84c8a182df54 Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Thu, 23 May 2024 23:07:02 +0100 Subject: [PATCH 12/15] Fixes for ask_for_context --- client/ayon_core/hosts/nuke/api/push_to_project.py | 2 +- client/ayon_core/tools/context_dialog/__init__.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/hosts/nuke/api/push_to_project.py b/client/ayon_core/hosts/nuke/api/push_to_project.py index fde26bfe81..f145ed652b 100644 --- a/client/ayon_core/hosts/nuke/api/push_to_project.py +++ b/client/ayon_core/hosts/nuke/api/push_to_project.py @@ -46,7 +46,7 @@ def bake_container(container): def main(): - context = context_dialog.show() + context = context_dialog.ask_for_context() if context is None: return diff --git a/client/ayon_core/tools/context_dialog/__init__.py b/client/ayon_core/tools/context_dialog/__init__.py index 66920c583c..8a77a46109 100644 --- a/client/ayon_core/tools/context_dialog/__init__.py +++ b/client/ayon_core/tools/context_dialog/__init__.py @@ -1,8 +1,8 @@ -from .window import ContextDialog, main, show +from .window import ContextDialog, main, ask_for_context __all__ = ( "ContextDialog", "main", - "show" + "ask_for_context" ) From 8c5f46dc13c22c0612936374126c2db81e9c747f Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Fri, 14 Jun 2024 11:41:11 +0200 Subject: [PATCH 13/15] Refactor saving and opening workfiles, display push message. - Refactored saving and opening workfiles in `main()` function. - Display a message indicating the pushed workfile path after pushing to project. --- .../nuke/client/ayon_nuke/api/push_to_project.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/server_addon/nuke/client/ayon_nuke/api/push_to_project.py b/server_addon/nuke/client/ayon_nuke/api/push_to_project.py index f145ed652b..852e5d0e31 100644 --- a/server_addon/nuke/client/ayon_nuke/api/push_to_project.py +++ b/server_addon/nuke/client/ayon_nuke/api/push_to_project.py @@ -70,7 +70,6 @@ def main(): anatomy, project_settings=project_settings ) - # Save current workfile. current_file = host.current_file() host.save_file(current_file) @@ -109,8 +108,11 @@ def main(): node["file"].setValue(path.replace("\\", "/")) # Save current workfile to new context. - basename = os.path.basename(current_file) - host.save_file(os.path.join(workdir, basename)) + pushed_workfile = os.path.join( + workdir, os.path.basename(current_file)) + host.save_file(pushed_workfile) - # Open current contex workfile. + # Open current context workfile. host.open_file(current_file) + + nuke.message(f"Pushed to project: \n{pushed_workfile}") From 9f85d4a2405648d672c6178a9ae5b693ebdb6a96 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Fri, 14 Jun 2024 11:41:29 +0200 Subject: [PATCH 14/15] Remove unnecessary callback for workfile builder in pipeline.py. Improve script load settings. --- server_addon/nuke/client/ayon_nuke/api/pipeline.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/server_addon/nuke/client/ayon_nuke/api/pipeline.py b/server_addon/nuke/client/ayon_nuke/api/pipeline.py index 8a9b5cb666..edf1e2dc03 100644 --- a/server_addon/nuke/client/ayon_nuke/api/pipeline.py +++ b/server_addon/nuke/client/ayon_nuke/api/pipeline.py @@ -160,9 +160,6 @@ def add_nuke_callbacks(): # template builder callbacks nuke.addOnCreate(start_workfile_template_builder, nodeClass="Root") - # TODO: remove this callback once workfile builder will be removed - nuke.addOnCreate(process_workfile_builder, nodeClass="Root") - # fix ffmpeg settings on script nuke.addOnScriptLoad(on_script_load) From 4c8a6f07ff1df67c849b1d2f009c9be412494ddc Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Fri, 14 Jun 2024 11:42:42 +0200 Subject: [PATCH 15/15] Remove unused process_workfile_builder function from pipeline module The commit removes the unused process_workfile_builder function from the pipeline module. --- server_addon/nuke/client/ayon_nuke/api/pipeline.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/server_addon/nuke/client/ayon_nuke/api/pipeline.py b/server_addon/nuke/client/ayon_nuke/api/pipeline.py index edf1e2dc03..2ba430c272 100644 --- a/server_addon/nuke/client/ayon_nuke/api/pipeline.py +++ b/server_addon/nuke/client/ayon_nuke/api/pipeline.py @@ -37,8 +37,6 @@ from .lib import ( INSTANCE_DATA_KNOB, get_main_window, WorkfileSettings, - # TODO: remove this once workfile builder will be removed - process_workfile_builder, start_workfile_template_builder, launch_workfiles_app, check_inventory_versions,