From ddf75b5e8916b853518abac40335460adceab7cb Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 22 May 2024 22:41:03 +0800 Subject: [PATCH 01/20] add ayon menu to version up saving workfile --- client/ayon_core/hosts/maya/api/lib.py | 8 ++++++++ client/ayon_core/hosts/maya/api/menu.py | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/hosts/maya/api/lib.py b/client/ayon_core/hosts/maya/api/lib.py index 2b41ffc06c..59b8cfeb16 100644 --- a/client/ayon_core/hosts/maya/api/lib.py +++ b/client/ayon_core/hosts/maya/api/lib.py @@ -22,6 +22,7 @@ from maya.api import OpenMaya import ayon_api from ayon_core.settings import get_project_settings +from ayon_core.lib import version_up from ayon_core.pipeline import ( get_current_project_name, get_current_folder_path, @@ -3390,6 +3391,13 @@ def set_colorspace(): _colormanage(viewTransformName=view_name) +def version_up_workfile(): + host = registered_host() + current_file = host.get_current_workfile() + filepath = version_up(current_file) + host.save_workfile(filepath) + + @contextlib.contextmanager def parent_nodes(nodes, parent=None): # type: (list, str) -> list diff --git a/client/ayon_core/hosts/maya/api/menu.py b/client/ayon_core/hosts/maya/api/menu.py index e3ef50cdc0..9b7670cfbb 100644 --- a/client/ayon_core/hosts/maya/api/menu.py +++ b/client/ayon_core/hosts/maya/api/menu.py @@ -123,7 +123,10 @@ def install(project_settings): parent=parent_widget ), ) - + cmds.menuItem( + "Version Up Workfile", + command=lambda *args: lib.version_up_workfile() + ) cmds.menuItem( "Set Frame Range", command=lambda *args: lib.reset_frame_range() From 5e957c50c8aeba2a89a5049ca154e670c22d8412 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 22 May 2024 22:49:21 +0800 Subject: [PATCH 02/20] add condition to check if there is a current file --- client/ayon_core/hosts/maya/api/lib.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/ayon_core/hosts/maya/api/lib.py b/client/ayon_core/hosts/maya/api/lib.py index 59b8cfeb16..204f851b2b 100644 --- a/client/ayon_core/hosts/maya/api/lib.py +++ b/client/ayon_core/hosts/maya/api/lib.py @@ -3392,8 +3392,12 @@ def set_colorspace(): def version_up_workfile(): + """Function to increment and save workfile + """ host = registered_host() current_file = host.get_current_workfile() + if not current_file: + return None filepath = version_up(current_file) host.save_workfile(filepath) From c4942d3ab8116de50f2cc68f814b8ca43a41a72d Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Tue, 28 May 2024 21:33:34 +0800 Subject: [PATCH 03/20] move version up workfile to custom tool menu --- client/ayon_core/hosts/maya/api/commands.py | 18 +++++++++++++++++- client/ayon_core/hosts/maya/api/lib.py | 12 ------------ client/ayon_core/hosts/maya/api/menu.py | 5 +---- server_addon/maya/package.py | 2 +- .../maya/server/settings/scriptsmenu.py | 10 ++++++++++ 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/client/ayon_core/hosts/maya/api/commands.py b/client/ayon_core/hosts/maya/api/commands.py index 22cf0871e2..411614c9da 100644 --- a/client/ayon_core/hosts/maya/api/commands.py +++ b/client/ayon_core/hosts/maya/api/commands.py @@ -4,7 +4,12 @@ from maya import cmds from ayon_api import get_project, get_folder_by_path -from ayon_core.pipeline import get_current_project_name, get_current_folder_path +from ayon_core.pipeline import ( + get_current_project_name, + get_current_folder_path, + registered_host +) +from ayon_core.lib import version_up class ToolWindows: @@ -116,3 +121,14 @@ def reset_resolution(): cmds.setAttr(width_attr_name, resolution_width) cmds.setAttr(height_attr_name, resolution_height) + + +def version_up_workfile(): + """Function to increment and save workfile + """ + host = registered_host() + current_file = host.get_current_workfile() + if not current_file: + return None + filepath = version_up(current_file) + host.save_workfile(filepath) diff --git a/client/ayon_core/hosts/maya/api/lib.py b/client/ayon_core/hosts/maya/api/lib.py index 204f851b2b..2b41ffc06c 100644 --- a/client/ayon_core/hosts/maya/api/lib.py +++ b/client/ayon_core/hosts/maya/api/lib.py @@ -22,7 +22,6 @@ from maya.api import OpenMaya import ayon_api from ayon_core.settings import get_project_settings -from ayon_core.lib import version_up from ayon_core.pipeline import ( get_current_project_name, get_current_folder_path, @@ -3391,17 +3390,6 @@ def set_colorspace(): _colormanage(viewTransformName=view_name) -def version_up_workfile(): - """Function to increment and save workfile - """ - host = registered_host() - current_file = host.get_current_workfile() - if not current_file: - return None - filepath = version_up(current_file) - host.save_workfile(filepath) - - @contextlib.contextmanager def parent_nodes(nodes, parent=None): # type: (list, str) -> list diff --git a/client/ayon_core/hosts/maya/api/menu.py b/client/ayon_core/hosts/maya/api/menu.py index 9b7670cfbb..e3ef50cdc0 100644 --- a/client/ayon_core/hosts/maya/api/menu.py +++ b/client/ayon_core/hosts/maya/api/menu.py @@ -123,10 +123,7 @@ def install(project_settings): parent=parent_widget ), ) - cmds.menuItem( - "Version Up Workfile", - command=lambda *args: lib.version_up_workfile() - ) + cmds.menuItem( "Set Frame Range", command=lambda *args: lib.reset_frame_range() diff --git a/server_addon/maya/package.py b/server_addon/maya/package.py index 4537c23eaa..852a6d563c 100644 --- a/server_addon/maya/package.py +++ b/server_addon/maya/package.py @@ -1,3 +1,3 @@ name = "maya" title = "Maya" -version = "0.1.20" +version = "0.1.21" diff --git a/server_addon/maya/server/settings/scriptsmenu.py b/server_addon/maya/server/settings/scriptsmenu.py index 7b0ba7d831..ef04a92f89 100644 --- a/server_addon/maya/server/settings/scriptsmenu.py +++ b/server_addon/maya/server/settings/scriptsmenu.py @@ -83,6 +83,16 @@ DEFAULT_SCRIPTSMENU_SETTINGS = { "pipeline", "shader" ] + }, + { + "type": "action", + "command": "import openpype.hosts.maya.api.commands as op_cmds; op_cmds.version_up_workfile()", + "sourcetype": "python", + "title": "Version Up", + "tooltip": "Save workfile with upversioning", + "tags": [ + "pipeline" + ] } ], "definition_json": "[]" From a696470fa2ee842ef0e66936e7cfe1630803b9e7 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 29 May 2024 17:16:43 +0800 Subject: [PATCH 04/20] add version up workfile in the general ayon core function --- client/ayon_core/hosts/maya/api/commands.py | 15 +-------------- client/ayon_core/hosts/maya/api/menu.py | 9 +++++++++ client/ayon_core/pipeline/context_tools.py | 13 ++++++++++++- package.py | 2 +- server/settings/main.py | 8 +++++++- server_addon/maya/server/settings/scriptsmenu.py | 10 ---------- 6 files changed, 30 insertions(+), 27 deletions(-) diff --git a/client/ayon_core/hosts/maya/api/commands.py b/client/ayon_core/hosts/maya/api/commands.py index 411614c9da..3dcc604d68 100644 --- a/client/ayon_core/hosts/maya/api/commands.py +++ b/client/ayon_core/hosts/maya/api/commands.py @@ -6,10 +6,8 @@ from ayon_api import get_project, get_folder_by_path from ayon_core.pipeline import ( get_current_project_name, - get_current_folder_path, - registered_host + get_current_folder_path ) -from ayon_core.lib import version_up class ToolWindows: @@ -121,14 +119,3 @@ def reset_resolution(): cmds.setAttr(width_attr_name, resolution_width) cmds.setAttr(height_attr_name, resolution_height) - - -def version_up_workfile(): - """Function to increment and save workfile - """ - host = registered_host() - current_file = host.get_current_workfile() - if not current_file: - return None - filepath = version_up(current_file) - host.save_workfile(filepath) diff --git a/client/ayon_core/hosts/maya/api/menu.py b/client/ayon_core/hosts/maya/api/menu.py index e3ef50cdc0..09e4af712a 100644 --- a/client/ayon_core/hosts/maya/api/menu.py +++ b/client/ayon_core/hosts/maya/api/menu.py @@ -25,6 +25,7 @@ from .workfile_template_builder import ( build_workfile_template, update_workfile_template ) +from ayon_core.pipeline.context_tools import version_up_workfile from ayon_core.tools.workfile_template_build import open_template_ui from .workfile_template_builder import MayaTemplateBuilder @@ -76,6 +77,14 @@ def install(project_settings): cmds.menuItem(divider=True) + if project_settings["core"].get("version_up_workfile"): + cmds.menuItem( + "Version Up Workfile", + command=lambda *args: version_up_workfile() + ) + + cmds.menuItem(divider=True) + cmds.menuItem( "Create...", command=lambda *args: host_tools.show_publisher( diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index c32d04c44c..399946cb84 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -11,7 +11,7 @@ from pyblish.lib import MessageHandler from ayon_core import AYON_CORE_ROOT from ayon_core.host import HostBase -from ayon_core.lib import is_in_tests, initialize_ayon_connection, emit_event +from ayon_core.lib import is_in_tests, initialize_ayon_connection, emit_event, version_up from ayon_core.addon import load_addons, AddonsManager from ayon_core.settings import get_project_settings @@ -579,3 +579,14 @@ def get_process_id(): if _process_id is None: _process_id = str(uuid.uuid4()) return _process_id + + +def version_up_workfile(): + """Function to increment and save workfile + """ + host = registered_host() + current_file = host.get_current_workfile() + if not current_file: + return None + filepath = version_up(current_file) + host.save_workfile(filepath) diff --git a/package.py b/package.py index 73f7174b6f..35877ff687 100644 --- a/package.py +++ b/package.py @@ -1,6 +1,6 @@ name = "core" title = "Core" -version = "0.3.3-dev.1" +version = "0.3.3-dev.2" client_dir = "ayon_core" diff --git a/server/settings/main.py b/server/settings/main.py index 40e16e7e91..1d357897d7 100644 --- a/server/settings/main.py +++ b/server/settings/main.py @@ -219,6 +219,11 @@ class CoreSettings(BaseSettingsModel): title="Project environments", section="---" ) + version_up_workfile: bool = SettingsField( + False, + title="Version Up Workfile", + section="---" + ) @validator( "environments", @@ -313,5 +318,6 @@ DEFAULT_VALUES = { "project_environments": json.dumps( {}, indent=4 - ) + ), + "version_up_workfile": False } diff --git a/server_addon/maya/server/settings/scriptsmenu.py b/server_addon/maya/server/settings/scriptsmenu.py index ef04a92f89..7b0ba7d831 100644 --- a/server_addon/maya/server/settings/scriptsmenu.py +++ b/server_addon/maya/server/settings/scriptsmenu.py @@ -83,16 +83,6 @@ DEFAULT_SCRIPTSMENU_SETTINGS = { "pipeline", "shader" ] - }, - { - "type": "action", - "command": "import openpype.hosts.maya.api.commands as op_cmds; op_cmds.version_up_workfile()", - "sourcetype": "python", - "title": "Version Up", - "tooltip": "Save workfile with upversioning", - "tags": [ - "pipeline" - ] } ], "definition_json": "[]" From 4cf797ac66926e525efe9bce4169d67263e1f9d2 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 29 May 2024 17:19:06 +0800 Subject: [PATCH 05/20] restore the setting in maya --- server_addon/maya/package.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server_addon/maya/package.py b/server_addon/maya/package.py index 852a6d563c..4537c23eaa 100644 --- a/server_addon/maya/package.py +++ b/server_addon/maya/package.py @@ -1,3 +1,3 @@ name = "maya" title = "Maya" -version = "0.1.21" +version = "0.1.20" From ca7dfa5387639e1b6af2d20a2c66c7e883271810 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 29 May 2024 17:20:12 +0800 Subject: [PATCH 06/20] restore the function in maya --- client/ayon_core/hosts/maya/api/commands.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/client/ayon_core/hosts/maya/api/commands.py b/client/ayon_core/hosts/maya/api/commands.py index 3dcc604d68..22cf0871e2 100644 --- a/client/ayon_core/hosts/maya/api/commands.py +++ b/client/ayon_core/hosts/maya/api/commands.py @@ -4,10 +4,7 @@ from maya import cmds from ayon_api import get_project, get_folder_by_path -from ayon_core.pipeline import ( - get_current_project_name, - get_current_folder_path -) +from ayon_core.pipeline import get_current_project_name, get_current_folder_path class ToolWindows: From 9e12a51c9d80be486c24da380a7de7135e78994e Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 29 May 2024 20:24:46 +0800 Subject: [PATCH 07/20] put the version up workfile setting underneath workfile --- client/ayon_core/hosts/maya/api/menu.py | 2 +- client/ayon_core/version.py | 2 +- package.py | 2 +- server/settings/main.py | 8 +------- server/settings/tools.py | 5 +++++ 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/client/ayon_core/hosts/maya/api/menu.py b/client/ayon_core/hosts/maya/api/menu.py index 09e4af712a..92759e933c 100644 --- a/client/ayon_core/hosts/maya/api/menu.py +++ b/client/ayon_core/hosts/maya/api/menu.py @@ -77,7 +77,7 @@ def install(project_settings): cmds.menuItem(divider=True) - if project_settings["core"].get("version_up_workfile"): + if project_settings["core"]["tools"]["Workfiles"].get("version_up_workfile"): cmds.menuItem( "Version Up Workfile", command=lambda *args: version_up_workfile() diff --git a/client/ayon_core/version.py b/client/ayon_core/version.py index e4297e2000..efcd78cd11 100644 --- a/client/ayon_core/version.py +++ b/client/ayon_core/version.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- """Package declaring AYON core addon version.""" -__version__ = "0.3.3-dev.1" +__version__ = "0.3.4-dev.1" diff --git a/package.py b/package.py index 35877ff687..cea2d84484 100644 --- a/package.py +++ b/package.py @@ -1,6 +1,6 @@ name = "core" title = "Core" -version = "0.3.3-dev.2" +version = "0.3.4-dev.1" client_dir = "ayon_core" diff --git a/server/settings/main.py b/server/settings/main.py index 1d357897d7..40e16e7e91 100644 --- a/server/settings/main.py +++ b/server/settings/main.py @@ -219,11 +219,6 @@ class CoreSettings(BaseSettingsModel): title="Project environments", section="---" ) - version_up_workfile: bool = SettingsField( - False, - title="Version Up Workfile", - section="---" - ) @validator( "environments", @@ -318,6 +313,5 @@ DEFAULT_VALUES = { "project_environments": json.dumps( {}, indent=4 - ), - "version_up_workfile": False + ) } diff --git a/server/settings/tools.py b/server/settings/tools.py index fb8430a71c..15f24db2fd 100644 --- a/server/settings/tools.py +++ b/server/settings/tools.py @@ -119,6 +119,10 @@ class WorkfilesLockProfile(BaseSettingsModel): class WorkfilesToolModel(BaseSettingsModel): + version_up_workfile: bool = SettingsField( + False, + title="Version Up Workfile" + ) workfile_template_profiles: list[WorkfileTemplateProfile] = SettingsField( default_factory=list, title="Workfile template profiles" @@ -407,6 +411,7 @@ DEFAULT_TOOLS_VALUES = { ] }, "Workfiles": { + "version_up_workfile": False, "workfile_template_profiles": [ { "task_types": [], From 7ebdb7be41c7576fc050a37fcc2398848de2323b Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 29 May 2024 20:28:58 +0800 Subject: [PATCH 08/20] make sure divider doesn't exist when the version up option is being disabled --- client/ayon_core/hosts/maya/api/menu.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client/ayon_core/hosts/maya/api/menu.py b/client/ayon_core/hosts/maya/api/menu.py index 92759e933c..cdd494224b 100644 --- a/client/ayon_core/hosts/maya/api/menu.py +++ b/client/ayon_core/hosts/maya/api/menu.py @@ -75,9 +75,8 @@ def install(project_settings): cmds.setParent("..", menu=True) - cmds.menuItem(divider=True) - if project_settings["core"]["tools"]["Workfiles"].get("version_up_workfile"): + cmds.menuItem(divider=True) cmds.menuItem( "Version Up Workfile", command=lambda *args: version_up_workfile() From 39ca9922bb391bf295dc53ddae8638609be3cc7d Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 29 May 2024 20:36:16 +0800 Subject: [PATCH 09/20] add description explain what verion up workfile is --- server/settings/tools.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/settings/tools.py b/server/settings/tools.py index 15f24db2fd..e185cc71ad 100644 --- a/server/settings/tools.py +++ b/server/settings/tools.py @@ -121,7 +121,8 @@ class WorkfilesLockProfile(BaseSettingsModel): class WorkfilesToolModel(BaseSettingsModel): version_up_workfile: bool = SettingsField( False, - title="Version Up Workfile" + title="Version Up Workfile", + description="Add 'Version Up Workfile' to AYON menu" ) workfile_template_profiles: list[WorkfileTemplateProfile] = SettingsField( default_factory=list, From e523b47412ae149bb3869151be94524f27330a24 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 29 May 2024 23:44:08 +0800 Subject: [PATCH 10/20] add version up workfile in ayon menu which is located inside the workfiles in core addon --- client/ayon_core/hosts/maya/api/menu.py | 13 +++++++------ server/settings/tools.py | 13 +++++++++++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/client/ayon_core/hosts/maya/api/menu.py b/client/ayon_core/hosts/maya/api/menu.py index cdd494224b..dbf353d84b 100644 --- a/client/ayon_core/hosts/maya/api/menu.py +++ b/client/ayon_core/hosts/maya/api/menu.py @@ -75,12 +75,13 @@ def install(project_settings): cmds.setParent("..", menu=True) - if project_settings["core"]["tools"]["Workfiles"].get("version_up_workfile"): - cmds.menuItem(divider=True) - cmds.menuItem( - "Version Up Workfile", - command=lambda *args: version_up_workfile() - ) + if project_settings["core"]["tools"]["Workfiles"]["ayon_menu"].get( + "version_up_workfile"): + cmds.menuItem(divider=True) + cmds.menuItem( + "Version Up Workfile", + command=lambda *args: version_up_workfile() + ) cmds.menuItem(divider=True) diff --git a/server/settings/tools.py b/server/settings/tools.py index e185cc71ad..0fb11404c9 100644 --- a/server/settings/tools.py +++ b/server/settings/tools.py @@ -118,12 +118,19 @@ class WorkfilesLockProfile(BaseSettingsModel): enabled: bool = SettingsField(True, title="Enabled") -class WorkfilesToolModel(BaseSettingsModel): +class AyonMenuModel(BaseSettingsModel): version_up_workfile: bool = SettingsField( False, title="Version Up Workfile", description="Add 'Version Up Workfile' to AYON menu" ) + + +class WorkfilesToolModel(BaseSettingsModel): + ayon_menu: AyonMenuModel = SettingsField( + default_factory=AyonMenuModel, + title="AYON Menu" + ) workfile_template_profiles: list[WorkfileTemplateProfile] = SettingsField( default_factory=list, title="Workfile template profiles" @@ -412,7 +419,9 @@ DEFAULT_TOOLS_VALUES = { ] }, "Workfiles": { - "version_up_workfile": False, + "ayon_menu": { + "version_up_workfile": False + }, "workfile_template_profiles": [ { "task_types": [], From 7077b78c3393ad766e28c01ca5a7f8caba97ccd2 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 30 May 2024 16:00:29 +0800 Subject: [PATCH 11/20] add debug message --- client/ayon_core/pipeline/context_tools.py | 1 + 1 file changed, 1 insertion(+) diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index 399946cb84..d92c43da04 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -587,6 +587,7 @@ def version_up_workfile(): host = registered_host() current_file = host.get_current_workfile() if not current_file: + log.debug("Current file not found.") return None filepath = version_up(current_file) host.save_workfile(filepath) From c2504bdd04b27db316af1cadec984f77431a223a Mon Sep 17 00:00:00 2001 From: Kayla Man <64118225+moonyuet@users.noreply.github.com> Date: Thu, 30 May 2024 16:06:51 +0800 Subject: [PATCH 12/20] Update client/ayon_core/pipeline/context_tools.py Co-authored-by: Roy Nieterau --- client/ayon_core/pipeline/context_tools.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index d92c43da04..f47c1f12f0 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -587,7 +587,9 @@ def version_up_workfile(): host = registered_host() current_file = host.get_current_workfile() if not current_file: - log.debug("Current file not found.") + log.debug( + "Current file is unsaved and can't be versioned up. " + "Please save your file first.") return None filepath = version_up(current_file) host.save_workfile(filepath) From 118b4c189f13741426f4ecabd47c4421ad22325b Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Tue, 4 Jun 2024 00:53:34 +0800 Subject: [PATCH 13/20] improve version up current workfile and code tweak --- client/ayon_core/pipeline/context_tools.py | 49 +++++++++++++++---- server/settings/tools.py | 19 +++---- .../maya/client/ayon_maya/api/menu.py | 8 +-- 3 files changed, 53 insertions(+), 23 deletions(-) diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index f47c1f12f0..a42c509125 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -11,7 +11,12 @@ from pyblish.lib import MessageHandler from ayon_core import AYON_CORE_ROOT from ayon_core.host import HostBase -from ayon_core.lib import is_in_tests, initialize_ayon_connection, emit_event, version_up +from ayon_core.lib import ( + is_in_tests, + initialize_ayon_connection, + emit_event, + version_up +) from ayon_core.addon import load_addons, AddonsManager from ayon_core.settings import get_project_settings @@ -21,6 +26,8 @@ from .template_data import get_template_data_with_names from .workfile import ( get_workdir, get_custom_workfile_template_by_string_context, + get_workfile_template_key_from_context, + get_last_workfile ) from . import ( register_loader_plugin_path, @@ -581,15 +588,37 @@ def get_process_id(): return _process_id -def version_up_workfile(): +def version_up_current_workfile(): """Function to increment and save workfile """ host = registered_host() - current_file = host.get_current_workfile() - if not current_file: - log.debug( - "Current file is unsaved and can't be versioned up. " - "Please save your file first.") - return None - filepath = version_up(current_file) - host.save_workfile(filepath) + project_name = get_current_project_name() + folder_path = get_current_folder_path() + task_name = get_current_task_name() + host_name = get_current_host_name() + + template_key = get_workfile_template_key_from_context( + project_name, + folder_path, + task_name, + host_name, + ) + anatomy = Anatomy(project_name) + + data = get_template_data_with_names( + project_name, folder_path, task_name, host_name + ) + data["root"] = anatomy.roots + + work_template = anatomy.get_template_item("work", template_key) + + # Define saving file extension + extensions = host.get_workfile_extensions() + + work_root = work_template["directory"].format_strict(data) + file_template = work_template["file"].template + last_workfile_path = get_last_workfile( + work_root, file_template, data, extensions, True + ) + current_workfile_path = version_up(last_workfile_path) + host.save_workfile(current_workfile_path) diff --git a/server/settings/tools.py b/server/settings/tools.py index 0fb11404c9..368543dbda 100644 --- a/server/settings/tools.py +++ b/server/settings/tools.py @@ -118,8 +118,9 @@ class WorkfilesLockProfile(BaseSettingsModel): enabled: bool = SettingsField(True, title="Enabled") -class AyonMenuModel(BaseSettingsModel): - version_up_workfile: bool = SettingsField( +class AYONMenuModel(BaseSettingsModel): + _layout = "expanded" + version_up_current_workfile: bool = SettingsField( False, title="Version Up Workfile", description="Add 'Version Up Workfile' to AYON menu" @@ -127,10 +128,6 @@ class AyonMenuModel(BaseSettingsModel): class WorkfilesToolModel(BaseSettingsModel): - ayon_menu: AyonMenuModel = SettingsField( - default_factory=AyonMenuModel, - title="AYON Menu" - ) workfile_template_profiles: list[WorkfileTemplateProfile] = SettingsField( default_factory=list, title="Workfile template profiles" @@ -280,6 +277,10 @@ class PublishToolModel(BaseSettingsModel): class GlobalToolsModel(BaseSettingsModel): + ayon_menu: AYONMenuModel = SettingsField( + default_factory=AYONMenuModel, + title="Tools" + ) creator: CreatorToolModel = SettingsField( default_factory=CreatorToolModel, title="Creator" @@ -299,6 +300,9 @@ class GlobalToolsModel(BaseSettingsModel): DEFAULT_TOOLS_VALUES = { + "ayon_menu": { + "version_up_current_workfile": False + }, "creator": { "product_types_smart_select": [ { @@ -419,9 +423,6 @@ DEFAULT_TOOLS_VALUES = { ] }, "Workfiles": { - "ayon_menu": { - "version_up_workfile": False - }, "workfile_template_profiles": [ { "task_types": [], diff --git a/server_addon/maya/client/ayon_maya/api/menu.py b/server_addon/maya/client/ayon_maya/api/menu.py index 7eb4e89a9e..a6f8ae2db0 100644 --- a/server_addon/maya/client/ayon_maya/api/menu.py +++ b/server_addon/maya/client/ayon_maya/api/menu.py @@ -25,7 +25,7 @@ from .workfile_template_builder import ( build_workfile_template, update_workfile_template ) -from ayon_core.pipeline.context_tools import version_up_workfile +from ayon_core.pipeline.context_tools import version_up_current_workfile from ayon_core.tools.workfile_template_build import open_template_ui from .workfile_template_builder import MayaTemplateBuilder @@ -75,12 +75,12 @@ def install(project_settings): cmds.setParent("..", menu=True) - if project_settings["core"]["tools"]["Workfiles"]["ayon_menu"].get( - "version_up_workfile"): + if project_settings["core"]["tools"]["ayon_menu"].get( + "version_up_current_workfile"): cmds.menuItem(divider=True) cmds.menuItem( "Version Up Workfile", - command=lambda *args: version_up_workfile() + command=lambda *args: version_up_current_workfile() ) cmds.menuItem(divider=True) From c2b35e21416e092dd8d1768a6e04ca9133c95a94 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Tue, 4 Jun 2024 12:40:30 +0800 Subject: [PATCH 14/20] code tweaks - big roy's comment --- client/ayon_core/pipeline/context_tools.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index a42c509125..1649c927f7 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -592,6 +592,10 @@ def version_up_current_workfile(): """Function to increment and save workfile """ host = registered_host() + if not host.has_unsaved_changes(): + print("No unsaved changes, skipping file save..") + return + project_name = get_current_project_name() folder_path = get_current_folder_path() task_name = get_current_task_name() @@ -614,11 +618,14 @@ def version_up_current_workfile(): # Define saving file extension extensions = host.get_workfile_extensions() + current_file = host.get_current_workfile() + if current_file: + extensions = [os.path.splitext(current_file)[-1]] work_root = work_template["directory"].format_strict(data) file_template = work_template["file"].template last_workfile_path = get_last_workfile( work_root, file_template, data, extensions, True ) - current_workfile_path = version_up(last_workfile_path) - host.save_workfile(current_workfile_path) + new_workfile_path = version_up(last_workfile_path) + host.save_workfile(new_workfile_path) From fc2b830522d3ecb8595699f35d11f7f585defefe Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Tue, 4 Jun 2024 12:44:47 +0800 Subject: [PATCH 15/20] bump maya addon version --- server_addon/maya/package.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server_addon/maya/package.py b/server_addon/maya/package.py index 274f74869b..0331fb2fb6 100644 --- a/server_addon/maya/package.py +++ b/server_addon/maya/package.py @@ -1,6 +1,6 @@ name = "maya" title = "Maya" -version = "0.2.0" +version = "0.2.1" ayon_required_addons = { "core": ">0.3.2", From f83ee81ba046af9ebe0dcce45d0cf91d159f85a5 Mon Sep 17 00:00:00 2001 From: Kayla Man <64118225+moonyuet@users.noreply.github.com> Date: Tue, 4 Jun 2024 22:27:19 +0800 Subject: [PATCH 16/20] Update client/ayon_core/version.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/version.py b/client/ayon_core/version.py index efcd78cd11..e4297e2000 100644 --- a/client/ayon_core/version.py +++ b/client/ayon_core/version.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- """Package declaring AYON core addon version.""" -__version__ = "0.3.4-dev.1" +__version__ = "0.3.3-dev.1" From 93dd3f2ba421dbcfd1d98fd524170e4411cc19e8 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 5 Jun 2024 21:01:58 +0800 Subject: [PATCH 17/20] menu named AYON menu and add condition check on workfile path save so that workfile is not overwritten --- client/ayon_core/pipeline/context_tools.py | 2 ++ server/settings/tools.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index 1649c927f7..8b72405048 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -628,4 +628,6 @@ def version_up_current_workfile(): work_root, file_template, data, extensions, True ) new_workfile_path = version_up(last_workfile_path) + if os.path.exists(new_workfile_path): + new_workfile_path = version_up(new_workfile_path) host.save_workfile(new_workfile_path) diff --git a/server/settings/tools.py b/server/settings/tools.py index 368543dbda..1d32169954 100644 --- a/server/settings/tools.py +++ b/server/settings/tools.py @@ -279,7 +279,7 @@ class PublishToolModel(BaseSettingsModel): class GlobalToolsModel(BaseSettingsModel): ayon_menu: AYONMenuModel = SettingsField( default_factory=AYONMenuModel, - title="Tools" + title="AYON Menu" ) creator: CreatorToolModel = SettingsField( default_factory=CreatorToolModel, From e4ea0ab94e2ea768bed0216c5e52bc8e9886c607 Mon Sep 17 00:00:00 2001 From: Kayla Man <64118225+moonyuet@users.noreply.github.com> Date: Wed, 5 Jun 2024 22:13:14 +0800 Subject: [PATCH 18/20] Update package.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- package.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.py b/package.py index cea2d84484..73f7174b6f 100644 --- a/package.py +++ b/package.py @@ -1,6 +1,6 @@ name = "core" title = "Core" -version = "0.3.4-dev.1" +version = "0.3.3-dev.1" client_dir = "ayon_core" From 869d3365195c69dc06b1c2ab2b1b7de6ff0e443a Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 5 Jun 2024 22:14:39 +0800 Subject: [PATCH 19/20] code tweaks - big roy's comment --- client/ayon_core/pipeline/context_tools.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index 8b72405048..ab44dd014e 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -624,10 +624,9 @@ def version_up_current_workfile(): work_root = work_template["directory"].format_strict(data) file_template = work_template["file"].template - last_workfile_path = get_last_workfile( + workfile_path = get_last_workfile( work_root, file_template, data, extensions, True ) - new_workfile_path = version_up(last_workfile_path) - if os.path.exists(new_workfile_path): - new_workfile_path = version_up(new_workfile_path) - host.save_workfile(new_workfile_path) + if os.path.exists(workfile_path): + workfile_path = version_up(workfile_path) + host.save_workfile(workfile_path) From 5310fd734106c582ab9968eb8578cfbc923a17d2 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 5 Jun 2024 22:44:16 +0800 Subject: [PATCH 20/20] add the condition back --- client/ayon_core/pipeline/context_tools.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index ab44dd014e..8b72405048 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -624,9 +624,10 @@ def version_up_current_workfile(): work_root = work_template["directory"].format_strict(data) file_template = work_template["file"].template - workfile_path = get_last_workfile( + last_workfile_path = get_last_workfile( work_root, file_template, data, extensions, True ) - if os.path.exists(workfile_path): - workfile_path = version_up(workfile_path) - host.save_workfile(workfile_path) + new_workfile_path = version_up(last_workfile_path) + if os.path.exists(new_workfile_path): + new_workfile_path = version_up(new_workfile_path) + host.save_workfile(new_workfile_path)