Tutor plugin. Fix for drag_and_drop_v2 key error

Hi!
I hope someone give me advice or clue about what I am doing wrong.

  • What I want: delete file from container when platform initialize.
  • What I do: add CLI_DO_INIT_TASKS filter in my plugin with rm <file to deletion> command in .sh file.
  • What I got: my command runs on init stage, but file that i want to remove remains in container.

Last lines of tutor local launch output:

Running init task in cms
docker compose -f /home/leonid/.local/share/tutor/env/local/docker-compose.yml -f /home/leonid/.local/share/tutor/env/local/docker-compose.prod.yml --project-name tutor_local -f /home/leonid/.local/share/tutor/env/local/docker-compose.jobs.yml run --rm cms-job sh -e -c '# Fix for drag_and_drop_v2 key error
rm --verbose /openedx/venv/lib/python3.8/site-packages/drag_and_drop_v2/translations/ru/LC_MESSAGES/text.mo'
WARN[0000] /home/leonid/.local/share/tutor/env/local/docker-compose.yml: `version` is obsolete 
WARN[0000] /home/leonid/.local/share/tutor/env/local/docker-compose.prod.yml: `version` is obsolete 
WARN[0000] /home/leonid/.local/share/tutor/env/local/docker-compose.jobs.yml: `version` is obsolete 
[+] Creating 5/0
 ✔ Container tutor_local-mysql-1          Running                                                                        0.0s 
 ✔ Container tutor_local-permissions-1    Created                                                                        0.0s 
 ✔ Container tutor_local-redis-1          Running                                                                        0.0s 
 ✔ Container tutor_local-elasticsearch-1  Running                                                                        0.0s 
 ✔ Container tutor_local-mongodb-1        Running                                                                        0.0s 
[+] Running 1/1
 ✔ Container tutor_local-permissions-1  Started                                                                          1.0s 
removed '/openedx/venv/lib/python3.8/site-packages/drag_and_drop_v2/translations/ru/LC_MESSAGES/text.mo'
All services initialised.
The platform is now running and can be accessed at the following urls:

    http://testmooc.local
    http://studio.testmooc.local
    http://apps.testmooc.local

Command run successfully, I see command output removed '/openedx/venv/lib/python3.8/site-packages/drag_and_drop_v2/translations/ru/LC_MESSAGES/text.mo', but if I check:

$ tutor local exec cms ls -l  /openedx/venv/lib/python3.8/site-packages/drag_and_drop_v2/translations/ru/LC_MESSAGES/
docker compose -f /home/leonid/.local/share/tutor/env/local/docker-compose.yml -f /home/leonid/.local/share/tutor/env/local/docker-compose.prod.yml --project-name tutor_local exec cms ls -l /openedx/venv/lib/python3.8/site-packages/drag_and_drop_v2/translations/ru/LC_MESSAGES/
total 48
-rw-r--r-- 1 app app 18165 Mar 22 13:45 text.mo
-rw-r--r-- 1 app app 27878 Mar 22 13:45 text.po

File remains in container.
If I remove this file with command: tutor local exec cms rm <file to deletion>, changes persists. And this is what I want to achieve with my plugin when platform initializes.

About reason of this file deletion. Translation for this xblock contain bug that cause key error. To fix it in “easy way” providing alternate translation file is not sufficient, need to remove existing compiled translation file.

I found where I am been wrong:

  • Changes in docker containers not persisting. How I forgot it.
  • Init tasks do changes in bind mounts, that persists.
  • For my purposes, I must change docker image ( openedx-dockerfile patch).

Finally I added to my plugin.py (based on Tutor plugin cookiecutter):

# Add translations to env/build/openedx/locale folder
openedx_locale_path: str = os.path.join(root_path, "env/build/openedx/locale")
myplugin_openedx_locale_path: str = pkg_resources.resource_filename("myplugin_tutor", "openedx_locale")
shutil.copytree(myplugin_openedx_locale_path, openedx_locale_path, dirs_exist_ok=True)

and openedx-dockerfile patch with:

# Fix for drag_and_drop_v2 key error
RUN rm /openedx/venv/lib/python3.8/site-packages/drag_and_drop_v2/translations/ru/LC_MESSAGES/text.mo