You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
Is it possible to debug remote python code, such as in a kubernetes cluster?
When i'm trying to debug a local docker container im getting: "Breakpoint in file that does not exist" while setting a breakpoint.
I have never tried but if I understand correctly @scweber-cisco did that with docker.
@omri-shilton as lsp4ij dap support is a new feature, I suggest that you try to debug python files with vscode. Once it is working´ try to configure lsp4ij dap support with the same configuration.
@omri-shilton without knowing specifics of your configuration, I would guess it is probably that you need to set pathMappings in your DAP parameters (JSON) field.
Depending on your configuration, you may only need one pathMappings entry, or your may need a lot. The localRoot points to a source code folder on your local development machine (where you are running PyCharm); and the remoteReoot points to the folder where the same source code lives on the remote machine where you are wanting to debug.
Again, depending on your configuration, you may need to also set justMyCode to false.
@scweber-cisco Im having a similar issue with the current python-debugpy addition. In my case, I want to run debugpy while running a uvicorn server within a k8s pod, and be able to set breakpoints within an endpoint. I have configured it the way you suggested with pathMappings, however upon running it, it does not acknowledge the breakpoint. I saw in your specification that the breakpoint event isnt supported yet, however from the example documentation it seems like it should be? I was wondering if you have a working example we could reference.
@scweber-cisco Im having a similar issue with the current python-debugpy addition. In my case, I want to run debugpy while running a uvicorn server within a k8s pod, and be able to set breakpoints within an endpoint. I have configured it the way you suggested with pathMappings, however upon running it, it does not acknowledge the breakpoint. I saw in your specification that the breakpoint event isnt supported yet, however from the example documentation it seems like it should be? I was wondering if you have a working example we could reference.
I suggest that you try with vscode to find the proper config and after that use this config with lsp4ij.
If it doesnt work it means that there is a bug with dap support.
setting breakpoint using debugpy.breakpoint() in the code works with the correct pathMapping however, setting breakpoint using IDE doesn't seem to work
@dorkwingduck I have a working configuration, but it is highly specific to the non-public details of my repository, application, and deployment. Sharing it would not yield benefit to anyone outside of those who work in my repo. Sorry. I do think that @angelozerr 's suggestion is probably your best next step.
@AliakbarSu This definitely works. I was able to interact with a remote debugger running in k8s today via a debugger port forward. My setup is very similar to yours, and I'm even using an event loop for my service.
Are you running your Debug Adapter Protocol configuration in debug mode? It's possible to connect to the server in "run" mode which confusingly DOES redirect output but doesn't activate breakpoints. However, I didn't see any errors when I did this, so I don't think I ever had path issues.
Attached is a screenshot of the working configuration.
I am able to use breakpoints without the DAP specific configuration.
Activity
angelozerr commentedon Feb 25, 2025
I have never tried but if I understand correctly @scweber-cisco did that with docker.
@omri-shilton as lsp4ij dap support is a new feature, I suggest that you try to debug python files with vscode. Once it is working´ try to configure lsp4ij dap support with the same configuration.
In otherwise I suggest that you read https://code.visualstudio.com/docs/python/debugging
omri-shilton commentedon Feb 25, 2025
@scweber-cisco can you elaborate a bit on how you got it to work?
scweber-cisco commentedon Feb 25, 2025
@omri-shilton without knowing specifics of your configuration, I would guess it is probably that you need to set
pathMappingsin your DAP parameters (JSON) field.I found some very light documentation here: https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings
Depending on your configuration, you may only need one
pathMappingsentry, or your may need a lot. ThelocalRootpoints to a source code folder on your local development machine (where you are running PyCharm); and theremoteReootpoints to the folder where the same source code lives on the remote machine where you are wanting to debug.Again, depending on your configuration, you may need to also set
justMyCodetofalse.dorkwingduck commentedon Mar 6, 2025
@scweber-cisco Im having a similar issue with the current python-debugpy addition. In my case, I want to run debugpy while running a uvicorn server within a k8s pod, and be able to set breakpoints within an endpoint. I have configured it the way you suggested with pathMappings, however upon running it, it does not acknowledge the breakpoint. I saw in your specification that the breakpoint event isnt supported yet, however from the example documentation it seems like it should be? I was wondering if you have a working example we could reference.
angelozerr commentedon Mar 6, 2025
I suggest that you try with vscode to find the proper config and after that use this config with lsp4ij.
If it doesnt work it means that there is a bug with dap support.
AliakbarSu commentedon Mar 6, 2025
setting breakpoint using
debugpy.breakpoint()in the code works with the correctpathMappinghowever, setting breakpoint using IDE doesn't seem to workscweber-cisco commentedon Mar 6, 2025
@dorkwingduck I have a working configuration, but it is highly specific to the non-public details of my repository, application, and deployment. Sharing it would not yield benefit to anyone outside of those who work in my repo. Sorry. I do think that @angelozerr 's suggestion is probably your best next step.
pnovotnak commentedon Mar 7, 2025
@AliakbarSu This definitely works. I was able to interact with a remote debugger running in k8s today via a debugger port forward. My setup is very similar to yours, and I'm even using an event loop for my service.
Are you running your Debug Adapter Protocol configuration in debug mode? It's possible to connect to the server in "run" mode which confusingly DOES redirect output but doesn't activate breakpoints. However, I didn't see any errors when I did this, so I don't think I ever had path issues.
Attached is a screenshot of the working configuration.
I am able to use breakpoints without the DAP specific configuration.
AliakbarSu commentedon Mar 7, 2025
@pnovotnak thanks! can confirm this is working in debugMode and this is my config:
angelozerr commentedon Mar 8, 2025
@omri-shilton can we close this issue? I think it is more a configuration problem.
omri-shilton commentedon Mar 9, 2025
i think so, thanks