Any good XBlock developement practices?

Hello,

I’m new to OpenEdx and I’m working on XBlocks development and integration. I need some good suggestions and proposals for optimizing my development environment as now I’m using a Linux virtual machine working directly on the edx platform (LMS and CMS). When I modify the code of my XBlock I need to reinstall, update assets and restart services every time, which is about 10-15 minutes.

First I managed to build my XBlock using the SDK, but when I installed it in the edx platform it didn’t work at all. I need to be able to make changes in the XBlock code and see the results in less amount of time.

Thanks for your help!
J

You should be able to place the XBlock repo in the src directory of your devstack, and then within the VM/docker containers, it will show up at /edx/src/.... If you install it into the edxapp virtual environment using pip install -e /edx/src/name-of-my-block/, then it will install in “editable mode”, using that exact folder rather than copying it into the virtualenv’s lib directory. Now, whenever you make a change to the XBlock’s python code, django should detect it and restart automatically; if not, just run make lms-restart to force it to restart.

Updating assets shouldn’t be necessary; I don’t think the XBlock assets are cached, though it may depend on how you have things set up, or I could be wrong.

Looks like I’m using the second option: I placed my XBlock folder in /home/ubuntu and I installed it using pip in the virtual environment:

sudo -U -u edxapp bash
source /edx/app/edxapp/edxapp_env
/edx/bin/pip.edxapp install /home/ubuntu/xblock-folder

then paver update_assets from edx-platdorm directory and restart the services.

Do I need to change the location of the XBlock? Also, If the changes are done in the static files (js, html) will Django also detect those changes?

Finally, make lms-restart is not working for me. Sould it be run in the venv or particular directory?

Big thanks for your help @braden :blush:
J

Most people who want to develop XBlocks or otherwise develop with edX use devstack to run it in a docker container; that’s where the make lms-restart command comes from. I’d recommend that approach for development.

1 Like

Thank you for the recommendation, I will start using this approach for development.

J