Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge branch 'feature/validation_exceptions' into feature/validation_…
Browse files Browse the repository at this point in the history
…exceptions_tvpaint
  • Loading branch information
iLLiCiTiT committed Dec 22, 2021
2 parents 9221d47 + 2813317 commit a499902
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>Subset context</title>
<description>
## Invalid subset context

Context of the given subset doesn't match your current scene.

### How to repair?

You can fix this with "repair" button on the right.
</description>
<detail>
### __Detailed Info__ (optional)

This might happen if you are reuse old workfile and open it in different context.
(Eg. you created subset "renderCompositingDefault" from asset "Robot' in "your_project_Robot_compositing.aep", now you opened this workfile in a context "Sloth" but existing subset for "Robot" asset stayed in the workfile.)
</detail>
</error>
</root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>Scene setting</title>
<description>
## Invalid scene setting found

One of the settings in a scene doesn't match to asset settings in database.

{invalid_setting_str}

### How to repair?

Change values for {invalid_keys_str} in the scene OR change them in the asset database if they are wrong there.
</description>
<detail>
### __Detailed Info__ (optional)

This error is shown when for example resolution in the scene doesn't match to resolution set on the asset in the database.
Either value in the database or in the scene is wrong.
</detail>
</error>
<error id="file_not_found">
<title>Scene file doesn't exist</title>
<description>
## Scene file doesn't exist

Collected scene {scene_url} doesn't exist.

### How to repair?

Re-save file, start publish from the beginning again.
</description>
</error>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pyblish.api
import openpype.api
from avalon import aftereffects
from openpype.pipeline import PublishXmlValidationError


class ValidateInstanceAssetRepair(pyblish.api.Action):
Expand Down Expand Up @@ -29,7 +30,6 @@ def process(self, context, plugin):
data["asset"] = api.Session["AVALON_ASSET"]
stub.imprint(instance[0], data)


class ValidateInstanceAsset(pyblish.api.InstancePlugin):
"""Validate the instance asset is the current selected context asset.
Expand All @@ -53,9 +53,8 @@ def process(self, instance):
current_asset = api.Session["AVALON_ASSET"]
msg = (
f"Instance asset {instance_asset} is not the same "
f"as current context {current_asset}. PLEASE DO:\n"
f"Repair with 'A' action to use '{current_asset}'.\n"
f"If that's not correct value, close workfile and "
f"reopen via Workfiles!"
f"as current context {current_asset}."
)
assert instance_asset == current_asset, msg

if instance_asset != current_asset:
raise PublishXmlValidationError(self, msg)
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from avalon import aftereffects

from openpype.pipeline import PublishXmlValidationError
import openpype.hosts.aftereffects.api as api

stub = aftereffects.stub()
Expand Down Expand Up @@ -103,12 +104,14 @@ def process(self, instance):
self.log.info("current_settings:: {}".format(current_settings))

invalid_settings = []
invalid_keys = set()
for key, value in expected_settings.items():
if value != current_settings[key]:
invalid_settings.append(
"{} expected: {} found: {}".format(key, value,
current_settings[key])
)
invalid_keys.add(key)

if ((expected_settings.get("handleStart")
or expected_settings.get("handleEnd"))
Expand All @@ -120,7 +123,27 @@ def process(self, instance):
msg = "Found invalid settings:\n{}".format(
"\n".join(invalid_settings)
)
assert not invalid_settings, msg
assert os.path.exists(instance.data.get("source")), (
"Scene file not found (saved under wrong name)"
)

if invalid_settings:
invalid_keys_str = ",".join(invalid_keys)
break_str = "<br/>"
invalid_setting_str = "<b>Found invalid settings:</b><br/>{}".\
format(break_str.join(invalid_settings))

formatting_data = {
"invalid_setting_str": invalid_setting_str,
"invalid_keys_str": invalid_keys_str
}
raise PublishXmlValidationError(self, msg,
formatting_data=formatting_data)

if not os.path.exists(instance.data.get("source")):
scene_url = instance.data.get("source")
msg = "Scene file {} not found (saved under wrong name)".format(
scene_url
)
formatting_data = {
"scene_url": scene_url
}
raise PublishXmlValidationError(self, msg, key="file_not_found",
formatting_data=formatting_data)
2 changes: 0 additions & 2 deletions openpype/pipeline/create/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,6 @@ def set_publish_plugins(self, attr_plugins):
self._plugin_names_order = []
self._missing_plugins = []
self.attr_plugins = attr_plugins or []
if not attr_plugins:
return

origin_data = self._origin_data
data = self._data
Expand Down
5 changes: 4 additions & 1 deletion openpype/tools/publisher/widgets/validations_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,15 @@ def __init__(self, action, parent):
action_label = action.label or action.__name__
action_icon = getattr(action, "icon", None)
label_widget = QtWidgets.QLabel(action_label, self)
icon_label = None
if action_icon:
icon_label = IconValuePixmapLabel(action_icon, self)

layout = QtWidgets.QHBoxLayout(self)
layout.setContentsMargins(5, 0, 5, 0)
layout.addWidget(label_widget, 1)
layout.addWidget(icon_label, 0)
if icon_label is not None:
layout.addWidget(icon_label, 0)

self.setSizePolicy(
QtWidgets.QSizePolicy.Minimum,
Expand Down Expand Up @@ -272,6 +274,7 @@ def clear(self):
item = self._content_layout.takeAt(0)
widget = item.widget()
if widget:
widget.setVisible(False)
widget.deleteLater()
self._actions_mapping = {}

Expand Down

0 comments on commit a499902

Please sign in to comment.