Skip to content

Commit

Permalink
docs: update documentation with latest how-to steps
Browse files Browse the repository at this point in the history
  • Loading branch information
mariajgrimaldi committed Dec 25, 2024
1 parent 6cc5849 commit 57ec387
Show file tree
Hide file tree
Showing 6 changed files with 178 additions and 146 deletions.
3 changes: 3 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ help:
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

serve_docs: ## serve the built docs locally to preview the site in the browser
sphinx-autobuild . $(BUILDDIR)/html
268 changes: 123 additions & 145 deletions docs/how-tos/create-a-new-filter.rst

Large diffs are not rendered by default.

File renamed without changes.
49 changes: 49 additions & 0 deletions docs/reference/filters-configuration.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Filter Configurations
#####################

The :term:`filter configuration` is a dictionary used to configure the pipeline steps for a particular filter. The configuration settings are specific for each :term:`filter type`. The dictionary looks like this:

.. code-block:: python
OPEN_EDX_FILTERS_CONFIG = {
"FILTER_TYPE": { # Replace with the specific filter type
"fail_silently": True, # Set to True to ignore exceptions and continue the pipeline
"pipeline": [
"module.path.PipelineStep0", # Replace with the actual module path and class name
"module.path.PipelineStep1",
# Add more steps as needed
"module.path.PipelineStepN",
]
},
}
Where:

- ``FILTER_TYPE`` is the :term:`filter type`.
- ``fail_silently`` is a boolean flag indicating whether the pipeline should continue executing the next steps when a runtime exception is raised by a pipeline step.
- If ``True``, when a pipeline step raises a runtime exception (e.g., ``ImportError`` or ``AttributeError``) which are not intentionally raised by the developer during the filter's execution; the exception won't be propagated and the execution will resume, i.e the next steps will be executed.
- If ``False``, the exception will be propagated and the execution will stop returning control to the caller.
- ``pipeline`` is list of paths for each pipeline step. Each path is a string with the following format: ``module.path.PipelineStepClassName``. The module path is the path to the module where the pipeline step class was implemented and the class name is the name of the class that implements the ``run_filter`` method to be executed when the filter is triggered.

With this configuration:

.. code-block:: python
OPEN_EDX_FILTERS_CONFIG = {
"FILTER_TYPE": {
"fail_silently": True,
"pipeline": [
"non_existing_module.PipelineStep",
"existing_module.NonExistingPipelineStep",
"module.path.PipelineStep",
]
},
}
Triggering the filter will behave as follows:

- The pipeline tooling will catch the ``ImportError`` exception raised by the first step and continue executing the next steps.
- The pipeline tooling will catch the ``AttributeError`` exception raised by the second step and continue executing the next steps.
- The pipeline tooling will execute the third step successfully and then return the result.

For more details on the configuration see :doc:`../decisions/0002-hooks-filter-config-location`.
2 changes: 1 addition & 1 deletion docs/reference/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ A filter has multiple components that are used to define, execute and handle fil
Filters can raise exceptions to control the flow of the pipeline. If a filter raises an exception, the pipeline halts, and the exception becomes the pipeline's output. Exceptions are typically raised when certain conditions specified in the filter's logic are met, allowing the filter to control the application flow. E.g., the `CourseEnrollmentStarted filter`_ might raise an exception if the user is ineligible for enrollment called ``PreventEnrollment``.

Filter Configuration
Filter configuration is a dictionary that defines the pipeline settings for a filter. Each filter type has its own configuration, which includes settings like whether errors should fail silently or propagate, and the sequence of pipeline steps. Configurations specify the filter type, error-handling preferences, and a list of module paths for each pipeline step to be executed. E.g., the configuration for the `CourseEnrollmentStarted filter`_ might include settings like ``fail_silently: False`` and ``['my_plugin.filters.StopEnrollmentIfNotValidEmail']`` as its pipeline steps. See the :doc:`/decisions/0002-hooks-filter-config-location` for more details on the configuration format.
The filter configuration is a dictionary that defines the pipeline settings for a filter. Each filter type has its own configuration, which includes settings like whether errors should fail silently or propagate, and the sequence of pipeline steps. Configurations specify the filter type, error-handling preferences, and a list of module paths for each pipeline step to be executed. E.g., the configuration for the `CourseEnrollmentStarted filter`_ might include settings like ``fail_silently: False`` and ``['my_plugin.filters.StopEnrollmentIfNotValidEmail']`` as its pipeline steps. See the :doc:`/decisions/0002-hooks-filter-config-location` for more details on the configuration format.

This glossary provides a high-level overview of the key concepts and components of the Open edX Filters library. Understanding these terms will help you implement filters in your application and leverage the filter tooling to control the flow of your application based on specific conditions. For a better illustration of these concepts, refer to the :doc:`/how-tos/using-filters` guide.

Expand Down
2 changes: 2 additions & 0 deletions docs/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ References

glossary
filters
filters-configuration
django-plugins-and-filters
real-life-use-cases
architecture-subdomains

0 comments on commit 57ec387

Please sign in to comment.