Conversation
…with-Publisher-attributes
…er-instance # Conflicts: # client/ayon_core/pipeline/create/structures.py
|
Now it should be able to handle edge cases, maybe not "the nicest and clearest way", but it is possible. I would not bother until we hit issues related to that. I had to add some implementations to attribute definitions to make it possible. |
|
Issue reported by @BigRoy . Publish buttons are disabled after reset, seems like it is related to instance context validation. |
…with-Publisher-attributes
|
Discovered few more issues. Labels of instances were not updating and change of active state on instances was not propagated. Should be resolved now. |
…with-Publisher-attributes
There was a problem hiding this comment.
All looks good now - seems to work.
Except I'm not seeing any Context attributes anymore.
Going to the Context entry I get this error:
# Traceback (most recent call last):
# File "F:\dev\ayon-core\client\ayon_core\tools\publisher\widgets\overview_widget.py", line 303, in _on_product_change
# self._product_attributes_widget.set_current_instances(
# File "F:\dev\ayon-core\client\ayon_core\tools\publisher\widgets\product_info.py", line 167, in set_current_instances
# self._refresh_instances()
# File "F:\dev\ayon-core\client\ayon_core\tools\publisher\widgets\product_info.py", line 191, in _refresh_instances
# self.publish_attrs_widget.set_current_instances(
# File "F:\dev\ayon-core\client\ayon_core\tools\publisher\widgets\product_attributes.py", line 246, in set_current_instances
# self._refresh_content()
# File "F:\dev\ayon-core\client\ayon_core\tools\publisher\widgets\product_attributes.py", line 261, in _refresh_content
# result = self._controller.get_publish_attribute_definitions(
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# File "F:\dev\ayon-core\client\ayon_core\tools\publisher\control.py", line 424, in get_publish_attribute_definitions
# return self._create_model.get_publish_attribute_definitions(
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# File "F:\dev\ayon-core\client\ayon_core\tools\publisher\models\create.py", line 861, in get_publish_attribute_definitions
# attr_defs = attr_val.attr_defs
# ^^^^^^^^^^^^^^^^^^
# AttributeError: 'dict' object has no attribute 'attr_defs'In both Maya 2025.3 and Fusion 18.
Other than that all the labels updating and instance variant name changing seem to update just fine - and of course the live toggling of attributes works fine for instances, etc.
|
Should be fixed. |
BigRoy
left a comment
There was a problem hiding this comment.
Lovely work - PR works for me. ❤️
antirotor
left a comment
There was a problem hiding this comment.
Works, tested in a bunch of hosts like 3dequalizer and 3dsmax.

Changelog Description
Create context now allows to define attribute definitions per instance and allows to register callbacks listening to changes (e.g. on instances).
Additional info
Create plugin can define different attribute definitions on each instance, for example only different default values using
get_attr_defs_for_instance. Publish plugins can define attribute definitions for any instance, and both instance and context plugins can define attribute definitions for both instances and context, so context plugin can define attribute definitions for instances. That can be achieved by implementingget_attr_defs_for_instanceabdget_attribute_defs_for_context. Everything should be backwards compatible and work as before this PR.Added callbacks allow to do adhoc live changes. That allows to create/publish plugin to change attribute definitions when a value changes. There is almost no limit to this usage. For example when a folder and task of instance A changes it is possible to propagate the same change to instances B, C, D. When create attribute changes value, publish attribute can be hidden or shown again. Registered callbacks are reset on each reset of CreateContext.
To register callbacks use
listen_to_added_instances,listen_to_removed_instances,listen_to_value_changes,listen_to_pre_create_attr_defs_change,listen_to_create_attr_defs_change,listen_to_publish_attr_defs_changeonCreateContext. To change create attributes useset_create_attr_defs, to update publish attributes useset_publish_plugin_attr_defsonCreatedInstanceand to update context publish attributes useset_context_publish_plugin_attr_defsonCreateContext.Callbacks are not targeted to the plugin, so plugin has to filter out what is relevant for him, if anything is relevant.
NOTE it is possible, but has caviads, the plugins must care that everything is set up correctly when they decide they do it. For example when enum will rename one value it should make sure the value kept selected on instances that did have it selected.
Also note that callbacks should not be used to live propagation to scene. The changes can be reverted if
save_changesis not called onCreateContext.Dev note
I did a lot of changes on the fly and maybe forgot some lines that might not be necessary or are undocumented, if you find those please comment in the code. I will try to cleanup it and fill in docstrings, but it won't hurt me if you mark something as "unclear", "confusing", "unnecessary". Any suggestions welcommed.
Traypublisher
Traypublisher is making issues at this moment as it changes window behavior and is using controller methods that should be removed but can't. We should remove option to change project in traypublisher and instead allow to change project only on start.
Testing notes
All changes are important mainly for publisher UI, so please choose DCC/host of your preference and use publisher.
All existing plugins should work as before.
None of new features are use in code so it requires to implement them to test hem out. If you'll find a plugin in ayon core that would benefit from these changes, we can change it in this PR as example.
This opens a lot of possibilities, so I need creative approaches and real life use-cases to be applied with this PR more than fake testing.
My testing steps using fake plugins
All tests were done in traypublisher.
Per instance attribute definitions
Callbacks
register_callbackson create plugin and classmethodregister_create_context_callbackson publish plugin.listen_to_added_instances,listen_to_removed_instances,listen_to_value_changes,listen_to_pre_create_attr_defs_change,listen_to_create_attr_defs_change,listen_to_publish_attr_defs_change.set_create_attr_defs, to update publish attributes useset_publish_plugin_attr_defsonCreatedInstance. To change values of instance just use instance as dictionary.Resolves #133
Resoves ynput/ayon-deadline#55