PyCharm Debugging

In order to debug the server using PyCharm you need to do two things:

  1. Prepare environment
  2. Create new remote Python interpreter

Prepare environment

Restart Docker with the debug mixin

./docker-compose-debug up

Restart Docker in the normal-mode to exit the debug-mode:

docker-compose up

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:

  1. Create a new Docker Server using Unix socket.
  2. Choose the docker-compose.yml at the root of your Phovea workspace
  3. Set the service to the docker container you would like to debug.
  4. Make sure the python interpreter is set to python.

Using SSH Credentials
Select SSH-Credentials and use the following values:

  • Host: localhost
  • Port: 2222
  • User name: root
  • Password: docker
  • Python interpreter path: /usr/local/bin/python NOTE: 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:

  1. Create default path mappings
  2. Select project directory and specify it is located at /phovea
  3. In the end the overview page should state: <Project root> -> /phovea
  4. Gevent compatible Python debugging
  5. Go to Build, Execution, Deployment -> Python Debugger
  6. Check Gevent compatible
  7. Uncheck PyQt compatible
  8. Apply changes -> Close settings dialog

Pycharm Python Remote Interpreter

Pycharm Python Debugger

Create a phovea_server debug launch configuration

  1. Run -> Edit Configurations
  2. In the dialog Plus sign (top-left) -> Python
  • Name: phovea_server
  • Script: \phovea\phovea_server\__main__.py
  • Script parameters: --env=dev api
  • Python interpreter: Remote Python (created above)
  • Working directory: \phovea
  • Uncheck Add content roots to PYTHONPATH and Add source roots to PYTHONPATH
  1. Apply and close the dialog

Pycharm Debug Launch Config

Run the server using PyCharm

  1. Start Docker using the debug mixin
  2. Set a breakpoint next to the line number in a Python file
  3. Run -> Debug -> phovea_server
  4. Open the URL in the browser that triggers the breakpoint
  5. Debug the Python in the PyCharm panel