Bases: InstancePlugin
, OptionalPyblishPluginMixin
Validate that the saver input resolution matches the folder resolution
Source code in client/ayon_fusion/plugins/publish/validate_saver_resolution.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76 | class ValidateSaverResolution(
pyblish.api.InstancePlugin, OptionalPyblishPluginMixin
):
"""Validate that the saver input resolution matches the folder resolution"""
order = pyblish.api.ValidatorOrder
label = "Validate Folder Resolution"
families = ["render", "image"]
hosts = ["fusion"]
optional = True
actions = [SelectInvalidAction]
def process(self, instance):
if not self.is_active(instance.data):
return
resolution = self.get_resolution(instance)
expected_resolution = self.get_expected_resolution(instance)
if resolution != expected_resolution:
raise PublishValidationError(
"The input's resolution does not match "
"the folder's resolution {}x{}.\n\n"
"The input's resolution is {}x{}.".format(
expected_resolution[0], expected_resolution[1],
resolution[0], resolution[1]
)
)
@classmethod
def get_invalid(cls, instance):
saver = instance.data["tool"]
try:
resolution = cls.get_resolution(instance)
except PublishValidationError:
resolution = None
expected_resolution = cls.get_expected_resolution(instance)
if resolution != expected_resolution:
return [saver]
@classmethod
def get_resolution(cls, instance):
saver = instance.data["tool"]
first_frame = instance.data["frameStartHandle"]
try:
return get_tool_resolution(saver, frame=first_frame)
except ValueError:
raise PublishValidationError(
"Cannot get resolution info for frame '{}'.\n\n "
"Please check that saver has connected input.".format(
first_frame
)
)
@classmethod
def get_expected_resolution(cls, instance):
entity = instance.data.get("taskEntity")
if not entity:
cls.log.debug(
"Using folder entity resolution for validation because "
f"task entity not found for instance: {instance}")
entity = instance.data["folderEntity"]
attributes = entity["attrib"]
return attributes["resolutionWidth"], attributes["resolutionHeight"]
|