From 49a0ccc0d5506f49335c886ca5f56dc9ca2de7ec Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Thu, 18 Jul 2024 23:28:17 +0200 Subject: [PATCH 1/6] Allow passing CollectSceneVersion but with a logged error so validators can catch a nicer error report instead --- client/ayon_core/plugins/publish/collect_scene_version.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/plugins/publish/collect_scene_version.py b/client/ayon_core/plugins/publish/collect_scene_version.py index ea4823d62a..8d643062bc 100644 --- a/client/ayon_core/plugins/publish/collect_scene_version.py +++ b/client/ayon_core/plugins/publish/collect_scene_version.py @@ -47,8 +47,9 @@ class CollectSceneVersion(pyblish.api.ContextPlugin): return if not context.data.get('currentFile'): - raise KnownPublishError("Cannot get current workfile path. " - "Make sure your scene is saved.") + self.log.error("Cannot get current workfile path. " + "Make sure your scene is saved.") + return filename = os.path.basename(context.data.get('currentFile')) From 412cc595cce900d1697146e30fdc3fb3203881f3 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Thu, 18 Jul 2024 23:31:29 +0200 Subject: [PATCH 2/6] Use regular `dict.get()` access on `instance.data.get("version")` for less confusion --- .../ayon_core/plugins/publish/collect_anatomy_instance_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/plugins/publish/collect_anatomy_instance_data.py b/client/ayon_core/plugins/publish/collect_anatomy_instance_data.py index b6636696c1..97bc47dc11 100644 --- a/client/ayon_core/plugins/publish/collect_anatomy_instance_data.py +++ b/client/ayon_core/plugins/publish/collect_anatomy_instance_data.py @@ -321,7 +321,7 @@ class CollectAnatomyInstanceData(pyblish.api.ContextPlugin): use_context_version = instance.data["followWorkfileVersion"] if use_context_version: - version_number = context.data("version") + version_number = context.data.get("version") # Even if 'follow_workfile_version' is enabled, it may not be set # because workfile version was not collected to 'context.data' From 30c32b8fa7a0dce477206ade54ecfa06940b8da4 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Fri, 19 Jul 2024 00:23:12 +0200 Subject: [PATCH 3/6] Improve Validate File Saved report and provide repair actions --- .../plugins/publish/validate_file_saved.py | 44 ++++++++++++++++++- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/plugins/publish/validate_file_saved.py b/client/ayon_core/plugins/publish/validate_file_saved.py index d459ba7ed4..976f78aa2f 100644 --- a/client/ayon_core/plugins/publish/validate_file_saved.py +++ b/client/ayon_core/plugins/publish/validate_file_saved.py @@ -1,6 +1,30 @@ +import inspect + import pyblish.api from ayon_core.pipeline.publish import PublishValidationError +from ayon_core.tools.utils.host_tools import show_workfiles +from ayon_core.pipeline.context_tools import version_up_current_workfile + + +class SaveByVersionUpAction(pyblish.api.Action): + """Save Workfile.""" + label = "Save Workfile" + on = "failed" + icon = "save" + + def process(self, context, plugin): + version_up_current_workfile() + + +class ShowWorkfilesAction(pyblish.api.Action): + """Save Workfile.""" + label = "Show Workfiles Tool..." + on = "failed" + icon = "files-o" + + def process(self, context, plugin): + show_workfiles() class ValidateCurrentSaveFile(pyblish.api.ContextPlugin): @@ -8,10 +32,26 @@ class ValidateCurrentSaveFile(pyblish.api.ContextPlugin): label = "Validate File Saved" order = pyblish.api.ValidatorOrder - 0.1 - hosts = ["maya", "houdini", "nuke"] + hosts = ["maya", "houdini", "nuke", "fusion"] + actions = [SaveByVersionUpAction, ShowWorkfilesAction] def process(self, context): current_file = context.data["currentFile"] if not current_file: - raise PublishValidationError("File not saved") + raise PublishValidationError( + "File not saved", + title="File not saved", + description=self.get_description()) + + def get_description(self): + return inspect.cleandoc(""" + ### File not saved + + Your workfile must be saved to continue publishing. + + Please save your scene. + + The **Save Workfile** action will save it for you with the first + available workfile version number in your current context. + """) From 6b7ece95e69e753dcefe46061b558b0ab960a606 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Fri, 19 Jul 2024 00:25:19 +0200 Subject: [PATCH 4/6] Improve Validate File Saved report and provide repair actions --- client/ayon_core/plugins/publish/validate_file_saved.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/client/ayon_core/plugins/publish/validate_file_saved.py b/client/ayon_core/plugins/publish/validate_file_saved.py index 976f78aa2f..bff835fd33 100644 --- a/client/ayon_core/plugins/publish/validate_file_saved.py +++ b/client/ayon_core/plugins/publish/validate_file_saved.py @@ -40,7 +40,7 @@ class ValidateCurrentSaveFile(pyblish.api.ContextPlugin): current_file = context.data["currentFile"] if not current_file: raise PublishValidationError( - "File not saved", + "Workfile is not saved. Please save your scene to continue.", title="File not saved", description=self.get_description()) @@ -50,8 +50,6 @@ class ValidateCurrentSaveFile(pyblish.api.ContextPlugin): Your workfile must be saved to continue publishing. - Please save your scene. - The **Save Workfile** action will save it for you with the first available workfile version number in your current context. """) From 86b1b4d208261bf987668b7d3655e46c832efaac Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Fri, 19 Jul 2024 00:31:12 +0200 Subject: [PATCH 5/6] Improve docstring --- client/ayon_core/plugins/publish/validate_file_saved.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/plugins/publish/validate_file_saved.py b/client/ayon_core/plugins/publish/validate_file_saved.py index bff835fd33..e4f009615a 100644 --- a/client/ayon_core/plugins/publish/validate_file_saved.py +++ b/client/ayon_core/plugins/publish/validate_file_saved.py @@ -28,7 +28,11 @@ class ShowWorkfilesAction(pyblish.api.Action): class ValidateCurrentSaveFile(pyblish.api.ContextPlugin): - """File must be saved before publishing""" + """File must be saved before publishing + + This does not validate for unsaved changes. It only validates whether + the current context was able to identify any 'currentFile'. + """ label = "Validate File Saved" order = pyblish.api.ValidatorOrder - 0.1 From 3245a74534a38bd795721810dbc2b20eda05134f Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Wed, 28 Aug 2024 20:53:12 +0200 Subject: [PATCH 6/6] Add `max` and `substancepainter` + sort the host names --- client/ayon_core/plugins/publish/validate_file_saved.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/plugins/publish/validate_file_saved.py b/client/ayon_core/plugins/publish/validate_file_saved.py index e4f009615a..8f956f586b 100644 --- a/client/ayon_core/plugins/publish/validate_file_saved.py +++ b/client/ayon_core/plugins/publish/validate_file_saved.py @@ -36,7 +36,7 @@ class ValidateCurrentSaveFile(pyblish.api.ContextPlugin): label = "Validate File Saved" order = pyblish.api.ValidatorOrder - 0.1 - hosts = ["maya", "houdini", "nuke", "fusion"] + hosts = ["fusion", "houdini", "max", "maya", "nuke", "substancepainter"] actions = [SaveByVersionUpAction, ShowWorkfilesAction] def process(self, context):