openedx / edx-django-utils

edX utilities for Django Application development.
https://edx.readthedocs.io/projects/edx-django-utils/en/latest/
Apache License 2.0
26 stars 20 forks source link

[BD-32] feat: Add Hooks Extension Framework tooling #110

Closed mariajgrimaldi closed 3 years ago

mariajgrimaldi commented 3 years ago

Description:

This PR adds a new module for the tools needed by the Hooks Extension Framework to execute filters. This project is described in more depth in the OEP-50.

This tooling will allow us to extend the platform by adding triggers in specific places, those triggers will be able to execute a list of filters previously configured.

For that to happen, we are introducing two functions called triggers_filter. When called, these functions will execute a Pipeline with the list of functions specified by the configuration. This pipeline is defined in ADR Hooks tooling: pipeline

Now, this configuration as indicated in ADR: Configuration for the Hook Extension Framework is defined using Django settings and looks like this (extended format):

HOOKS_EXTENSION_CONFIG = {
      "openedx.lms.module.some_trigger.filter.v1": {
               "pipeline": [
                     "somelibrary.filters.1st_function",
                     "other_library.filters.2nd_function"
                     ],
     },

Pipeline is the list of functions that the pipeline runner will execute, and async indicates how the pipeline is going to run, asynchronous or synchronous. Please be aware that this PR does not add the asynchronous feature, only the synchronous, that feature is meant to be added in another PR to reduce complexity.

Please, check out the ADR where the other configuration formats are defined.

JIRA:

XXX-XXXX

Dependencies:

List dependencies on other outstanding PRs, issues, etc.

Merge deadline:

None

Testing instructions:

  1. Run make lms-shell
  2. Inside the shell run: pip install -e git+https://github.com/edx/edx-django-utils.git@MJG/hooks_pipeline_tool#egg=edx_django_utils
  3. Run pip install -e https://github.com/eduNEXT/openedx-basic-hooks.git, you can also use your own test library. Here are defined the functions that will be executed by a trigger.
  4. Here's a quick and dirty way to create and use triggers on edx-platform. We defined three triggers and the configuration needed to use this framework. PENDING: add link to the PR against edx-platform that includes the first implementation of a trigger.
  5. (Optional) If you're using our demo and sample openedx-hooks-library, you have a trigger_filter ready to be used. What you'll have to do is execute the logic that the hook extended, for example:

Reviewers:

Merge checklist:

Post merge:

Author concerns:

Note that some utilities may warrant their own repository. A judgement call needs to be made as to whether code properly belongs here or not. Please review with the Architecture Team if you have any questions.

openedx-webhooks commented 3 years ago

Thanks for the pull request, @mariajgrimaldi! I've created BLENDED-806 to keep track of it in Jira.

When this pull request is ready, tag your edX technical lead.

mariajgrimaldi commented 3 years ago

Hey! I made a PR showing how it'll look adding the async feature -if we decide that this repository is the best place for Hooks Extension Framework-: https://github.com/edx/edx-django-utils/pull/111

mariajgrimaldi commented 3 years ago

Closing PR following recommendations made on this post: https://discuss.openedx.org/t/configuration-for-the-hooks-extension-framework/4527 From now on, this PR is going to be found here: https://github.com/eduNEXT/openedx-filters