@viadanna Have you tried debugging an individual unit test with VS Code for the LMS? I’m able to run the pytest lms/<path>/test_*.py successfully, however, I’m not able to debug to see why that test is failing. Any advice on how to do this with VS Code?
Thanks a lot for the solution to our woes @farhaanbukhsh
I can confirm it works when replacing the original code in private.py with
import os
import ptvsd
if os.environ.get('RUN_MAIN') or os.environ.get('WERKZEUG_RUN_MAIN'):
ptvsd.enable_attach(address=('0.0.0.0', 5678), redirect_output=True)
@viadanna I got an issue when trying to debug a third party python package and wanted to let you know how I got around that. It wouldn’t let me debug it.
@viadanna If you’re looking to debugging a Django management command follow these steps. This may be worth adding your blog post on how to debug a management command.
Update: I’m able to get the debugger starting to work with the following ${workspaceFolder}/vscode/launch.json configuration. The file below is running the refresh_course_metadata Django management command from the course-discovery service.
You can either update the default ${workspaceFolder}/.env file with the environment variables or add the “env” to the launch configuration as shown below. I added in the virtual environment variables from /edx/app/discovery/discovery_env settings.
The ${workspaceFolder}/.env is the default Python: Env File setting for the workspace.
Hey @Zachary_Trabookis, it seems that you were able to get it working. I took a look at my own launch for manage.py and it doesn’t look too different.
I noticed that my own has some environment variables missing but still works.
One question, do you need to use the debugStdLib? My VScode complains that the property is not allowed but I see it working when argparse throws an exception.
@viadanna Thanks for sharing your configuration for Django management for LMS dump_course_ids. That looks similar to what I did with refresh_course_metadata for the course-discovery service.
I would keep debugStdLib in the configuration since it allows you to debug third-party libraries. That is in regards to this response.