A template for debugging long running, containerized ML applications in python with vscode.
import debugpy
debugpy.listen(("0.0.0.0", 5678))
print("Waiting for client to attach...")
debugpy.wait_for_client()
See medium post for a full explanation: Debugging for Dockerized ML applications in Python
- Set some breakpoints in
main.py
with either:- The vscode UI
- Use the
debugpy.breakpoint()
function
- Run
bash ./run_container.sh
to build the docker image and run the container - Once the container is running, select the
Python: Docker Attach
debugging configuration - Debug away 😍