Need Recipe for common dev workflow

I’ve got the devstack built and running and it seems to work. Phew!
Now its time to figure out how all this code works and try fixing something or changing it to see if I can actually develop.

From the standpoint of Django development:
Let’s say I want to change something in the CMS So I’d typically want to use the debugger in a section of the code that is relevant so I could set breakpoints, add print statements, find the bug, change the code, test it…

Could someone provide a recipe (I work on an Ubuntu machine) that would allow me to use an IDE like PyCharm to do this debug cycle. I’m guessing that code may be very data-driven. So perhaps things like XBlocks are defined in a database and then some more generic code loads it and executes based on the data… or maybe not. The point is that the workflow might need some amount of database tampering in order to achieve an effect on behavior so please describe how that might be done in addition to modifying the Django. Of course, I’m not asking about UI changes but that would certainly be another needed recipe.

Any instructions on correctly setting up the Python virtual environment would also be helpful.
I tried building one based on python3.8 with
sudo pip install -qr requirements/edx/development.txt --exists-action w

and it failed. The log file is long. I can attach with a reply but maybe this was the wrong way to build the venv.

Thanks for any help!

Hello David!

The devstack has a document on setting up PyCharm for development and debugging.

There’s also an option to develop and debug using Visual Studio Code.

Both approaches mentioned above works for such workflows.

You can also work directly inside the Devstack shell, using the shell with:

$ make studio-shell

root@studio:/edx/app/edxapp/edx-platform# source ../venvs/edxapp/bin/activate

(edxapp) root@studio:/edx/app/edxapp/edx-platform# ./manage.py cms shell --settings devstack

Python 3.5.2 (default, Oct  8 2019, 13:06:37) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> 

Finally, you can even use PDB debugging inside the container by running the service manually (either in a separate port or killing the original process):

root@studio:/edx/app/edxapp/edx-platform# /edx/app/edxapp/venvs/edxapp/bin/pytn /edx/app/edxapp/edx-platform/manage.py cms runserver 0.0.0.0:18020 --settings devstack_docker
(...)
Django version 1.11.29, using settings 'cms.envs.devstack_docker'
Starting development server at http://0.0.0.0:18020/
Quit the server with CONTROL-C.

This is in your development environment, outside of the devstack containers, right? Open edX currently supports Python 3.5, so I recommend pyenv to manage different Python versions.

Let me know if this helps you or if you have further questions.

Cheers!