-
Notifications
You must be signed in to change notification settings - Fork 940
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
(Forge and/or Gradio) Error Afflicting Many Extensions #1605
Comments
I appreciate the discussion you had here, helped to fix some other extensions. For this issue, have you tried debug stepping through the repair loop in gradio_extensions? Or looked at the |
The above is probably not good advice; the root cause seems to be that subclassed gradio components from extensions that are not modules, and thus they aren't in sys's module dict. They will then fail in gradio.components.base.get_component_class_id:
Is it possible that the extension loading is different in Forge compared to other webui's? |
I want to add a quick thing I meant to preface my OP with: When I see people on Reddit / discord saying the reasons they do not use Forge, the main reason is "My extensions don't work". Here is one major bug that will not be easily resolved by all extension developers, if I am correct that this is indeed on Forge. I've suffered traumatically in attempting / assisting with debugging this particular issue, and it's brought me some relief to just spill out everything that I learned in the process, in hopes someone who really knows what they are doing can solve this. I'm really not willing to dive back in, test prints, etc. I had put debug prints all over the place, tested over and over again for hours... in my script, in the modules, etc.
|
Thanks for transferring some of your trauma on to me 😅 You were correct that something was wrong, though it is also a problem in auto1111, they just won't start encountering it until they update to Gradio 4 (or some other code explicitly checks sys.modules). See PR above and let me know if it fixes the issue you were seeing. |
You're very good! I applied your PR, then used git checkout to roll back my extension. Your PR resolved the
But your PR is already a huge step in the right direction, as the extension loaded up without error! Comparing the gradio code, |
The bug affects any extension that subclasses a UI component. My extension was updated to simply not subclass the ToolButtons. I used git checkout to roll back to a version before I made that change, and the PR did fix the error. Lev145 really solved the problem for us here and it’s actually a complicated solution for our application. Instead of making custom button classes, it tuples functions with each button instance EDIT Okay I see you were actually looking at their repo. They fixed it as I described EDIT2 this is the commit before I resolved the issue you can also check out Segment Anything main branch, they also have the bug - I sent them a PR that replaces the subclassed button with a direct instance |
Gradio 4 directly caused many extensions to have issues, due to code changes, deprecations, etc.
Not this error. This error is from Forge, and it affects many extensions.
The error, which I'll refer to later as "Inherited Component bug":
Traceback Sample
What I believe Forge needs to Fix this Forge error:
Reproduction:
Inherit from
ToolButton()
(or, presumably, any component imported frommodules.ui_components
).How extension developers can resolve the issue:
Note: developers are typically subclassing UI components so they can define class methods.
Therefore, this solution can be extremely painful/confusing depending on the application.
Solution: Do not subclass any UI components.
What's happening:
Refer to the Traceback Sample in the accordion above.
Strange Initialization for subclassed components:
Important: At this step, all WebUIs (A1111, Forge, Reforge, etc) experience "Inherited Component bug"
.__module__
attribute value: "extension-script-name
".__module__
attribute value: "modules.ui_components
"WebUI Repairs Strange Initialization:
At this step, all other WebUIs except Forge successfully repair the Strange Initialization that occurs.
.__module__
attribute value: "extension-script-name
" will be updated to "modules.ui_components
"Hack that fixes the error, but not "Among other things":
"Among other things" (not resolved by this) includes the following:
disabled
for no apparent reason.js
code defined by the scriptThis will make the script load in Forge:
CustomToolButton.__module__ = "modules.ui_components"
Example:
What is the specific problem?!?!?!
It has something to do with the patching steps when it tries "
__repaired_init__
"This in particular looks very suspicious to me:
IOComponent
andComponent
IOComponent_init()
is identical between Forge and A1111The text was updated successfully, but these errors were encountered: