mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
| .. | ||
| ui | ||
| __init__.py | ||
| base.py | ||
| click_wrap.py | ||
| interfaces.py | ||
| README.md | ||
| utils.py | ||
AYON addons
AYON addons should contain separated logic of specific kind of implementation, such as ftrack connection and its usage code, Deadline farm rendering or may contain only special plugins. Addons work the same way currently, there is no difference between module and addon functionality.
Addons concept
- addons are dynamically imported based on current AYON bundle
Base class AYONAddon
- abstract class as base for each addon
- implementation should contain addon's api without GUI parts
- may implement
get_global_environmentsmethod which should return dictionary of environments that are globally applicable and value is the same for whole studio if launched at any workstation (except os specific paths) - abstract parts:
nameattribute - name of a addoninitializemethod - method for own initialization of a addon (should not override__init__)connect_with_addonsmethod - where addon may look for it's interfaces implementations or check for other addons__init__should not be overridden andinitializeshould not do time consuming part but only prepare base data about addon- also keep in mind that they may be initialized in headless mode
- connection with other addons is made with help of interfaces
climethod - add cli commands specific for the addon- command line arguments are handled using
click_wrappython module located inayon_core.addon climethod should expect single argument which is click group on which can be called any group specific methods (e.g.add_commandto add another click group as children seeExampleAddon)- it is possible to add trigger cli commands using
./ayon addon <addon name> <command> *args
- command line arguments are handled using
Interfaces
- interface is class that has defined abstract methods to implement and may contain pre implemented helper methods
- addon that inherit from an interface must implement those abstract methods otherwise won't be initialized
- it is easy to find which addon object inherited from which interfaces with 100% chance they have implemented required methods
- default interfaces are defined in
interfaces.py
IPluginPaths
- addon wants to add directory path/s to publish, load, create or inventory plugins
- addon must implement
get_plugin_pathswhich must return dictionary with possible keys"publish","load","create"or"actions" - each key may contain list or string with a path to directory with plugins
ITrayAddon
- addon has more logic when used in a tray
- it is possible that addon can be used only in the tray
- abstract methods
tray_init- initialization triggered afterinitializewhen used inTrayAddonsManagerand beforeconnect_with_addonstray_menu- add actions to tray widget's menu that represent the addontray_start- start of addon's login in tray- addon is initialized and connected with other addons
tray_exit- addon's cleanup like stop and join threads etc.- order of calling is based on implementation this order is how it works with
TrayAddonsManager - it is recommended to import and use GUI implementation only in these methods
- has attribute
tray_initialized(bool) which is set to False by default and is set byTrayAddonsManagerto True aftertray_init - if addon has logic only in tray or for both then should be checking for
tray_initializedattribute to decide how should handle situations
ITrayService
- inherits from
ITrayAddonand implementstray_menumethod for you - adds action to submenu "Services" in tray widget menu with icon and label
- abstract attribute
label - label shown in menu
- interface has pre implemented methods to change icon color
set_service_running- green iconset_service_failed- red iconset_service_idle- orange icon- these states must be set by addon itself
set_service_runningis default state on initialization
ITrayAction
- inherits from
ITrayAddonand implementstray_menumethod for you - adds action to tray widget menu with label
- abstract attribute
label - label shown in menu
- abstract method
on_action_trigger - what should happen when an action is triggered
- NOTE: It is a good idea to implement logic in
on_action_triggerto the api method and trigger that method on callbacks. This gives ability to trigger that method outside tray
AddonsManager
- collects addon classes and tries to initialize them
- important attributes
addons- list of available attributesaddons_by_id- dictionary of addons mapped by their idsaddons_by_name- dictionary of addons mapped by their names- all these attributes contain all found addons even if are not enabled
- helper methods
collect_global_environmentsto collect all global environments from enabled addons with callingget_global_environmentson each of themcollect_plugin_pathscollects plugin paths from all enabled addons- output is always dictionary with all keys and values as an list
{
"publish": [],
"create": [],
"load": [],
"actions": [],
"inventory": []
}