Skip to content

Callback order#15205

Merged
AUTOMATIC1111 merged 5 commits intodevfrom
callback_order
Mar 16, 2024
Merged

Callback order#15205
AUTOMATIC1111 merged 5 commits intodevfrom
callback_order

Conversation

@AUTOMATIC1111
Copy link
Owner

@AUTOMATIC1111 AUTOMATIC1111 commented Mar 10, 2024

Description

Adds a way to reorder callbacks.

  • For users, a section in settings UI is added where user can pick which callback to run first, in a multi-select dropdown.
  • For developers, support for specifying order of callbacks in metadata.ini via After= and Before=.

Example metadata.ini:

[callbacks/swinir/swinir_model.py/ui_settings]
Before = ldsr/ldsr_model.py/ui_settings
After = hypertile/hypertile_script.py/ui_settings

Here, swinir/swinir_model.py/ui_settings, ldsr/ldsr_model.py/ui_settings and hypertile/hypertile_script.py/ui_settings are three callbacks. They will be reordered like this:

  1. hypertile/hypertile_script.py/ui_settings
  2. swinir/swinir_model.py/ui_settings
  3. ldsr/ldsr_model.py/ui_settings

Each callback is identified by its extension's canonical name, its filename, its category (here, it's ui_settings for all of them), and, optionally, by a user-specified name

  • calling script_callbacks.on_ui_settings(on_ui_settings, name='mysettings') creates callback swinir/swinir_model.py/ui_settings/mysettings
  • calling script_callbacks.on_ui_settings(on_ui_settings) creates callback swinir/swinir_model.py/ui_settings
  • calling script_callbacks.on_ui_settings(on_ui_settings) again creates callback swinir/swinir_model.py/ui_settings-1, then swinir/swinir_model.py/ui_settings-2, etc.

You can see identifiers for existing callbacks in settings (see screenshot below).

Screenshots/videos:

firefox_pGHeQtPQON

Checklist:

@AUTOMATIC1111
Copy link
Owner Author

Adding this as PR for comments/suggestions.

@AUTOMATIC1111 AUTOMATIC1111 merged commit 5bd2724 into dev Mar 16, 2024
@AUTOMATIC1111 AUTOMATIC1111 deleted the callback_order branch March 16, 2024 06:45
@w-e-w w-e-w mentioned this pull request Apr 6, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant