AUTOMATIC1111 / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
135.33k stars 25.84k forks source link

[Feature Request]: Remote attach debugger to a1111 #16084

Open kurophali opened 1 week ago

kurophali commented 1 week ago

Is there an existing issue for this?

What would your feature do ?

I want to develop some network injections for sd and I want to use breakpoint to check whether things are running smoothly. Can the script start some debug servers I can attach to and use breakpoints?

Proposed workflow

1.enable server by command line args 2.remote attach with vscode or something. 3.trigger function and breakpoint is triggered

Additional information

No response

w-e-w commented 1 week ago

google "remote debug a python script in vscode" I think this is what you're looking for https://code.visualstudio.com/docs/python/debugging https://github.com/microsoft/debugpy and a guide https://stackoverflow.com/questions/73378057/how-to-debug-remote-python-script-in-vs-code

it should be possible for you to configure your vs code to connect to SSH server that can launch webui in debug mode and have your vsocde conect to the debug server

note I have never tried doing this myself


these days in most IDEs basically automatically setup the debugging environment as an option for convenience, but essentially what's going on under the hood is that a python script is launch with debug modules enable, the IDE then connects to the debug server with allows you to setup breakpoints in the code editor

I dont use VS code for python much so not to familiar, but I know it's possible setup remote debugging in pycharm, so I would expect it should also be possible in VS code

as far as I'm aware debugging is generally something that you (the developer) should configured and enabled by launching the python script with a debugging module enabled, and it is not something that a project should provide as a future

debugging is not something that you should enable if you're not actively doing debugging as sometimes debugging itself can lead to issues and performance lost

kurophali commented 1 week ago

google "remote debug a python script in vscode" I think this is what you're looking for https://code.visualstudio.com/docs/python/debugging https://github.com/microsoft/debugpy and a guide https://stackoverflow.com/questions/73378057/how-to-debug-remote-python-script-in-vs-code

it should be possible for you to configure your vs code to connect to SSH server that can launch webui in debug mode and have your vsocde conect to the debug server

note I have never tried doing this myself

these days in most IDEs basically automatically setup the debugging environment as an option for convenience, but essentially what's going on under the hood is that a python script is launch with debug modules enable, the IDE then connects to the debug server with allows you to setup breakpoints in the code editor

I dont use VS code for python much so not to familiar, but I know it's possible setup remote debugging in pycharm, so I would expect it should also be possible in VS code

as far as I'm aware debugging is generally something that you (the developer) should configured and enabled by launching the python script with a debugging module enabled, and it is not something that a project should provide as a future

debugging is not something that you should enable if you're not actively doing debugging as sometimes debugging itself can lead to issues and performance lost

I didn't know a1111 has any debug servers enabled by default. I'll try installing some debugging modules and run it on launch.py

w-e-w commented 1 week ago

I didn't know a1111 has any debug servers enabled by default.

NO webui dose not and should not have debug servers

but Python itself does have modules that are used for debugging https://docs.python.org/3/library/pdb.html and there are packages that enables more convenient debugging that are commonly integrated with the IDE (like pydevd and debugpy) with these stuff you should be able to run ANY a debugger (debuger server) you can then connect to the debugger serve with an IDE that allows you to easily interact with the debugger like adding breakpoints

this is in most cases these days done "Automatically" when you set up a python development environment like using vs code or pycharm

so for ANY python script (not just webui) in most cases you should just configured your ID correctly to Launch the python script with debugger enabled

unless you're doing some advanced stuff which the default configuration does not support you should don't need to do an understand much

note I never tried to fully understand how debugger actually works so take my information with a grain of salt

most of us just launch with debug option that is pre-configured with an IDE, we don't try to understand how debugger actually functions