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

TVPaint: Use new publisher exceptions in validators #2435

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?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?

Yout can fix this with "Repair" button on the right. This will use '{expected_asset}' asset name and overwrite '{found_asset}' asset name in scene metadata.

After that restart publishing with Reload button.
</description>
<detail>
### How could this happen?

The subset was created in different scene with different context
or the scene file was copy pasted from different context.
</detail>
</error>
</root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>Layer names</title>
<description>## Duplicated layer names

Can't determine which layers should be published because there are duplicated layer names in the scene.

### Duplicated layer names

{layer_names}

*Check layer names for all subsets in list on left side.*

### How to repair?

Hide/rename/remove layers that should not be published.

If all of them should be published then you have duplicated subset names in the scene. In that case you have to recrete them and use different variant name.
</description>
</error>
</root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>Layers visiblity</title>
<description>## All layers are not visible

Layers visibility was changed during publishing which caused that all layers for subset "{instance_name}" are hidden.

### Layer names for **{instance_name}**

{layer_names}

*Check layer names for all subsets in the list on the left side.*

### How to repair?

Reset publishing and do not change visibility of layers after hitting publish button.
</description>
</error>
</root>
21 changes: 21 additions & 0 deletions openpype/hosts/tvpaint/plugins/publish/help/validate_marks.xml
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>Frame range</title>
<description>## Invalid render frame range

Scene frame range which will be rendered is defined by MarkIn and MarkOut. Expected frame range is {expected_frame_range} and current frame range is {current_frame_range}.

It is also required that MarkIn and MarkOut are enabled in the scene. Their color is highlighted on timeline when are enabled.

- MarkIn is {mark_in_enable_state}
- MarkOut is {mark_out_enable_state}

### How to repair?

Yout can fix this with "Repair" button on the right. That will change MarkOut to {expected_mark_out}.

Or you can manually modify MarkIn and MarkOut in the scene timeline.
</description>
</error>
</root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>Missing layers</title>
<description>## Missing layers for render pass

Render pass subset "{instance_name}" has stored layer names that belong to it's rendering scope but layers were not found in scene.

### Missing layer names

{layer_names}

### How to repair?

Find layers that belong to subset {instance_name} and rename them back to expected layer names or remove the subset and create new with right layers.
</description>
</error>
</root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>Render pass group</title>
<description>## Invalid group of Render Pass layers

Layers of Render Pass {instance_name} belong to Render Group which is defined by TVPaint color group {expected_group}. But the layers are not in the group.

### How to repair?

Change the color group to {expected_group} on layers {layer_names}.
</description>
</error>
</root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>Scene settings</title>
<description>## Invalid scene settings

Scene settings do not match to expected values.

**FPS**
- Expected value: {expected_fps}
- Current value: {current_fps}

**Resolution**
- Expected value: {expected_width}x{expected_height}
- Current value: {current_width}x{current_height}

**Pixel ratio**
- Expected value: {expected_pixel_ratio}
- Current value: {current_pixel_ratio}

### How to repair?

FPS and Pixel ratio can be modified in scene setting. Wrong resolution can be fixed with changing resolution of scene but due to TVPaint limitations it is possible that you will need to create new scene.
</description>
</error>
</root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>First frame</title>
<description>## MarkIn is not set to 0

MarkIn in your scene must start from 0 fram index but MarkIn is set to {current_start_frame}.

### How to repair?

You can modify MarkIn manually or hit the "Repair" button on the right which will change MarkIn to 0 (does not change MarkOut).
</description>
</error>
</root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>Missing metadata</title>
<description>## Your scene miss context metadata

Your scene does not contain metadata about {missing_metadata}.

### How to repair?

Resave the scene using Workfiles tool or hit the "Repair" button on the right.
</description>
<detail>
### How this could happend?

You're using scene file that was not created using Workfiles tool.
</detail>
</error>
</root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>Project name</title>
<description>## Your scene is from different project

It is not possible to publish into project "{workfile_project_name}" when TVPaint was opened with project "{env_project_name}" in context.

### How to repair?

If the workfile belongs to project "{env_project_name}" then use Workfiles tool to resave it.

Otherwise close TVPaint and launch it again from project you want to publish in.
</description>
<detail>
### How this could happend?

You've opened workfile from different project. You've opened TVPaint on a task from "{env_project_name}" then you've opened TVPaint again on task from "{workfile_project_name}" without closing the TVPaint. Because TVPaint can run only once the project didn't change.

### Why it is important?
Because project may affect how TVPaint works or change publishing behavior it is dangerous to allow change project context in many ways. For example publishing will not run as expected.
</detail>
</error>
</root>
23 changes: 17 additions & 6 deletions openpype/hosts/tvpaint/plugins/publish/validate_asset_name.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pyblish.api
from avalon.tvpaint import pipeline
from openpype.pipeline import PublishXmlValidationError


class FixAssetNames(pyblish.api.Action):
Expand Down Expand Up @@ -27,7 +28,7 @@ def process(self, context, plugin):
pipeline._write_instances(new_instance_items)


class ValidateMissingLayers(pyblish.api.ContextPlugin):
class ValidateAssetNames(pyblish.api.ContextPlugin):
"""Validate assset name present on instance.

Asset name on instance should be the same as context's.
Expand All @@ -48,8 +49,18 @@ def process(self, context):
instance_label = (
instance.data.get("label") or instance.data["name"]
)
raise AssertionError((
"Different asset name on instance then context's."
" Instance \"{}\" has asset name: \"{}\""
" Context asset name is: \"{}\""
).format(instance_label, asset_name, context_asset_name))

raise PublishXmlValidationError(
self,
(
"Different asset name on instance then context's."
" Instance \"{}\" has asset name: \"{}\""
" Context asset name is: \"{}\""
).format(
instance_label, asset_name, context_asset_name
),
formatting_data={
"expected_asset": context_asset_name,
"found_asset": asset_name
}
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pyblish.api
from openpype.pipeline import PublishXmlValidationError


class ValidateLayersGroup(pyblish.api.InstancePlugin):
Expand Down Expand Up @@ -30,14 +31,20 @@ def process(self, instance):
"\"{}\"".format(layer_name)
for layer_name in duplicated_layer_names
])

# Raise an error
raise AssertionError(
detail_lines = [
"- {}".format(layer_name)
for layer_name in set(duplicated_layer_names)
]
raise PublishXmlValidationError(
self,
(
"Layers have duplicated names for instance {}."
# Description what's wrong
" There are layers with same name and one of them is marked"
" for publishing so it is not possible to know which should"
" be published. Please look for layers with names: {}"
).format(instance.data["label"], layers_msg)
).format(instance.data["label"], layers_msg),
formatting_data={
"layer_names": "<br/>".join(detail_lines)
}
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import pyblish.api
from openpype.pipeline import PublishXmlValidationError


# TODO @iLLiCiTiT add repair action to disable instances?
class ValidateLayersVisiblity(pyblish.api.InstancePlugin):
"""Validate existence of renderPass layers."""

Expand All @@ -9,8 +11,26 @@ class ValidateLayersVisiblity(pyblish.api.InstancePlugin):
families = ["review", "renderPass", "renderLayer"]

def process(self, instance):
layer_names = set()
for layer in instance.data["layers"]:
layer_names.add(layer["name"])
if layer["visible"]:
return

raise AssertionError("All layers of instance are not visible.")
instance_label = (
instance.data.get("label") or instance.data["name"]
)

raise PublishXmlValidationError(
self,
"All layers of instance \"{}\" are not visible.".format(
instance_label
),
formatting_data={
"instance_name": instance_label,
"layer_names": "<br/>".join([
"- {}".format(layer_name)
for layer_name in layer_names
])
}
)
38 changes: 32 additions & 6 deletions openpype/hosts/tvpaint/plugins/publish/validate_marks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pyblish.api
from avalon.tvpaint import lib
from openpype.pipeline import PublishXmlValidationError


class ValidateMarksRepair(pyblish.api.Action):
Expand Down Expand Up @@ -73,9 +74,34 @@ def process(self, context):
"expected": expected_data[k]
}

if invalid:
raise AssertionError(
"Marks does not match database:\n{}".format(
json.dumps(invalid, sort_keys=True, indent=4)
)
)
# Validation ends
if not invalid:
return

current_frame_range = (
(current_data["markOut"] - current_data["markIn"]) + 1
)
expected_frame_range = (
(expected_data["markOut"] - expected_data["markIn"]) + 1
)
mark_in_enable_state = "disabled"
if current_data["markInState"]:
mark_in_enable_state = "enabled"

mark_out_enable_state = "disabled"
if current_data["markOutState"]:
mark_out_enable_state = "enabled"

raise PublishXmlValidationError(
self,
"Marks does not match database:\n{}".format(
json.dumps(invalid, sort_keys=True, indent=4)
),
formatting_data={
"current_frame_range": str(current_frame_range),
"expected_frame_range": str(expected_frame_range),
"mark_in_enable_state": mark_in_enable_state,
"mark_out_enable_state": mark_out_enable_state,
"expected_mark_out": expected_data["markOut"]
}
)
Loading