From d68edcfe90edeeef109f764ed84546c76fce8d5b Mon Sep 17 00:00:00 2001 From: Kyle McCormick Date: Wed, 11 Jan 2023 14:34:26 -0500 Subject: [PATCH] feat: add init task to pip-install mounted edx-platform TODO details Closes https://github.com/openedx/wg-developer-experience/issues/152 --- .../20230111_143421_kdmc_egg_info_init_task.md | 10 ++++++++++ docs/dev.rst | 12 ++++++------ tutor/templates/jobs/init/lms.sh | 12 ++++++++++++ 3 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 changelog.d/20230111_143421_kdmc_egg_info_init_task.md diff --git a/changelog.d/20230111_143421_kdmc_egg_info_init_task.md b/changelog.d/20230111_143421_kdmc_egg_info_init_task.md new file mode 100644 index 00000000000..69f31299091 --- /dev/null +++ b/changelog.d/20230111_143421_kdmc_egg_info_init_task.md @@ -0,0 +1,10 @@ + + +- [Improvement] Before, Open edX developers needed to pip-install requirements when bind-mounting a local copy of edx-platform the first time. Now, they can just launch the bind-mounted platform instead: ``tutor ... launch --mount=edx-platform`` (by @kdmccormick). diff --git a/docs/dev.rst b/docs/dev.rst index 4ff7c933a66..f824f8b8fb5 100644 --- a/docs/dev.rst +++ b/docs/dev.rst @@ -200,7 +200,7 @@ Setting up a development environment for edx-platform Following the instructions :ref:`above ` on how to bind-mount directories from the host above, you may mount your own `edx-platform `__ fork in your containers by running:: - tutor dev start -d --mount=/path/to/edx-platform lms + tutor dev launch -d --mount=/path/to/edx-platform But to achieve that, you will have to make sure that your fork works with Tutor. @@ -211,16 +211,17 @@ Then, you should run the following commands:: # Run bash in the lms container tutor dev run --mount=/path/to/edx-platform lms bash - # Compile local python requirements - pip install --requirement requirements/edx/development.txt - # Install nodejs packages in node_modules/ npm clean-install # Rebuild static assets openedx-assets build --env=dev -After running all these commands, your edx-platform repository will be ready for local development. To debug a local edx-platform repository, you can then add a `python breakpoint `__ with ``breakpoint()`` anywhere in your code and run:: +After running all these commands, your edx-platform repository will be ready for local development. Going forward, for the same copy of edx-platform, you can use ``start`` instead of ``launch`` to start the platform more quickly:: + + tutor dev start -d --mount=/path/to/edx/platform + +To debug a local edx-platform repository, you can then add a `python breakpoint `__ with ``breakpoint()`` anywhere in your code and run:: tutor dev start --mount=/path/to/edx-platform lms @@ -228,7 +229,6 @@ The default debugger is ``ipdb.set_trace``. ``PYTHONBREAKPOINT`` can be modified If LMS isn't running, this will start it in your terminal. If an LMS container is already running background, this command will stop it, recreate it, and attach your terminal to it. Later, to detach your terminal without stopping the container, just hit ``Ctrl+z``. - XBlock and edx-platform plugin development ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tutor/templates/jobs/init/lms.sh b/tutor/templates/jobs/init/lms.sh index 88c94625c54..1231f794a0c 100644 --- a/tutor/templates/jobs/init/lms.sh +++ b/tutor/templates/jobs/init/lms.sh @@ -1,5 +1,16 @@ +# If the the entry points info file (within the *egg-info directory) +# doesn't exist or is out-of-date with respect to setup.py, +# then we need to (re-)generate the egg-info by pip-installing this directory. +# Otherwise, XBlocks and Django App Plugins will not be registered. +# (This will only ever apply when a local copy of edx-platform has been +# bind-mounted by the user.) +ENTRY_POINTS_INFO=Open_edX.egg-info/entry_points.txt +if [ ! -f "$ENTRY_POINTS_INFO" ] || [ "$ENTRY_POINTS_INFO" -ot setup.py ]; then + pip install -e . +fi dockerize -wait tcp://{{ MYSQL_HOST }}:{{ MYSQL_PORT }} -timeout 20s +# Wait for MongoDB. {%- if MONGODB_HOST.startswith("mongodb+srv://") %} echo "MongoDB is using SRV records, so we cannot wait for it to be ready" {%- else %} @@ -8,6 +19,7 @@ dockerize -wait tcp://{{ MONGODB_HOST }}:{{ MONGODB_PORT }} -timeout 20s echo "Loading settings $DJANGO_SETTINGS_MODULE" +# Run migrations. ./manage.py lms migrate # Create oauth2 apps for CMS SSO