Skip to content

lifecycle

Lifecycle traits.

Persistent dataclass

Bases: TraitBase

Persistent trait model.

Persistent trait is opposite to transient trait. It marks representation as persistent. Such representations are persisted in the system (e.g. in the database).

Attributes:

Name Type Description
name str

Trait name.

description str

Trait description.

id str

id should be a namespaced trait name with the version

Source code in client/ayon_core/pipeline/traits/lifecycle.py
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
@dataclass
class Persistent(TraitBase):
    """Persistent trait model.

    Persistent trait is opposite to transient trait. It marks representation
    as persistent. Such representations are persisted in the system (e.g. in
    the database).

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

    name: ClassVar[str] = "Persistent"
    description: ClassVar[str] = "Persistent Trait Model"
    id: ClassVar[str] = "ayon.lifecycle.Persistent.v1"
    # Note that this affects the persistence of the trait itself, not
    # the representation. This is a class variable, so it is shared
    # among all instances of the class.
    persistent: bool = True

    def validate_trait(self, representation) -> None:  # noqa: ANN001
        """Validate representation is not Transient.

        Args:
            representation (Representation): Representation model.

        Raises:
            TraitValidationError: If representation is marked
                as both Persistent and Transient.

        """
        if representation.contains_trait(Transient):
            msg = "Representation is marked as both Persistent and Transient."
            raise TraitValidationError(self.name, msg)

validate_trait(representation)

Validate representation is not Transient.

Parameters:

Name Type Description Default
representation Representation

Representation model.

required

Raises:

Type Description
TraitValidationError

If representation is marked as both Persistent and Transient.

Source code in client/ayon_core/pipeline/traits/lifecycle.py
64
65
66
67
68
69
70
71
72
73
74
75
76
77
def validate_trait(self, representation) -> None:  # noqa: ANN001
    """Validate representation is not Transient.

    Args:
        representation (Representation): Representation model.

    Raises:
        TraitValidationError: If representation is marked
            as both Persistent and Transient.

    """
    if representation.contains_trait(Transient):
        msg = "Representation is marked as both Persistent and Transient."
        raise TraitValidationError(self.name, msg)

Transient dataclass

Bases: TraitBase

Transient trait model.

Transient trait marks representation as transient. Such representations are not persisted in the system.

Attributes:

Name Type Description
name str

Trait name.

description str

Trait description.

id str

id should be a namespaced trait name with the version

Source code in client/ayon_core/pipeline/traits/lifecycle.py
 8
 9
10
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
@dataclass
class Transient(TraitBase):
    """Transient trait model.

    Transient trait marks representation as transient. Such representations
    are not persisted in the system.

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

    name: ClassVar[str] = "Transient"
    description: ClassVar[str] = "Transient Trait Model"
    id: ClassVar[str] = "ayon.lifecycle.Transient.v1"
    persistent: ClassVar[bool] = True  # see note in Persistent

    def validate_trait(self, representation) -> None:  # noqa: ANN001
        """Validate representation is not Persistent.

        Args:
            representation (Representation): Representation model.

        Raises:
            TraitValidationError: If representation is marked as both
                Persistent and Transient.

        """
        if representation.contains_trait(Persistent):
            msg = "Representation is marked as both Persistent and Transient."
            raise TraitValidationError(self.name, msg)

validate_trait(representation)

Validate representation is not Persistent.

Parameters:

Name Type Description Default
representation Representation

Representation model.

required

Raises:

Type Description
TraitValidationError

If representation is marked as both Persistent and Transient.

Source code in client/ayon_core/pipeline/traits/lifecycle.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
def validate_trait(self, representation) -> None:  # noqa: ANN001
    """Validate representation is not Persistent.

    Args:
        representation (Representation): Representation model.

    Raises:
        TraitValidationError: If representation is marked as both
            Persistent and Transient.

    """
    if representation.contains_trait(Persistent):
        msg = "Representation is marked as both Persistent and Transient."
        raise TraitValidationError(self.name, msg)