-
Notifications
You must be signed in to change notification settings - Fork 52
Pre and post loader hooks #1222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pre and post loader hooks #1222
Conversation
Added functions to register/deregister them.
Task linked: OP-6870 Plugin hooks - Loader and Scene Inventory |
I wonder if new hook plug-ins here make more sense than just an |
Had the same question, but they should be blocking, I dont think you can achieve that with events. |
It is assumed that utils could be used in some kind 'load API', `actions` are tightly bound to UI loading.
The Event system in AYON is blocking by default, right @iLLiCiTiT ? |
We still support older Maya
Plugin is required so it makes sense to bump it up to first position and pass it before args
Reordered arguments in |
Co-authored-by: Jakub Trllo <[email protected]>
Co-authored-by: Jakub Trllo <[email protected]>
): | ||
pass | ||
|
||
@abstractmethod |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more question, is there a reason that it is required to implement all the methods? I would just remove the abstractmethod
except is_compatible
which is really required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel it forces developer to actually think about (mostly) update process, which might be a bit hidden.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if I want to implement only pre
methods then I also have to implement all post
methods too, just keep them empty.
It is mergable, from my point of view the abstract methods are unnecessary, but I won't be the one who will use it. |
Changelog Description
This PR introduces new concept of
Pre/Post Loader Hooks
which could be used by to enhance or modify loading processes without need of modifying official loaders.The idea is for custom addons to be able to implement their own
PrePostLoaderHookPlugin
which would be triggered before/after Loader action.Method to be implemented in
PrePostLoaderHookPlugin
:pre_load
post_load
pre_update
post_update
pre_remove
post_remove
The function signature (arguments) to each of the pre/post methods matches the regular
LoadPlugin
except thatpost_*
methods take an additionalresult
argument which receives the output of theLoadPlugin
method call, like simplified:Additional info
Each addon must register its folder with pre/post hooks like this:
I am testing it with this dummy custom addon which shows hooks for
"CopyFile", "FileLoader", "LoadImage"
Loaders.my_custom_addon-1.0.0.zip(outdated example files)Register example hook to just print all the hook methods
Or when targeting specific loaders and e.g. writing to a file on disk on each hook call:
Testing notes:
copy_file_hook.py
inmy_custom_addon
however you feel fit for your testing