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

Harmony: Added new style validations for New Publisher #2434

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions openpype/hosts/harmony/plugins/publish/help/validate_audio.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>Missing audio file</title>
<description>
## Cannot locate linked audio file

Audio file at {audio_url} cannot be found.

### How to repair?

Copy audio file to the highlighted location or remove audio link in the workfile.
</description>
</error>
</root>
25 changes: 25 additions & 0 deletions openpype/hosts/harmony/plugins/publish/help/validate_instances.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>Subset context</title>
<description>
## Invalid subset context

Asset name found '{found}' in subsets, expected '{expected}'.

### How to repair?

You can fix this with `Repair` button on the right. This will use '{expected}' asset name and overwrite '{found}' asset name in scene metadata.

After that restart `Publish` with a `Reload button`.

If this is unwanted, close workfile and open again, that way different asset value would be used for context information.
</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>
9 changes: 8 additions & 1 deletion openpype/hosts/harmony/plugins/publish/validate_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from avalon import harmony

from openpype.pipeline import PublishXmlValidationError


class ValidateAudio(pyblish.api.InstancePlugin):
"""Ensures that there is an audio file in the scene.
Expand Down Expand Up @@ -42,4 +44,9 @@ def process(self, instance):

msg = "You are missing audio file:\n{}".format(audio_path)

assert os.path.isfile(audio_path), msg
formatting_data = {
"audio_url": audio_path
}
if os.path.isfile(audio_path):
raise PublishXmlValidationError(self, msg,
formatting_data=formatting_data)
14 changes: 12 additions & 2 deletions openpype/hosts/harmony/plugins/publish/validate_instances.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import os

from avalon import harmony
import pyblish.api
import openpype.api
from avalon import harmony

from openpype.pipeline import PublishXmlValidationError


class ValidateInstanceRepair(pyblish.api.Action):
Expand Down Expand Up @@ -45,4 +47,12 @@ def process(self, instance):
"Instance asset is not the same as current asset:"
f"\nInstance: {instance_asset}\nCurrent: {current_asset}"
)
assert instance_asset == current_asset, msg

formatting_data = {
"found": instance_asset,
"expected": current_asset
}
if instance_asset != current_asset:
raise PublishXmlValidationError(self, msg,
formatting_data=formatting_data)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank line at end of file

32 changes: 28 additions & 4 deletions openpype/hosts/harmony/plugins/publish/validate_scene_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import pyblish.api

from avalon import harmony

import openpype.hosts.harmony
from openpype.pipeline import PublishXmlValidationError


class ValidateSceneSettingsRepair(pyblish.api.Action):
Expand Down Expand Up @@ -102,13 +104,15 @@ def process(self, instance):
self.log.debug("current scene settings {}".format(current_settings))

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

if ((expected_settings["handleStart"]
or expected_settings["handleEnd"])
Expand All @@ -120,10 +124,30 @@ def process(self, instance):
msg = "Found invalid settings:\n{}".format(
json.dumps(invalid_settings, sort_keys=True, indent=4)
)
assert not invalid_settings, msg
assert os.path.exists(instance.context.data.get("scenePath")), (
"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)

scene_url = instance.context.data.get("scenePath")
if not os.path.exists(scene_url):
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)


def _update_frames(expected_settings):
Expand Down