Skip to content

two_dimensional

Two-dimensional image traits.

Deep dataclass

Bases: TraitBase

Deep trait model.

Type trait model for deep EXR images.

Attributes:

Name Type Description
name str

Trait name.

description str

Trait description.

id str

id should be a namespaced trait name with a version

Source code in client/ayon_core/pipeline/traits/two_dimensional.py
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
@dataclass
class Deep(TraitBase):
    """Deep trait model.

    Type trait model for deep EXR images.

    Attributes:
        name (str): Trait name.
        description (str): Trait description.
        id (str): id should be a namespaced trait name with a version
    """

    name: ClassVar[str] = "Deep"
    description: ClassVar[str] = "Deep Trait Model"
    id: ClassVar[str] = "ayon.2d.Deep.v1"
    persistent: ClassVar[bool] = True

Image dataclass

Bases: TraitBase

Image trait model.

Type trait model for image.

Attributes:

Name Type Description
name str

Trait name.

description str

Trait description.

id str

id should be a namespaced trait name with version

Source code in client/ayon_core/pipeline/traits/two_dimensional.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
@dataclass
class Image(TraitBase):
    """Image trait model.

    Type trait model for image.

    Attributes:
        name (str): Trait name.
        description (str): Trait description.
        id (str): id should be a namespaced trait name with version
    """

    name: ClassVar[str] = "Image"
    description: ClassVar[str] = "Image Trait"
    id: ClassVar[str] = "ayon.2d.Image.v1"
    persistent: ClassVar[bool] = True

Overscan dataclass

Bases: TraitBase

Overscan trait model.

This model represents an overscan (or underscan) trait. Defines the extra pixels around the image.

Attributes:

Name Type Description
name str

Trait name.

description str

Trait description.

id str

id should be a namespaced trait name with a version

left int

Left overscan/underscan.

right int

Right overscan/underscan.

top int

Top overscan/underscan.

bottom int

Bottom overscan/underscan.

Source code in client/ayon_core/pipeline/traits/two_dimensional.py
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
@dataclass
class Overscan(TraitBase):
    """Overscan trait model.

    This model represents an overscan (or underscan) trait. Defines the
    extra pixels around the image.

    Attributes:
        name (str): Trait name.
        description (str): Trait description.
        id (str): id should be a namespaced trait name with a version
        left (int): Left overscan/underscan.
        right (int): Right overscan/underscan.
        top (int): Top overscan/underscan.
        bottom (int): Bottom overscan/underscan.
    """

    name: ClassVar[str] = "Overscan"
    description: ClassVar[str] = "Overscan Trait"
    id: ClassVar[str] = "ayon.2d.Overscan.v1"
    persistent: ClassVar[bool] = True
    left: int
    right: int
    top: int
    bottom: int

PixelBased dataclass

Bases: TraitBase

PixelBased trait model.

The pixel-related trait for image data.

Attributes:

Name Type Description
name str

Trait name.

description str

Trait description.

id str

id should be a namespaced trait name with a version

display_window_width int

Width of the image display window.

display_window_height int

Height of the image display window.

pixel_aspect_ratio float

Pixel aspect ratio.

Source code in client/ayon_core/pipeline/traits/two_dimensional.py
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
@dataclass
class PixelBased(TraitBase):
    """PixelBased trait model.

    The pixel-related trait for image data.

    Attributes:
        name (str): Trait name.
        description (str): Trait description.
        id (str): id should be a namespaced trait name with a version
        display_window_width (int): Width of the image display window.
        display_window_height (int): Height of the image display window.
        pixel_aspect_ratio (float): Pixel aspect ratio.
    """

    name: ClassVar[str] = "PixelBased"
    description: ClassVar[str] = "PixelBased Trait Model"
    id: ClassVar[str] = "ayon.2d.PixelBased.v1"
    persistent: ClassVar[bool] = True
    display_window_width: int
    display_window_height: int
    pixel_aspect_ratio: float

Planar dataclass

Bases: TraitBase

Planar trait model.

This model represents an Image with planar configuration.

Todo
  • (antirotor): Is this really a planar configuration? As with bit planes and everything? If it serves as differentiator for Deep images, should it be named differently? Like Raster?

Attributes:

Name Type Description
name str

Trait name.

description str

Trait description.

id str

id should be namespaced trait name with version

planar_configuration str

Planar configuration.

Source code in client/ayon_core/pipeline/traits/two_dimensional.py
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
@dataclass
class Planar(TraitBase):
    """Planar trait model.

    This model represents an Image with planar configuration.

    Todo:
        * (antirotor): Is this really a planar configuration? As with
            bit planes and everything? If it serves as differentiator for
            Deep images, should it be named differently? Like Raster?

    Attributes:
        name (str): Trait name.
        description (str): Trait description.
        id (str): id should be namespaced trait name with version
        planar_configuration (str): Planar configuration.
    """

    name: ClassVar[str] = "Planar"
    description: ClassVar[str] = "Planar Trait Model"
    id: ClassVar[str] = "ayon.2d.Planar.v1"
    persistent: ClassVar[bool] = True
    planar_configuration: str

UDIM dataclass

Bases: TraitBase

UDIM trait model.

This model represents a UDIM trait.

Attributes:

Name Type Description
name str

Trait name.

description str

Trait description.

id str

id should be namespaced trait name with version

udim int

UDIM value.

udim_regex str

UDIM regex.

Source code in client/ayon_core/pipeline/traits/two_dimensional.py
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
@dataclass
class UDIM(TraitBase):
    """UDIM trait model.

    This model represents a UDIM trait.

    Attributes:
        name (str): Trait name.
        description (str): Trait description.
        id (str): id should be namespaced trait name with version
        udim (int): UDIM value.
        udim_regex (str): UDIM regex.
    """

    name: ClassVar[str] = "UDIM"
    description: ClassVar[str] = "UDIM Trait"
    id: ClassVar[str] = "ayon.2d.UDIM.v1"
    persistent: ClassVar[bool] = True
    udim: list[int]
    udim_regex: Optional[str] = r"(?:\.|_)(?P<udim>\d+)\.\D+\d?$"

    # Field validator for udim_regex - this works in the pydantic model v2
    # but not with the pure data classes.
    @classmethod
    def validate_frame_regex(cls, v: Optional[str]) -> Optional[str]:
        """Validate udim regex.

        Returns:
            Optional[str]: UDIM regex.

        Raises:
            ValueError: UDIM regex must include 'udim' named group.

        """
        if v is not None and "?P<udim>" not in v:
            msg = "UDIM regex must include 'udim' named group"
            raise ValueError(msg)
        return v

    def get_file_location_for_udim(
            self,
            file_locations: FileLocations,
            udim: int,
        ) -> Optional[FileLocation]:
        """Get file location for UDIM.

        Args:
            file_locations (FileLocations): File locations.
            udim (int): UDIM value.

        Returns:
            Optional[FileLocation]: File location.

        """
        if not self.udim_regex:
            return None
        pattern = re.compile(self.udim_regex)
        for location in file_locations.file_paths:
            result = re.search(pattern, location.file_path.name)
            if result:
                udim_index = int(result.group("udim"))
                if udim_index == udim:
                    return location
        return None

    def get_udim_from_file_location(
            self, file_location: FileLocation) -> Optional[int]:
        """Get UDIM from the file location.

        Args:
            file_location (FileLocation): File location.

        Returns:
            Optional[int]: UDIM value.

        """
        if not self.udim_regex:
            return None
        pattern = re.compile(self.udim_regex)
        result = re.search(pattern, file_location.file_path.name)
        if result:
            return int(result.group("udim"))
        return None

get_file_location_for_udim(file_locations, udim)

Get file location for UDIM.

Parameters:

Name Type Description Default
file_locations FileLocations

File locations.

required
udim int

UDIM value.

required

Returns:

Type Description
Optional[FileLocation]

Optional[FileLocation]: File location.

Source code in client/ayon_core/pipeline/traits/two_dimensional.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
def get_file_location_for_udim(
        self,
        file_locations: FileLocations,
        udim: int,
    ) -> Optional[FileLocation]:
    """Get file location for UDIM.

    Args:
        file_locations (FileLocations): File locations.
        udim (int): UDIM value.

    Returns:
        Optional[FileLocation]: File location.

    """
    if not self.udim_regex:
        return None
    pattern = re.compile(self.udim_regex)
    for location in file_locations.file_paths:
        result = re.search(pattern, location.file_path.name)
        if result:
            udim_index = int(result.group("udim"))
            if udim_index == udim:
                return location
    return None

get_udim_from_file_location(file_location)

Get UDIM from the file location.

Parameters:

Name Type Description Default
file_location FileLocation

File location.

required

Returns:

Type Description
Optional[int]

Optional[int]: UDIM value.

Source code in client/ayon_core/pipeline/traits/two_dimensional.py
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
def get_udim_from_file_location(
        self, file_location: FileLocation) -> Optional[int]:
    """Get UDIM from the file location.

    Args:
        file_location (FileLocation): File location.

    Returns:
        Optional[int]: UDIM value.

    """
    if not self.udim_regex:
        return None
    pattern = re.compile(self.udim_regex)
    result = re.search(pattern, file_location.file_path.name)
    if result:
        return int(result.group("udim"))
    return None

validate_frame_regex(v) classmethod

Validate udim regex.

Returns:

Type Description
Optional[str]

Optional[str]: UDIM regex.

Raises:

Type Description
ValueError

UDIM regex must include 'udim' named group.

Source code in client/ayon_core/pipeline/traits/two_dimensional.py
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
@classmethod
def validate_frame_regex(cls, v: Optional[str]) -> Optional[str]:
    """Validate udim regex.

    Returns:
        Optional[str]: UDIM regex.

    Raises:
        ValueError: UDIM regex must include 'udim' named group.

    """
    if v is not None and "?P<udim>" not in v:
        msg = "UDIM regex must include 'udim' named group"
        raise ValueError(msg)
    return v