Extension / Script load and execution order system #13943
Closed
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.
please help and test if there's any flaws to the system
Description
Currently webui loads extensions based on its installation path
initially this is fine but as the amount of extension and the complexity grows this becomes increasingly troublesome
Here I implemented a system that allows a extension developer to specify
load order
eachentry_script.py
Script class initialization order
of eachscripts.Script
classfunction execution order
of almost every function in eachscripts.Script
classthis should solve the issue of an extension depending on another extensions being loaded first
and opens up the possibility of executing
callback functions
in special sequenceUsage explanation
scrip_file.py Load order
in the route to directory of an extension create a
webui-extension-properties.json
with the following structurescript_file_name.py
corresponds to each entry scriptscript_file.py
under thescripts
directory the requires a custom load orderFunction execution order and Script class initialization order
Function execution order
callback function
from allScripts
will be sorted based on theirorder
attributedetails
show.order
also acts as theScript class initialization order
ui.order
has ability to rearrange the order ofgr.Accordion
of aalways on script
title.order
serves as the order of how a script is stored order in webui but in most cases the store order shouldn't matter should be irrelevant, but it can be used to control the order of howselectable strips
are listedother orders like the callbacks of
alwayson_scripts
such asbefore_process.order
postprocess_batch
are normal and no special purpose other than defining thethese are all the current function that have `order attribute`
there are certain functions that I did not add the attribute
either because I believe they do not need it or I'm not sure the function of
the
run
function used by selectable Scripts does not need to be orderedI'm not familiar with
on_before_component
andon_after_component
and as it seem to serve different purpose I did not addorder
to itall orders can override be user in
config.json
currently the setting is only accessible by directly editing the config file file
and adding the dict key
script_order_override
restructure of the values is as follows
instructor is simple
identifying string
as keyorder number
as valuethe first two entries in this example are
Scriptfile.py Load order
entriesthe last two are entries for Script function
>
character is used as a separatorfor exact detail reference the
object_id
inscripts.get_function_execution_order
andscripts.get_script_load_order
currently there is no user interface to configure order override
this can be implemented at the later date if this system is accepted
defalt order when order is not specified
included bug fix
there's some strange behavior on of the original (current) script loading order
stable-diffusion-webui/modules/scripts.py
Lines 368 to 374 in 5e80d9e
base on comment message
64b7e83
to described behavior is
1st webui, 2nd extensions-builtin, 3rd extensions
but in reality this code produces
1st built-in-scripts + webui, 2nd extensions, 3rd extensions-builtin
in this PR it is corrected too the order described above in
defalt order when order is not specified
Checklist: