Tools: Objects data conversions - #1988
Merged
Merged
Conversation
# Conflicts: # client/ayon_core/tools/publisher/abstract.py # client/ayon_core/tools/publisher/models/create.py # client/ayon_core/tools/publisher/models/publish.py
# Conflicts: # client/ayon_core/tools/loader/abstract.py # client/ayon_core/tools/workfiles/abstract.py
BigRoy
approved these changes
Aug 10, 2026
BigRoy
left a comment
Member
There was a problem hiding this comment.
Works for me in Fusion, Blender and Maya. And changes LGTM.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR standardizes UI-facing model objects around explicit to_data / from_data conversions to support future IPC-based tool execution, and removes unused legacy items from the workfiles abstraction.
Changes:
- Added/expanded
to_dataandfrom_dataserialization for multiple tool model objects (workfiles, publisher, loader, common models). - Converted several lightweight “item” classes to
@dataclassfor clearer structure and easier (de)serialization. - Cleaned up workfiles abstractions by removing unused
FolderItem/TaskItemdefinitions.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| client/ayon_core/tools/workfiles/abstract.py | Removes unused legacy items and adds to_data/from_data for workarea/published workfile wrappers. |
| client/ayon_core/tools/publisher/models/create.py | Adds to_data/from_data for instance-related UI model items and updates typing. |
| client/ayon_core/tools/publisher/abstract.py | Adds attribute-def serialization helpers and to_data/from_data for publish attribute structures. |
| client/ayon_core/tools/loader/abstract.py | Converts loader UI structures to dataclasses and adds/updates serialization helpers. |
| client/ayon_core/tools/common_models/users.py | Introduces UserItem dataclass and adds to_data/from_data. |
| client/ayon_core/tools/common_models/projects.py | Adds/updates serialization for project/common items and icon mapping structures. |
| client/ayon_core/tools/common_models/init.py | Exposes UserItem from the common_models package. |
| client/ayon_core/pipeline/create/structures.py | Adds to_data/from_data for InstanceContextInfo to support transport/IPC. |
Suppressed comments (2)
client/ayon_core/tools/loader/abstract.py:335
- ActionItem.to_data currently returns the icon object directly. Call sites pass AwesomeFontIcon/MaterialSymbolsIcon instances, which are not JSON-serializable for IPC; similarly from_data does not rebuild IconBase from the serialized dict.
identifier=self.identifier,
label=self.label,
group_label=self.group_label,
icon=self.icon,
tooltip=self.tooltip,
client/ayon_core/tools/loader/abstract.py:120
- ProductItem.to_data returns product_icon as-is. icons_mapping.get_icon now yields IconBase instances, so this will embed a non-serializable object into the data payload; from_data also doesn't rebuild the icon definition.
product_type=self.product_type,
product_base_type=self.product_base_type,
product_name=self.product_name,
product_icon=self.product_icon,
product_in_scene=self.product_in_scene,
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+37
to
+41
| name: str | ||
| icon: dict[str, Any] | ||
|
|
||
| def to_data(self): | ||
| return { | ||
| "name": self.name, | ||
| "icon": self.icon, | ||
| } | ||
| return dict(name=self.name, icon=self.icon) |
|
|
||
| @dataclass | ||
| class ProductItem: | ||
| """Product item with it versions. |
Comment on lines
244
to
+248
| if isinstance(icon, dict): | ||
| return icon.copy() | ||
| return icon | ||
|
|
||
| def _get_default_def(self) -> dict[str, str]: | ||
| def _get_default_def(self) -> MaterialSymbolsIcon: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog Description
Add
to_dataandfrom_dataconversions for objects used in UIs.Additional info
Some of the methods were already there but had bugs in it. Some of the existing classes were converted to dataclasses. There will be more similar PRs that might change them more.
Removed forgotten
FolderItemandTaskItemin workfiles abstract definition that were not used.This is a preparation for future implementation of IPC communication #1987 .
Testing notes:
The PR might be clashing with changes in #1949 . This PR should be merged after that PR.