https://dagster.io/ logo
Title
m

Matthias Queitsch

03/08/2022, 1:45 PM
Just out of curiosity: Was anyone able to attach to a debugger (e.g. debugpy) to a docker container running dagster? I don't know where to run debugpy - on dagit or on the pipeline docker container?
❤️ 2
a

Alex Service

03/08/2022, 2:40 PM
Yeah! There are a couple steps that have to be taken: • expose port 5678 from the container • call
debugpy.listen(('0.0.0.0', 5678))
in the appropriate op/function. Note that we’re using a tuple to specify the interface • call
debugpy.wait_for_client()
so you’re not rushing around • finally, call
debugpy.breakpoint()
wherever you’d like in the function Oh, and you’ll need to create a
launch.json
for python remote attach. In VSCode, click “Run and Debug” -> “Create a launch.json file” and follow the prompts ( python -> remote attach -> localhost -> 5678 )
❤️ 1
It depends on what you want to debug, but generally speaking, I put all of the stuff above directly in whatever op I’m trying to debug
s

Sebastian Napiorkowski

03/08/2022, 2:49 PM
Is it possible to add the pycharm debugger?
a

Alex Service

03/08/2022, 2:51 PM
I don’t know, but probably 🙂
It looks like you need a professional license and the instructions would be different from what I put above: https://www.jetbrains.com/help/pycharm/remote-debugging-with-product.html
m

Matthias Queitsch

03/08/2022, 3:11 PM
Ok thanks. I will give this a try. I was thinking that I could have a generic dockerfile/docker-compose config generally allows to attach a debugger. With you method I have to be careful to remove the debug code before using it in production.
a

Alex Service

03/08/2022, 3:14 PM
Ah that requirement wasn’t in your original spec 😉 Yeah I’m not sure how to do it without explicitly adding what I specified above
I dug into it a little bit and in theory, debugpy should be able to attach to a process by specifying its PID; trying to do this in a
python:3.9.8-buster
container wasn’t really working for me though due to some
ptrace
error
if that worked, then I would hope that VSCode could trigger on breakpoints, but sadly I didn’t make it that far and have other things I need to do