Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
ec847d8
:art: add support for representation traits
antirotor Dec 16, 2024
f7c397c
✨ add traits to representation fields
antirotor Mar 28, 2025
2c7916c
Merge remote-tracking branch 'origin/enhancement/add-traits-to-repres…
antirotor Apr 7, 2025
d0f560d
:recycle: remove traits from default fields
antirotor Apr 7, 2025
760f38a
Merge branch 'develop' into feature/add-support-for-representation-tr…
antirotor Apr 8, 2025
71df683
:sparkles: add traits to operations
antirotor Apr 9, 2025
891f637
:bug: fix type error
antirotor Apr 9, 2025
93a8c37
:memo: add todo for future
antirotor Apr 9, 2025
fb422ab
Merge remote-tracking branch 'origin/feature/add-support-for-represen…
antirotor Apr 9, 2025
f17c808
change order of traits argument
iLLiCiTiT Apr 11, 2025
adb3f85
don't add traits if are empty
iLLiCiTiT Apr 11, 2025
24f2791
rename 'grahql_allows_traits_in_representations' to 'representation_t…
iLLiCiTiT Apr 11, 2025
efb118d
Merge branch 'develop' into feature/add-support-for-representation-tr…
iLLiCiTiT Apr 11, 2025
018dcd4
actually add traits to repre fields
iLLiCiTiT Apr 14, 2025
a3cd06c
reverse to 'graphql_allows_traits_in_representations'
iLLiCiTiT Apr 14, 2025
a932482
update public api
iLLiCiTiT Apr 14, 2025
fb51cd0
Merge branch 'develop' into feature/add-support-for-representation-tr…
iLLiCiTiT Apr 14, 2025
a919f7c
move the 'traits' after 'data'
iLLiCiTiT Apr 14, 2025
2629098
Merge branch 'develop' into feature/add-support-for-representation-tr…
iLLiCiTiT Apr 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ayon_api/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5475,6 +5475,7 @@ def create_representation(
files: Optional[List[Dict[str, Any]]] = None,
attrib: Optional[Dict[str, Any]] = None,
data: Optional[Dict[str, Any]] = None,
traits: Optional[Dict[str, Any]] = None,
tags: Optional[List[str]] = None,
status: Optional[str] = None,
active: Optional[bool] = None,
Expand All @@ -5489,6 +5490,8 @@ def create_representation(
files (Optional[list[dict]]): Representation files information.
attrib (Optional[dict[str, Any]]): Representation attributes.
data (Optional[dict[str, Any]]): Representation data.
traits (Optional[dict[str, Any]]): Representation traits
serialized data as dict.
tags (Optional[Iterable[str]]): Representation tags.
status (Optional[str]): Representation status.
active (Optional[bool]): Representation active state.
Expand All @@ -5507,6 +5510,7 @@ def create_representation(
files=files,
attrib=attrib,
data=data,
traits=traits,
tags=tags,
status=status,
active=active,
Expand All @@ -5522,6 +5526,7 @@ def update_representation(
files: Optional[List[Dict[str, Any]]] = None,
attrib: Optional[Dict[str, Any]] = None,
data: Optional[Dict[str, Any]] = None,
traits: Optional[Dict[str, Any]] = None,
tags: Optional[List[str]] = None,
status: Optional[str] = None,
active: Optional[bool] = None,
Expand All @@ -5542,6 +5547,7 @@ def update_representation(
information.
attrib (Optional[dict[str, Any]]): New attributes.
data (Optional[dict[str, Any]]): New data.
traits (Optional[dict[str, Any]]): New traits.
tags (Optional[Iterable[str]]): New tags.
status (Optional[str]): New status.
active (Optional[bool]): New active state.
Expand All @@ -5556,6 +5562,7 @@ def update_representation(
files=files,
attrib=attrib,
data=data,
traits=traits,
tags=tags,
status=status,
active=active,
Expand Down
1 change: 1 addition & 0 deletions ayon_api/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
"data",
"status",
"tags",
"traits",
}

REPRESENTATION_FILES_FIELDS = {
Expand Down
16 changes: 14 additions & 2 deletions ayon_api/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ def new_representation_entity(
tags=None,
attribs=None,
data=None,
entity_id=None
traits=None,
entity_id=None,
):
"""Create skeleton data of representation entity.

Expand All @@ -290,6 +291,8 @@ def new_representation_entity(
attribs (Optional[Dict[str, Any]]): Explicitly set attributes
of representation.
data (Optional[Dict[str, Any]]): Representation entity data.
traits (Optional[Dict[str, Any]]): Representation traits. Empty
if not passed.
entity_id (Optional[str]): Predefined id of entity. New id is created
if not passed.

Expand All @@ -309,8 +312,10 @@ def new_representation_entity(
"files": files,
"name": name,
"data": data,
"attrib": attribs
"attrib": attribs,
}
if traits:
output["traits"] = traits
if tags:
output["tags"] = tags
if status:
Expand Down Expand Up @@ -1359,6 +1364,7 @@ def create_representation(
files=None,
attrib=None,
data=None,
traits=None,
tags=None,
status=None,
active=None,
Expand All @@ -1373,6 +1379,8 @@ def create_representation(
files (Optional[list[dict]]): Representation files information.
attrib (Optional[dict[str, Any]]): Representation attributes.
data (Optional[dict[str, Any]]): Representation data.
traits (Optional[Dict[str, Any]]): Representation traits. Empty
if not passed.
tags (Optional[Iterable[str]]): Representation tags.
status (Optional[str]): Representation status.
active (Optional[bool]): Representation active state.
Expand All @@ -1394,6 +1402,7 @@ def create_representation(
("files", files),
("attrib", attrib),
("data", data),
("traits", traits),
("tags", tags),
("status", status),
("active", active),
Expand All @@ -1416,6 +1425,7 @@ def update_representation(
files=None,
attrib=None,
data=None,
traits=None,
tags=None,
status=None,
active=None,
Expand All @@ -1436,6 +1446,7 @@ def update_representation(
information.
attrib (Optional[dict[str, Any]]): New attributes.
data (Optional[dict[str, Any]]): New data.
traits (Optional[Dict[str, Any]]): New representation traits.
tags (Optional[Iterable[str]]): New tags.
status (Optional[str]): New status.
active (Optional[bool]): New active state.
Expand All @@ -1451,6 +1462,7 @@ def update_representation(
("files", files),
("attrib", attrib),
("data", data),
("traits", traits),
("tags", tags),
("status", status),
("active", active),
Expand Down
23 changes: 23 additions & 0 deletions ayon_api/server_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ def __init__(
self._server_version_tuple = None

self._graphql_allows_data_in_query = None
self._graphql_allows_traits_in_representations: Optional[bool] = None

self._session = None

Expand Down Expand Up @@ -1116,6 +1117,18 @@ def graphql_allows_data_in_query(self) -> bool:
self._graphql_allows_data_in_query = graphql_allows_data_in_query
return self._graphql_allows_data_in_query


@property
def graphql_allows_traits_in_representations(self) -> bool:
"""Check server support for representation traits."""
if self._graphql_allows_traits_in_representations is None:
major, minor, patch, _, _ = self.server_version_tuple
self._graphql_allows_traits_in_representations = (
(major, minor, patch) >= (1, 7, 5)
)
return self._graphql_allows_traits_in_representations


def _get_user_info(self) -> Optional[Dict[str, Any]]:
if self._access_token is None:
return None
Expand Down Expand Up @@ -2779,6 +2792,9 @@ def get_default_fields_for_type(self, entity_type: str) -> Set[str]:
if not self.graphql_allows_data_in_query:
entity_type_defaults.discard("data")

if not self.graphql_allows_traits_in_representations:
entity_type_defaults.discard("traits")

elif entity_type == "folderType":
entity_type_defaults = set(DEFAULT_FOLDER_TYPE_FIELDS)

Expand Down Expand Up @@ -7474,6 +7490,7 @@ def create_representation(
files: Optional[List[Dict[str, Any]]] = None,
attrib: Optional[Dict[str, Any]] = None,
data: Optional[Dict[str, Any]] = None,
traits: Optional[Dict[str, Any]] = None,
tags: Optional[List[str]]=None,
status: Optional[str] = None,
active: Optional[bool] = None,
Expand All @@ -7488,6 +7505,8 @@ def create_representation(
files (Optional[list[dict]]): Representation files information.
attrib (Optional[dict[str, Any]]): Representation attributes.
data (Optional[dict[str, Any]]): Representation data.
traits (Optional[dict[str, Any]]): Representation traits
serialized data as dict.
tags (Optional[Iterable[str]]): Representation tags.
status (Optional[str]): Representation status.
active (Optional[bool]): Representation active state.
Expand All @@ -7509,6 +7528,7 @@ def create_representation(
("files", files),
("attrib", attrib),
("data", data),
("traits", traits),
("tags", tags),
("status", status),
("active", active),
Expand All @@ -7532,6 +7552,7 @@ def update_representation(
files: Optional[List[Dict[str, Any]]] = None,
attrib: Optional[Dict[str, Any]] = None,
data: Optional[Dict[str, Any]] = None,
traits: Optional[Dict[str, Any]] = None,
tags: Optional[List[str]] = None,
status: Optional[str] = None,
active: Optional[bool] = None,
Expand All @@ -7552,6 +7573,7 @@ def update_representation(
information.
attrib (Optional[dict[str, Any]]): New attributes.
data (Optional[dict[str, Any]]): New data.
traits (Optional[dict[str, Any]]): New traits.
tags (Optional[Iterable[str]]): New tags.
status (Optional[str]): New status.
active (Optional[bool]): New active state.
Expand All @@ -7564,6 +7586,7 @@ def update_representation(
("files", files),
("attrib", attrib),
("data", data),
("traits", traits),
("tags", tags),
("status", status),
("active", active),
Expand Down