Skip to content
This repository has been archived by the owner on Nov 14, 2022. It is now read-only.

Debugging with VS Code

Samuel edited this page Apr 12, 2022 · 5 revisions

Run the debugger

Go to the "Run and Debug" tab (Ctrl+Shift+D):

image

Running and attaching the debugger is done via a different task for each part:

  • Queue Processor - Run queue processor launch task. If you see connection error, you have to start ActiveMQ
  • Web App - Run webapp launch task.
  • pytest tests with Django and Selenium:
    • Selenium is used for part of the webapp testing, and it allows tests to open the webpage in a browser and automate assertions that elements are visible as expected, showing the correct text, etc.
    • Start Selenium with the Run Selenium Docker daemon task.
    • Then run the pytest launch task. If running from command line you need to pass in some environment variables:
RUNNING_VIA_PYTEST=true SELENIUM_REMOTE=true DISPLAY=:1 pytest

Visually debugging selenium tests

You can attach to the Selenium container's VNC server to see the testing (very useful for debugging failed tests):

Debugging a reduce.py script and queue_processor/reduction

This is slightly more involved as a large part of the reduction in queue_processor/reduction is executed in a subprocess, which is not being debugged by default. For now we don't have a single start task that can set up the whole thing.

To fully debug the reduction you need to:

  1. Start the queue processor, either with Queue Processor Docker Attach or without a debugger. It doesn't matter as we need to debug the child process that runs the actual reduction.
  2. Add a debugpy attach in queue_processor/reduction/service.py::reduce. Example of how that looks:
import debugpy
print('Waiting for client')
debugpy.listen(5700)
debugpy.wait_for_client()
debugpy.breakpoint()
  1. Start a VSCode Python attach to port 5700
  2. You should now be able to step through the whole reduction, including going into the reduce.py script

Common issues

Check the page https://github.com/ISISScientificComputing/autoreduce/wiki/Common-Development-Errors

Clone this wiki locally