Merge pull request #786 from BigRoy/enhancement/better_error_on_unsaved_workfile

Better validation report when publishing from unsaved workfile
This commit is contained in:
Roy Nieterau 2024-09-04 02:04:05 +02:00 committed by GitHub
commit 9c6c0e32aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 49 additions and 6 deletions

View file

@ -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'

View file

@ -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'))

View file

@ -1,17 +1,59 @@
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):
"""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
hosts = ["maya", "houdini", "nuke"]
hosts = ["fusion", "houdini", "max", "maya", "nuke", "substancepainter"]
actions = [SaveByVersionUpAction, ShowWorkfilesAction]
def process(self, context):
current_file = context.data["currentFile"]
if not current_file:
raise PublishValidationError("File not saved")
raise PublishValidationError(
"Workfile is not saved. Please save your scene to continue.",
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.
The **Save Workfile** action will save it for you with the first
available workfile version number in your current context.
""")