Implements Script order / Callback order#14220
Implements Script order / Callback order#14220aria1th wants to merge 5 commits intoAUTOMATIC1111:devfrom
Conversation
|
some differences between my implementation #13943
one thing that I don't have implemented is the I've only implemented if requested I can rework my origin implementation |
|
@w-e-w I don't really expect users to modify the callback execution order - most of the case, they would not know anything about how extensions were written and working... rather, extensions creator should handle if the race condition happens. Also it would be beneficial to have closures / functions that returns dynamic values at runtime, which can be effective for conditional ordering. We won't really benefit unless someone has 100k extensions that might take seconds to sort 🧠, so I'd suggest dynamic sorting for that, unless it includes some I/O operation. For As far as I experienced, usually just a simple ordering / or conditional ordering is enough, maybe we already have DAG so expanding it as metadata....can be some option too. So I would consider 2 options, as metadata (maybe readable and unified), or as code snippet style (arguments or closures, closures can be very dynamic but I think just 'Before' 'After' handling should be enough, and escaping scope to get all scripts name will be pain.....) |
|
user overridable is kind of important, even though the average user will not be able to utilize the system it is still beneficial to have the TLDR it's that can be very beneficial for special circumstances and advanced users, read below if you want examples also just want to make it clear that, I don't really have an objection of sorting the order at runtime, I'm just explaining the difference between our implementations and why I did it that way I don't really have a preference between Examples let's say there are two independent extensions that will function perfectly well without setting a specific order, because of which the extension developer did not set a custom order later down the line a 3rd extension was made by some other developer, due to special reasons this extension needs to be executed in between the two extensions because of those extension doesn't have a custom order they are both assign the same default order if this only happens for one function then it's still salvageable, because the developer can just set a custom extension load order using the DAG system, but if there are multiple functions or if this type of complex happens for multiple extensions there are certain combinations that are not possible to achieve simply by the load order
and they're also cases that certain extension combination would have execution issues, let the developer simply does not know about (if the developer is made aware of the situation then this could be fixed potentially) if issues like these occur obviously the best solution would be for the extensions to just update but sometimes this might require multiple extensions to be updated due to the same issue which is not exactly fast and easy to do so it's more practical to allow the user to manually the order, and if the future fix is built into the extension they can always remove the override they're also cases that the execution order is determined not by functionality but of user use case / preference thats say
one user might want to use in this situation there is no one right way of configuring the execution orde, it depends on the user's use case if you have two post processing operation and the output would be affected by the order that they are applied, and assume that both results are valid effects, in this case the developers cannot know beforehand what's the user wants and so cannot set a correct order because there is no correct order in other cases such as the before / after component function if two extensions both want to inject their own UI at the same position the user should have the choice to choose the order that the injected elements are placed |
|
@w-e-w That makes sense, I was just trying to handle functionality setups - to just allow devs to plan and calculate their order, but those type of processing has to be considered too. But still, I guess those customization has too many options to implement - for example, we can let extensions implement their API endpoints, and let someone combine them as processors... My implementation was just for minimal stuff to specifying execution orders - just to avoid hijack hellness... so we might want separate discussion about this, maybe comfyUI-style node conversion / etc... |
|
#15205 implements callback order via extension configuration files so I'm closing this. |
Description
Related:#13943
on_*(callback, priority_getter_or_int)
Now, on_* type callback register supports one additional (optional) parameter, priority.
on_ui_settings(setup_ui, 10)-> Registers callback with priority 10 (bigger executes first)on_ui_settings(setup_ui, lambda x:10)-> Registers callback with closureBehavior:
at callback call time, we call the priority getter (which will handle callable or int) to get priorities, and sort by them.
As a result, we can control the order of callback execution.
Note that the callable currently does not pass any arguments.
Script callbacks
This is the modified script example, which would make hypertile process be always processed after priority 0 executions.

Screenshots/videos:
Checklist: