Input version used for dependency links.
The version id always points to the active real version. When the source was a hero version, the original hero metadata is stored separately so it can be persisted to farm metadata JSON and link data.
Source code in client/ayon_core/pipeline/publish/input_versions.py
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 | @dataclass(frozen=True)
class InputVersion:
"""Input version used for dependency links.
The version id always points to the active real version.
When the source was a hero version, the original hero metadata is stored
separately so it can be persisted to farm metadata JSON and link data.
"""
version_id: str
hero: bool = False
hero_version_id: Optional[str] = None
@property
def data(self) -> dict[str, Any]:
output = {}
if self.hero:
output["hero"] = True
if self.hero_version_id:
output["hero_version_id"] = self.hero_version_id
return output
def to_dict(self) -> SerializedInputVersion:
return {
"version_id": self.version_id,
"data": self.data,
}
@classmethod
def from_value(
cls,
value: Union["InputVersion", SerializedInputVersion, str]
) -> "InputVersion":
if isinstance(value, cls):
return value
if isinstance(value, str):
return cls(version_id=str(value))
if isinstance(value, dict):
version_id = value.get("version_id")
if not version_id:
raise ValueError(
"Serialized input version is missing 'version_id'."
)
data: dict = value.get("data") or {}
hero: bool = data.get("hero", False)
hero_version_id: Optional[str] = data.get("hero_version_id")
return cls(
version_id=str(version_id),
hero=hero,
hero_version_id=hero_version_id,
)
raise TypeError(
"Must have InputVersion, str or dict type."
f" Got: {value} ({type(value)})"
)
|