In order to debug the server using PyCharm you need to do two things:
Restart Docker with the debug mixin
Restart Docker in the normal-mode to exit the debug-mode:
Create new remote Python interpreter
Within PyCharm go to Settings -> Project Interpreter -> Cogs symbol -> Add Remote...
At the time of this writing there are five options, we will explain two of it: Docker Compose and SSH Credentials.
Using Docker compose
Select Docker Compose and check the following values:
- Create a new Docker Server using Unix socket.
- Choose the
docker-compose.ymlat the root of your Phovea workspace
- Set the service to the docker container you would like to debug.
- Make sure the python interpreter is set to
Using SSH Credentials
Select SSH-Credentials and use the following values:
- User name:
- Python interpreter path:
/usr/local/bin/pythonNOTE: this is different from the default!
PyCharm should now be able to connect to the docker container and upload some helper files. Regardless of which option you chose:
- Create default path mappings
- Select project directory and specify it is located at
- In the end the overview page should state:
<Project root> -> /phovea
- Gevent compatible Python debugging
- Go to Build, Execution, Deployment -> Python Debugger
- Apply changes -> Close settings dialog
Create a phovea_server debug launch configuration
- Run -> Edit Configurations
- In the dialog Plus sign (top-left) -> Python
- Script parameters:
- Python interpreter: Remote Python (created above)
- Working directory:
Add content roots to PYTHONPATHand
Add source roots to PYTHONPATH
- Apply and close the dialog
Run the server using PyCharm
- Start Docker using the debug mixin
- Set a breakpoint next to the line number in a Python file
- Run -> Debug -> phovea_server
- Open the URL in the browser that triggers the breakpoint
- Debug the Python in the PyCharm panel