Skip to content

representation

Representation

Bases: WorkflowTaskNode

Prepare a representation for publishing.

Source code in client/ayon_workflow/plugins/workflow/publish/representation.py
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
class Representation(WorkflowTaskNode):
    """Prepare a representation for publishing."""

    version = "0.0.1"
    inputs = [
        InputAttribute(
            name="input_media",
            description="The content to be published.",
            allow_multi_connection=True,
            widget={
                "name": "filepath",
                "caption": "Select a content",
                "filter": "All Files (*.*)",
            },
        ),
        InputAttribute(
            name="name",
            description="The representation name",
        ),
        InputAttribute(
            name="frame_range",
            description="The representation frame range.",
        ),
        InputAttribute(
            name="data",
            description="The raw representation dict data.",
        ),
        InputAttribute(
            name="custom_tags",
            description="The representation custom tags.",
        ),
        InputAttribute(
            name="tags",
            description="The representation tags.",
        ),
    ]
    outputs = [
        OutputAttribute(
            name="output_representation",
            description="A representation ready to be published.",
        ),
    ]

    def execute(
        self,
        input_media: Union[str, MediaType, List[Union[str, MediaType]]],
        name: Optional[str] = None,
        frame_range: Optional[FrameRange] = None,
        data: Optional[Dict[str, Any]] = None,
        custom_tags: Optional[List[str]] = None,
        tags: Optional[List[str]] = None,
    ) -> Union[RepresentationItem, List[RepresentationItem]]:
        """Prepare a representation for publishing.
        """
        # single entry, return it as representation.
        if not isinstance(input_media, list):
            return RepresentationItem(
                input_media=input_media,
                name=name,
                frame_range=frame_range,
                data=data,
                custom_tags=custom_tags,
                tags=tags,
            )

        # multiple entries, return a list of representations replicating
        # the same data, frame_range, custom_tags, tags for each entry.
        return [
            RepresentationItem(
                input_media=media,
                name=name,
                frame_range=frame_range,
                data=copy.deepcopy(data),
                custom_tags=copy.deepcopy(custom_tags),
                tags=copy.deepcopy(tags),
            )
            for media in input_media
        ]

execute(input_media, name=None, frame_range=None, data=None, custom_tags=None, tags=None)

Prepare a representation for publishing.

Source code in client/ayon_workflow/plugins/workflow/publish/representation.py
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
def execute(
    self,
    input_media: Union[str, MediaType, List[Union[str, MediaType]]],
    name: Optional[str] = None,
    frame_range: Optional[FrameRange] = None,
    data: Optional[Dict[str, Any]] = None,
    custom_tags: Optional[List[str]] = None,
    tags: Optional[List[str]] = None,
) -> Union[RepresentationItem, List[RepresentationItem]]:
    """Prepare a representation for publishing.
    """
    # single entry, return it as representation.
    if not isinstance(input_media, list):
        return RepresentationItem(
            input_media=input_media,
            name=name,
            frame_range=frame_range,
            data=data,
            custom_tags=custom_tags,
            tags=tags,
        )

    # multiple entries, return a list of representations replicating
    # the same data, frame_range, custom_tags, tags for each entry.
    return [
        RepresentationItem(
            input_media=media,
            name=name,
            frame_range=frame_range,
            data=copy.deepcopy(data),
            custom_tags=copy.deepcopy(custom_tags),
            tags=copy.deepcopy(tags),
        )
        for media in input_media
    ]