Skip to content

System-defined taxonomies architecture decisions - #56

Merged
ormsbee merged 4 commits into
openedx:mainfrom
open-craft:chris/system-taxonomy-adrs
Jun 20, 2023
Merged

System-defined taxonomies architecture decisions#56
ormsbee merged 4 commits into
openedx:mainfrom
open-craft:chris/system-taxonomy-adrs

Conversation

@ChrisChV

Copy link
Copy Markdown
Contributor

This PR documents the decisions that arose from openedx/modular-learning#61
The ADRs here continues the enumeration of #55

Testing instructions

  • Check the added ADRs for clarity and correctness.

Supporting information

Closes openedx/modular-learning#61

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jun 13, 2023
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @ChrisChV! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@pomegranited pomegranited left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for writing up these decisions @ChrisChV ! I've left some suggestions, but feel free to push back if any don't make sense?

Create a ``Content-side`` class that lives on ``openedx.features.tagging``.
You must create a content-side model for each content and taxonomy to be used.
You can use ``ContentSystemTaxonomyMixin`` and the mixin of the Taxonomy (e.g. ``LanguageSystemTaxonomy``) to create the new class.
Then, all system-defined taxonomies must be created initially in a fixture.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't true for all system taxonomies.. some are free text, as described below. So I think this sentence should be removed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence has been misunderstood. I have updated the document to make the separation between the creation of instances for the system-defined taxonomies and the creation of their tags

You can use ``ContentSystemTaxonomyMixin`` and the mixin of the Taxonomy (e.g. ``LanguageSystemTaxonomy``) to create the new class.
Then, all system-defined taxonomies must be created initially in a fixture.

Each Taxonomy mixin has ``get_tags``; to configure the valid tags, and ``validate_tags``; to check if a list of tags are valid.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each Taxonomy mixin has get_tags; to configure the valid tags,

From what I understand, most system taxonomies won't need to override get_tags. Language is an exception, since we're filtering down the available ISO languages using Django settings.LANGUAGES , but from what I understand, most system taxonomies won't need to do this.

  • hardcoded by fixtures/migrations: Tags are added to the database, linked to the SystemTaxonomy, so the base class get_tags will return them.
  • Free-form tags: no Tags exist in the database for the SystemTaxonomy; instead the user can add any free-text tag they like, and they are validated dynamically below. The base class get_tags will return an empty set, which is correct for free-form taxonomies.

and validate_tags; to check if a list of tags are valid.

I'd removed validate_tags from the Taxonomy data architecture, and instead proposed just validating individual object tags with validate_object_tag.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understand, most system taxonomies won't need to override get_tags. Language is an exception, since we're filtering down the available ISO languages using Django settings.LANGUAGES , but from what I understand, most system taxonomies won't need to do this.

@pomegranited Yes it's correct. I will update the docs so this is not misunderstood

I'd removed validate_tags from the Taxonomy data architecture, and instead proposed just validating individual object tags with validate_object_tag.

Ohh Ok, Noted 👍


Each Taxonomy mixin has ``get_tags``; to configure the valid tags, and ``validate_tags``; to check if a list of tags are valid.

We have two ways to handle tags in this type of taxonomies:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: for clarity

Suggested change
We have two ways to handle tags in this type of taxonomies:
We have two ways to handle tag creation and validation for system taxonomies:

~~~~~~~~~~~~~~

This taxonomy depends on a core data model, but simplifies the creation of Tags by allowing free-form tags,
but we can validate the tags using the ``validate_tags`` method. For example we can put the Author taxonomy associated with

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ditto re validate_object_tag.)

Auto-generated from the codebase
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Taxonomies that depend on a core data model and it is necessary to create a Tag for each object created.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: adding some justification here

Suggested change
Taxonomies that depend on a core data model and it is necessary to create a Tag for each object created.
Taxonomies that depend on a core data model could create a Tag for each eligible object. Maintaining this dynamic list of available Tags is cumbersome: we'd need triggers for creation, editing, and deletion. And if it's a large list of objects (e.g. Users), then copying that list into the Tag table is overkill. It is better to dynamically generate the list of available Tags, and/or dynamically validate a submitted object tag than to store the options in the database.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

After create the ``Content-side`` class, `register a pipeline`_ with the respective filter.
Some filters must to be created, like ``CourseCreation``, ``LibraryCreation``, etc.

All this logic will be live on ``openedx.features.tagging``.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better for the new filters themselves to live outside of openedx.features.tagging?

The filter logic itself will still live in openedx-filters, and the events that trigger the filters should live as close to the content creation as possible. The openedx.features.tagging code should simply register to receive these events and act on them -- as may other openedx libraries that care about content creation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pomegranited Yes, I updated the doc to be more clear about it 👍

~~~~~~~~~~~~~~

Implement a function to add the tag from the content metadata and register that function
as a Django signal. Use openedx-filters is better in the edx context, but if there is

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: u

Suggested change
as a Django signal. Use openedx-filters is better in the edx context, but if there is
as a Django signal. This works for Django database models, but some of the content lives in Mongo, outside of the Django models. Also, Using openedx-filters is better in the edx context, but if there is

@mphilbrick211 mphilbrick211 added the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Jun 13, 2023

@bradenmacdonald bradenmacdonald left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Context
--------

The System-defined are closed taxonomies created by the system. Some of this are totally static (e.g Language)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The System-defined are closed taxonomies created by the system. Some of this are totally static (e.g Language)
System-defined taxonomies are closed taxonomies created by the system. Some of these are totally static (e.g. Language)

Context
--------

One main characteristic of the System-defined is the automatic content tagging.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
One main characteristic of the System-defined is the automatic content tagging.
One main characteristic of system-defined taxonomies is automatic content tagging.

@pomegranited pomegranited left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Couple of nits to fix, but this is good to merge once they're addressed.

Thank you @ChrisChV !

  • I tested this N/A -- only ADRs
  • I read through the code
  • I checked for accessibility issues N/A
  • Includes documentation

outside of the Django models. Also, using openedx-filters is better in the edx context, but if there is
other no-edX project that need to use ``openedx-tagging``, can use the Django Signals approach.

.. _openedx-filters: https://github.com/openedx/openedx-filters/tree/a4a192e1cac0b70bed31e0db8e4c4b058848c5c4

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to link to project home:

Suggested change
.. _openedx-filters: https://github.com/openedx/openedx-filters/tree/a4a192e1cac0b70bed31e0db8e4c4b058848c5c4
.. _openedx-filters: https://github.com/openedx/openedx-filters

~~~~~~~~

It is necessary to create `filters`_ for each content for creation/edition: ``CourseCreation``, ``LibraryCreation``, etc.
This filters will live on ``openedx-filters``.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
This filters will live on ``openedx-filters``.
These filters will live in ``openedx-filters``.

Comment on lines +24 to +28
After create the ``Content-side`` class for each content and taxonomy,
create a function inside each class with the logic of the auto tagging.
Then you need to register each class as `a pipeline`_ with the respective filter.

This pipelines will live on ``openedx.features.tagging``

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be simpler, since it's only the code encapsulation we need to specify here:

Suggested change
After create the ``Content-side`` class for each content and taxonomy,
create a function inside each class with the logic of the auto tagging.
Then you need to register each class as `a pipeline`_ with the respective filter.
This pipelines will live on ``openedx.features.tagging``
Auto-tagging pipelines will live under ``openedx.features.tagging``, registered as `a pipeline`_ with the respective filter.

@ChrisChV
ChrisChV force-pushed the chris/system-taxonomy-adrs branch from e60097f to 45add7c Compare June 14, 2023 16:25
@ChrisChV

Copy link
Copy Markdown
Contributor Author

@ormsbee It's ready for your review

@e0d

e0d commented Jun 15, 2023

Copy link
Copy Markdown
Contributor

@ChrisChV the conventional commit labels are case sensitive. Can you amend the last commit when you get a second?

@e0d e0d removed the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Jun 15, 2023
@ChrisChV
ChrisChV force-pushed the chris/system-taxonomy-adrs branch from 45add7c to 69ee8dc Compare June 15, 2023 19:26
@ChrisChV

Copy link
Copy Markdown
Contributor Author

@ChrisChV the conventional commit labels are case sensitive. Can you amend the last commit when you get a second?

@e0d Oh sorry. It's fixed. Thanks!

@ormsbee
ormsbee merged commit eb59338 into openedx:main Jun 20, 2023
@openedx-webhooks

Copy link
Copy Markdown

@ChrisChV 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

@pomegranited
pomegranited deleted the chris/system-taxonomy-adrs branch July 4, 2023 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[Tagging] Discovery + ADR: System Defined Taxonomies

7 participants