Skip to content

Commit

Permalink
Merge pull request #861 from ynput/enhancement/exception-for-artist-e…
Browse files Browse the repository at this point in the history
…rror

Publisher: Exception for artist error
  • Loading branch information
iLLiCiTiT authored Sep 23, 2024
2 parents d00fa72 + 82d77d2 commit a7977ad
Show file tree
Hide file tree
Showing 12 changed files with 427 additions and 263 deletions.
6 changes: 4 additions & 2 deletions client/ayon_core/pipeline/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@
)

from .publish import (
KnownPublishError,
PublishError,
PublishValidationError,
PublishXmlValidationError,
KnownPublishError,
AYONPyblishPluginMixin,
OptionalPyblishPluginMixin,
)
Expand Down Expand Up @@ -162,9 +163,10 @@
"get_repres_contexts",

# --- Publish ---
"KnownPublishError",
"PublishError",
"PublishValidationError",
"PublishXmlValidationError",
"KnownPublishError",
"AYONPyblishPluginMixin",
"OptionalPyblishPluginMixin",

Expand Down
18 changes: 10 additions & 8 deletions client/ayon_core/pipeline/publish/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ AYON is using `pyblish` for publishing process which is a little bit extented an
## Exceptions
AYON define few specific exceptions that should be used in publish plugins.

### Validation exception
Validation plugins should raise `PublishValidationError` to show to an artist what's wrong and give him actions to fix it. The exception says that error happened in plugin can be fixed by artist himself (with or without action on plugin). Any other errors will stop publishing immediately. Exception `PublishValidationError` raised after validation order has same effect as any other exception.
### Publish error
Exception `PublishError` can be raised on known error. The message is shown to artist.
- **message** Error message.
- **title** Short description of error (2-5 words). Title can be used for grouping of exceptions per plugin.
- **description** Override of 'message' for UI, you can add markdown and html. By default, is filled with 'message'.
- **detail** Additional detail message that is hidden under collapsed component.

Exception `PublishValidationError` 3 arguments:
- **message** Which is not used in UI but for headless publishing.
- **title** Short description of error (2-5 words). Title is used for grouping of exceptions per plugin.
- **description** Detailed description of happened issue where markdown and html can be used.
Arguments `title`, `description` and `detail` are optional. Title is filled with generic message "This is not your fault" if is not passed.

### Validation exception
Validation plugins should raise `PublishValidationError` to show to an artist what's wrong and give him actions to fix it. The exception says that error happened in plugin can be fixed by artist himself (with or without action on plugin). Any other errors will stop publishing immediately. Exception `PublishValidationError` raised after validation order has same effect as any other exception.

### Known errors
When there is a known error that can't be fixed by user (e.g. can't connect to deadline service, etc.) `KnownPublishError` should be raise. The only difference is that it's message is shown in UI to artist otherwise a neutral message without context is shown.
Exception expect same arguments as `PublishError`. Value of `title` is filled with plugin label if is not passed.

## Plugin extension
Publish plugins can be extended by additional logic when inherits from `AYONPyblishPluginMixin` which can be used as mixin (additional inheritance of class).
Expand Down
8 changes: 6 additions & 2 deletions client/ayon_core/pipeline/publish/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
AbstractMetaInstancePlugin,
AbstractMetaContextPlugin,

KnownPublishError,
PublishError,
PublishValidationError,
PublishXmlValidationError,
KnownPublishError,

AYONPyblishPluginMixin,
OptionalPyblishPluginMixin,

Expand Down Expand Up @@ -61,9 +63,11 @@
"AbstractMetaInstancePlugin",
"AbstractMetaContextPlugin",

"KnownPublishError",
"PublishError",
"PublishValidationError",
"PublishXmlValidationError",
"KnownPublishError",

"AYONPyblishPluginMixin",
"OptionalPyblishPluginMixin",

Expand Down
56 changes: 36 additions & 20 deletions client/ayon_core/pipeline/publish/publish_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,52 @@ class AbstractMetaContextPlugin(ABCMeta, ExplicitMetaPlugin):
pass


class PublishValidationError(Exception):
"""Validation error happened during publishing.
class KnownPublishError(Exception):
"""Publishing crashed because of known error.
This exception should be used when validation publishing failed.
Artist can't affect source of the error.
Has additional UI specific attributes that may be handy for artist.
Deprecated:
Please use `PublishError` instead. Marked as deprecated 24/09/02.
Args:
message(str): Message of error. Short explanation an issue.
title(str): Title showed in UI. All instances are grouped under
single title.
description(str): Detailed description of an error. It is possible
to use Markdown syntax.
"""
pass


class PublishError(Exception):
"""Publishing crashed because of known error.
Message will be shown in UI for artist.
Args:
message (str): Message of error. Short explanation an issue.
title (Optional[str]): Title showed in UI.
description (Optional[str]): Detailed description of an error.
It is possible to use Markdown syntax.
"""
def __init__(self, message, title=None, description=None, detail=None):
self.message = message
self.title = title
self.description = description or message
self.detail = detail
super(PublishValidationError, self).__init__(message)
super().__init__(message)


class PublishValidationError(PublishError):
"""Validation error happened during publishing.
This exception should be used when validation publishing failed.
Publishing does not stop during validation order if this
exception is raised.
Has additional UI specific attributes that may be handy for artist.
Argument 'title' is used to group errors.
"""
pass


class PublishXmlValidationError(PublishValidationError):
Expand All @@ -68,15 +93,6 @@ def __init__(
)


class KnownPublishError(Exception):
"""Publishing crashed because of known error.
Message will be shown in UI for artist.
"""

pass


class AYONPyblishPluginMixin:
# TODO
# executable_in_thread = False
Expand Down
16 changes: 8 additions & 8 deletions client/ayon_core/style/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1118,39 +1118,39 @@ ValidationArtistMessage QLabel {
font-weight: bold;
}

#ValidationActionButton {
#PublishActionButton {
border-radius: 0.2em;
padding: 4px 6px 4px 6px;
background: {color:bg-buttons};
}

#ValidationActionButton:hover {
#PublishActionButton:hover {
background: {color:bg-buttons-hover};
color: {color:font-hover};
}

#ValidationActionButton:disabled {
#PublishActionButton:disabled {
background: {color:bg-buttons-disabled};
}

#ValidationErrorTitleFrame {
#PublishErrorTitleFrame {
border-radius: 0.2em;
background: {color:bg-buttons};
}

#ValidationErrorTitleFrame:hover {
#PublishErrorTitleFrame:hover {
background: {color:bg-buttons-hover};
}

#ValidationErrorTitleFrame[selected="1"] {
#PublishErrorTitleFrame[selected="1"] {
background: {color:bg-view-selection};
}

#ValidationErrorInstanceList {
#PublishErrorInstanceList {
border-radius: 0;
}

#ValidationErrorInstanceList::item {
#PublishErrorInstanceList::item {
border-bottom: 1px solid {color:border};
border-left: 1px solid {color:border};
}
Expand Down
11 changes: 5 additions & 6 deletions client/ayon_core/tools/publisher/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
)

if TYPE_CHECKING:
from .models import CreatorItem
from .models import CreatorItem, PublishErrorInfo


class CardMessageTypes:
Expand Down Expand Up @@ -543,22 +543,21 @@ def get_publish_max_progress(self) -> int:
pass

@abstractmethod
def get_publish_error_msg(self) -> Union[str, None]:
def get_publish_error_info(self) -> Optional["PublishErrorInfo"]:
"""Current error message which cause fail of publishing.
Returns:
Union[str, None]: Message which will be showed to artist or
None.
"""
Optional[PublishErrorInfo]: Error info or None.
"""
pass

@abstractmethod
def get_publish_report(self) -> Dict[str, Any]:
pass

@abstractmethod
def get_validation_errors(self):
def get_publish_errors_report(self):
pass

@abstractmethod
Expand Down
8 changes: 4 additions & 4 deletions client/ayon_core/tools/publisher/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,14 +496,14 @@ def get_publish_max_progress(self):
def get_publish_progress(self):
return self._publish_model.get_progress()

def get_publish_error_msg(self):
return self._publish_model.get_error_msg()
def get_publish_error_info(self):
return self._publish_model.get_error_info()

def get_publish_report(self):
return self._publish_model.get_publish_report()

def get_validation_errors(self):
return self._publish_model.get_validation_errors()
def get_publish_errors_report(self):
return self._publish_model.get_publish_errors_report()

def set_comment(self, comment):
"""Set comment from ui to pyblish context.
Expand Down
3 changes: 2 additions & 1 deletion client/ayon_core/tools/publisher/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from .create import CreateModel, CreatorItem
from .publish import PublishModel
from .publish import PublishModel, PublishErrorInfo


__all__ = (
"CreateModel",
"CreatorItem",

"PublishModel",
"PublishErrorInfo",
)
Loading

0 comments on commit a7977ad

Please sign in to comment.