-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add documentation for current filters tooling
- Loading branch information
1 parent
8b11af9
commit 44d8950
Showing
8 changed files
with
276 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
Open edX filters glossary | ||
########################## | ||
|
||
This glossary provides definitions for some of the concepts needed to use the Open edX Filters library. | ||
|
||
|
||
Pipelines | ||
--------- | ||
|
||
A pipeline is a list of functions that are executed in order. Each function receives the output of the previous function as input. The output of the last function is the output of the pipeline. | ||
|
||
Pipeline steps | ||
-------------- | ||
|
||
A pipeline step is a function that receives data, manipulates it and returns it. It can be used to transform data, to validate it, to filter it, to enrich it, etc. | ||
|
||
Open edX Filter | ||
--------------- | ||
|
||
An Open edX Filter is a Python class used for executing pipelines or list of functions in specific order. It implements a `run_filter` method that receives the data to be processed and returns the output of the pipeline. | ||
|
||
Filter signature | ||
---------------- | ||
|
||
It's the signature of the `run_filter` method. It defines the input and output of the filter. The input is a dictionary with the data to be processed. The output is a dictionary with the processed data. | ||
|
||
Filter type | ||
----------- | ||
|
||
It's the filter identifier. It's used to identify the filter in the configuration settings. When configuring the pipeline for a filter, the type is as an index for the filter configuration. | ||
|
||
Filter exceptions | ||
----------------- | ||
|
||
Besides acting as a filter, an Open edX Filter can also raise exceptions. These exceptions are used to control the execution of the pipeline. If an exception is raised, the pipeline execution is stopped and the exception is raised again as the output of the pipeline. | ||
|
||
Filter configuration | ||
-------------------- | ||
|
||
The filter configuration is a dictionary with the configuration settings for the filter. It's used to configure the pipeline for a filter. The configuration settings are specific for each filter type. The dictionary looks like this: | ||
|
||
.. code-block:: python | ||
OPEN_EDX_FILTERS_CONFIG = { | ||
"<FILTER EVENT TYPE>": { | ||
"fail_silently": <BOOLEAN>, | ||
"pipeline": [ | ||
"<STEP MODULE PATH 0>", | ||
"<STEP MODULE PATH 1>", | ||
... | ||
"<STEP MODULE PATH N-1>", | ||
] | ||
}, | ||
} | ||
Where: | ||
|
||
- ``<FILTER EVENT TYPE>`` is the filter type. | ||
- ``fail_silently`` is a boolean value. If ``True``, the method ``run_pipeline`` won't raise runtime exceptions, and the pipeline execution will resume if one is raised. If ``False``, it will raise runtime exceptions and the pipeline execution will stop. By runtime exceptions we mean exceptions like ``ImportError`` or ``AttributeError``, which are not raised by the filter itself. | ||
- ``pipeline`` is list of paths for each pipeline step. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ Concepts | |
:caption: Contents: | ||
|
||
hooks-extension-framework | ||
glossary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,41 @@ | ||
Django Plugins and Filters | ||
########################## | ||
|
||
Django plugins is one of the most valuable extension mechanisms for the Open edX platform. In this section, we will | ||
guide you through the process of using filters inside your own plugin. | ||
|
||
|
||
Use filters inside your plugin | ||
****************************** | ||
|
||
Imagine you have your own registration plugin and you want to add a filter to it. The first thing you need to do is | ||
adding ``openedx-filters`` to your requirements file. Then, you can import the registration filter and use it inside | ||
your registration flow as it's used in the LMS registration flow. You can even add your own filters to your registration, | ||
after implementing their definitions in your plugin. | ||
|
||
Configure filters | ||
***************** | ||
|
||
Filters are configured in the ``OPEN_EDX_FILTERS_CONFIG`` dictionary which can we specified in your plugin's settings | ||
file. The dictionary has the following structure: | ||
|
||
.. code-block:: python | ||
OPEN_EDX_FILTERS_CONFIG = { | ||
"<FILTER EVENT TYPE>": { | ||
"fail_silently": <BOOLEAN>, | ||
"pipeline": [ | ||
"<STEP NAME 0>", | ||
"<STEP NAME 1>", | ||
... | ||
"<STEP NAME N-1>", | ||
] | ||
}, | ||
} | ||
Create pipeline steps | ||
********************* | ||
|
||
In your own plugin, you can create your own pipeline steps by inheriting from ``PipelineStep`` and implementing the | ||
``run_filter`` method. You can find examples of pipeline steps in the ``openedx-filters-samples`` repository. See :doc:`/quickstarts/index` for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,3 @@ References | |
:caption: Contents: | ||
|
||
django-plugins-and-filters | ||
pipeline-implementation-details |
This file was deleted.
Oops, something went wrong.