Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aftereffects: New style validations for New publisher #2430

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)