Skip to content

Commit

Permalink
feat: add init task to pip-install mounted edx-platform
Browse files Browse the repository at this point in the history
  • Loading branch information
kdmccormick committed Jan 11, 2023
1 parent b903c69 commit d68edcf
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
10 changes: 10 additions & 0 deletions changelog.d/20230111_143421_kdmc_egg_info_init_task.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!--
Create a changelog entry for every new user-facing change. Please respect the following instructions:
- Indicate breaking changes by prepending an explosion 💥 character.
- Prefix your changes with either [Bugfix], [Improvement], [Feature], [Security], [Deprecation].
- You may optionally append "(by @<author>)" at the end of the line, where "<author>" is either one (just one)
of your GitHub username, real name or affiliated organization. These affiliations will be displayed in
the release notes for every release.
-->

- [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).
12 changes: 6 additions & 6 deletions docs/dev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ Setting up a development environment for edx-platform

Following the instructions :ref:`above <bind_mounts>` on how to bind-mount directories from the host above, you may mount your own `edx-platform <https://github.com/openedx/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.

Expand All @@ -211,24 +211,24 @@ 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 <https://docs.python.org/3/library/functions.html#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 <https://docs.python.org/3/library/functions.html#breakpoint>`__ with ``breakpoint()`` anywhere in your code and run::

tutor dev start --mount=/path/to/edx-platform lms

The default debugger is ``ipdb.set_trace``. ``PYTHONBREAKPOINT`` can be modified by setting an environment variable in the Docker imamge.

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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
12 changes: 12 additions & 0 deletions tutor/templates/jobs/init/lms.sh
Original file line number Diff line number Diff line change
@@ -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 %}
Expand All @@ -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
Expand Down

0 comments on commit d68edcf

Please sign in to comment.