Skip to content

Commit

Permalink
feat: separate pip-install-mounted script
Browse files Browse the repository at this point in the history
  • Loading branch information
kdmccormick committed Aug 9, 2024
1 parent 610d26f commit cc6e668
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
21 changes: 21 additions & 0 deletions tutor/templates/build/openedx/bin/pip-install-mounted
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh
# Whenever edx-platform or installable packages (e.g., xblocks) are mounted,
# during the image build, they are copied over to container and installed. This
# results in egg_info generation for the mounted directories. However, the
# egg_info is not carried over to host. When the containers are launched, the
# host directories without egg_info are mounted on runtime and disappear from
# pip list. To fix this, we `pip install` edx-platform and every mounted
# package ("/mnt/*") again, re-generating the egg-infos. This script is called
# during LMS initialization, and can also be called separately by users.

set -eu
set -x # Echo out executed lines

for mounted_dir in /openedx/edx-platform /mnt/*; do
if [ -f $mounted_dir/setup.py ] && ! ls $mounted_dir/*.egg-info >/dev/null 2>&1 ; then
echo "Unable to locate egg-info in $mounted_dir -- generating now."
pip install -e $mounted_dir
fi
done

set +x
26 changes: 6 additions & 20 deletions tutor/templates/jobs/init/mounted-directories.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@
# The initialization job contains various re-install operations needed to be done
# on mounted directories (edx-platform, /mnt/*xblock, /mnt/<edx-ora, search, enterprise>)
# The initialization job contains various re-install and asset-symlinking
# operations needed to be done on mounted directories (edx-platform,
# /mnt/*xblock, /mnt/<edx-ora, search, enterprise>)

echo "Performing additional setup for bind-mounted directories."
set -x # Echo out executed lines

cd /openedx/edx-platform || exit 1
cd /openedx/edx-platform || exit 1 # Fail early if edx-platform is missing

# Whenever edx-platform or installable packages (e.g., xblocks) are mounted,
# during the image build, they are copied over to container and installed. This
# results in egg_info generation for the mounted directories. However, the
# egg_info is not carried over to host. When the containers are launched, the
# host directories without egg_info are mounted on runtime and disappear from
# pip list. To fix this, we `pip install` edx-platform (".") and every mounted
# package ("./mnt/*") again, re-generating the egg-infos.
for mounted_dir in . /mnt/*; do
if [ -f $mounted_dir/setup.py ] && ! ls $mounted_dir/*.egg-info >/dev/null 2>&1 ; then
echo "Unable to locate egg-info in $mounted_dir -- generating now."
pip install -e $mounted_dir
fi
done
pip-install-mounted

# The same problem exists for edx-platform's compiled frontend assets, but recompiling
# them is very slow. So, instead of re-compiling, we create symlinks to an alternate
# directory in which we expect them to have been cached (/openedx/assets).
ln-assets /openedx/assets /openedx/edx-platform

set -x
set +x
echo "Done setting up bind-mounted directories."

0 comments on commit cc6e668

Please sign in to comment.