Plugin `tutor-contrib-aspects` expects missing `edx-event-routing-backends` python package

Hi,

I’ve been having a problem lately with GitHub - openedx/tutor-contrib-aspects: The Open Analytics Reference System - Tutor plugin · GitHub

The plugin expects edx-event-routing-backends to be installed when using ralph (tho this has changed recently iiuc)

System check identified some issues:
WARNINGS:
embargo.GlobalRestrictedCountry.country: (fields.W342) Setting unique=True on a ForeignKey has the same effect as using a OneToOneField.
        HINT: ForeignKey(unique=True) is usually better served by a OneToOneField.
Traceback (most recent call last):
  File "/openedx/venv/lib/python3.11/site-packages/django/apps/registry.py", line 158, in get_app_config
Importing JSON data from file /tmp/erb_config.json
    return self.app_configs[app_label]
           ~~~~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: 'event_routing_backends'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/openedx/edx-platform/./manage.py", line 99, in <module>
    execute_from_command_line([sys.argv[0]] + django_args)
  File "/openedx/venv/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/openedx/venv/lib/python3.11/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/openedx/venv/lib/python3.11/site-packages/django/core/management/base.py", line 420, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/openedx/venv/lib/python3.11/site-packages/django/core/management/base.py", line 464, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/config_models/management/commands/populate_model.py", line 76, in handle
    created_entries = deserialize_json(data, options['username'])
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/config_models/utils.py", line 61, in deserialize_json
    serializer_class = get_serializer_class(apps.get_model(parsed_json["model"]))
                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/django/apps/registry.py", line 208, in get_model
    app_config = self.get_app_config(app_label)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/django/apps/registry.py", line 165, in get_app_config
    raise LookupError(message)
LookupError: No installed app with label 'event_routing_backends'.

I’ve narrowed down the cause of the issue to these lines: tutor-contrib-aspects/tutoraspects/templates/aspects/jobs/init/lms/init-lms.sh at main · openedx/tutor-contrib-aspects · GitHub

The problem is that this package is not installed in the default openedx image overhangio/openedx:21.0.2:

$ tutor local run lms python3 -- -c “import event_routing_backends; print(event_routing_backends.__file__)”
Traceback (most recent call last):
File “”, line 1, in
ModuleNotFoundError: No module named ‘event_routing_backends’

I’ve tried to rebuild an image with this additional dependency and it works so far

$ tutor local run lms python3 -- -c “import event_routing_backends; print(event_routing_backends.__file__)”
/openedx/venv/lib/python3.11/site-packages/event_routing_backends/__init__.py

Is this expected behavior ?

Hi @ComplianceEnthusiast and welcome to the forums!

@Sara_Burns - any advice here?

1 Like

Hi @ComplianceEnthusiast ! Try rebuilding the openedx image

tutor config save
tutor images build openedx --no-cache

If you install Aspects after building the images, you sometimes have to rebuild them to get everything working. If that doesn’t work, please let me know and I can keep troubleshooting

1 Like

The problem is that I have one constraint: it happens in an environment that doesn’t support building an image directly from tutor (of course :smile:)

What I did was rebuild an image externally and let tutor pull it from there instead.

Here’s the exact Dockerfile I used to build the new image:

FROM overhangio/openedx:21.0.2
RUN pip install --no-cache-dir edx-event-routing-backends

@Sara_Burns iiuc your comment, installing aspects also tells tutor to add related dependencies to the resulting openedx image ?

Correct - this patch mounts event-routing-backends when Aspects is installed

RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared \
    pip install "platform-plugin-aspects==v1.1.2"

RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared \
    pip install "edx-event-routing-backends>=9.3.0,<9.4"

If what you have is working though, it seems fine to me!