This repository has been archived by the owner on Nov 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Debugging with VS Code
Samuel edited this page Apr 12, 2022
·
5 revisions
Go to the "Run and Debug" tab (Ctrl
+Shift
+D
):
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
You can attach to the Selenium container's VNC server to see the testing (very useful for debugging failed tests):
- Open
~/.autoreduce/config.json
and change the value of"run_headless"
tofalse
. If the file doesn't exist run the tests once first. - Forward the port 7900 from VSCode
- Go to http://localhost:7900, click
Connect
and enter the passwordsecret
. Details on why this works can be found in the Selenium Docker README
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:
- 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. - Add a
debugpy
attach inqueue_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()
- Start a VSCode Python attach to port 5700
- You should now be able to step through the whole reduction, including going into the
reduce.py
script
Check the page https://github.com/ISISScientificComputing/autoreduce/wiki/Common-Development-Errors