Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add language auto-tagging #32907

Conversation

rpenido
Copy link
Contributor

@rpenido rpenido commented Aug 4, 2023

Description

This PR adds an auto-tagging feature (language) for Courses and XBlocks.

Every time a Course/XBlock is updated, if there is no Language ObjectTag associated with this Course/XBlock, a new one is created using the Course Language as a reference.

Supporting information:

More Info

Depends on:

Testing instructions

  • Check the unit tests in test_taks.py.
  • Run the unit tests

Manual check can be done in the CMS App:

  1. Start lms and studio using make dev.up.lms+studio+frontend-app-learning
  2. Enabled the CONTENT_TAGGING_AUTO CourseWaffleFlag
  3. Open studio in http://localhost:18010/ and login with [email protected] / edx
  4. Create a course
  5. Create a course
  6. Open cms python shell (./in cms python manage.py cms shell) and and check the created ObjectTags:
from openedx_tagging.core.tagging.models import ObjectTag
object_tags = ObjectTag.objects.all()
object_tags

Private-ref: FAL-3460

@openedx-webhooks
Copy link

openedx-webhooks commented Aug 4, 2023

Thanks for the pull request, @rpenido! 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.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Aug 4, 2023
@rpenido rpenido force-pushed the rpenido/fal-3460-content-auto-tagging-by-system-taxonomies branch from 7665cf2 to d964ba3 Compare August 10, 2023 21:04
@rpenido rpenido force-pushed the rpenido/fal-3460-content-auto-tagging-by-system-taxonomies branch 3 times, most recently from f6693fb to fe32017 Compare August 23, 2023 19:04
@rpenido rpenido force-pushed the rpenido/fal-3460-content-auto-tagging-by-system-taxonomies branch from fe32017 to a18182b Compare August 23, 2023 19:25
@rpenido rpenido force-pushed the rpenido/fal-3460-content-auto-tagging-by-system-taxonomies branch from a18182b to 2bc5070 Compare August 23, 2023 19:36
@rpenido
Copy link
Contributor Author

rpenido commented Aug 24, 2023

Hi @ChrisChV! Could you give me a light here?

After the auto-tagging, this test is failing.

FAILED xmodule/modulestore/tests/test_mixed_modulestore.py::TestMixedModuleStore::test_delete_draft_vertical_1___mongo___0__3__1_ - AssertionError: 1 != 0 : 1 queries executed, 0 expected
Captured queries were:
1. DELETE FROM "oel_tagging_objecttag" WHERE "oel_tagging_objecttag"."object_id" = 'i4x://MITx/999/html/bug_leaf'

When we delete an XBlock, we also delete the ObjectTag associated with it. The problem here is that this test counts the queries against the DB, and we have one more here because of the delete.

with check_mongo_calls(max_find, max_send), self.assertNumQueries(num_mysql):
self.store.delete_item(private_leaf.location, self.user_id)

Whats is the best approach to make this maintainable in the long term? Just update the query count? Mock the handler?

@bradenmacdonald
Copy link
Contributor

@rpenido You can just update the query count. That's what these tests are for - making you aware that the new functionality is having a performance impact on the deletion of XBlocks in general. However, a single additional query is totally fine, especially if it's a very simple and fast query like deleting one row by ID.

@rpenido rpenido force-pushed the rpenido/fal-3460-content-auto-tagging-by-system-taxonomies branch from a6e08f2 to ee179b1 Compare August 25, 2023 00:27
@rpenido rpenido marked this pull request as ready for review August 25, 2023 20:32
@rpenido
Copy link
Contributor Author

rpenido commented Aug 30, 2023

Feature flag done: 5200966

# .. toggle_use_cases: open_edx
# .. toggle_creation_date: 2023-08-30
# .. toggle_tickets: https://github.com/openedx/modular-learning/issues/79
CONTENT_TAGGING_AUTO = WaffleSwitch('content_tagging.auto', __name__)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should use CourseWaffleFlag so that we can turn this on on a per-course basis? What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will this feature be enabled by default sometime in the future? Or do you see it always as an opt-in?
Wouldn't it be a hassle to make the user enable it every time he creates a course?

I don't know the product well enough to find the right balance between features and usability here. I'll happily follow your call!

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, in the future we'll enable it by default and remove this setting. Making it a course waffle flag doesn't mean it's only enabled on a course-by-course basis; you can still turn it on for the whole instance, on our sandbox for example. It just means that during the testing phase you may choose to only turn it on for certain courses.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great! I will look at the documentation tomorrow and change it to a CourseWaffleFlag if I don't see any problem.

Thank you for your input!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 154a4ae!

@rpenido
Copy link
Contributor Author

rpenido commented Aug 31, 2023

Hi @bradenmacdonald! I think this is ready for another review round!

Copy link
Contributor

@ChrisChV ChrisChV left a comment

Choose a reason for hiding this comment

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

@rpenido Looks good to me 👍 Only one comment about the tests. Also, for the record, you need to update the testing instructions with "enable the waffle flag" to check the functionality.

  • I tested this by:
    • Checking and running the tests
    • Run and revert migrations
    • Following the testing instructions to check auto tagging functionality
  • I read through the code.
  • Includes documentation -- docstrings

LANGUAGE_TAXONOMY_ID = -1


@skip_unless_cms # Auto-tagging is only available in the CMS
Copy link
Contributor

Choose a reason for hiding this comment

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

@rpenido This tests are skipped on the CI action, maybe you need to delete this line?

Copy link
Contributor

Choose a reason for hiding this comment

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

And I think is happend the same with test_views. (CI action)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm..
Do you know a way to include these tests in the CMS test group? The view is not enabled in LMS, so it will fail there.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know a way to include these tests in the CMS test group? The view is not enabled in LMS, so it will fail there.

Oh I understand, I haven't found an example of it, I'm not sure if it's a good practice. @bradenmacdonald could you help us with this?

Copy link
Contributor

Choose a reason for hiding this comment

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

@ChrisChV good catch - thanks!

Unfortunately it seems like the whole openedx/features/ directory is only tested as LMS on CI. What you'll need to do is after this PR merges, open a second PR to move this whole content_tagging app from openedx/features/ to openedx/core/djangoapps/content_tagging. Then, you can edit unit-test-shards.json and put it into shard openedx-3 or openedx-4 (whichever is currently running faster on the CI).

@rpenido
Copy link
Contributor Author

rpenido commented Aug 31, 2023

Also, for the record, you need to update the testing instructions with "enable the waffle flag" to check the functionality.

Well noted @ChrisChV ! Thank you!

Copy link
Contributor

@bradenmacdonald bradenmacdonald left a comment

Choose a reason for hiding this comment

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

Looks good, thanks! I can merge tomorrow.

@rpenido rpenido changed the title feat: add auto-tagging feat: add language auto-tagging Sep 1, 2023
@bradenmacdonald
Copy link
Contributor

I see you just updated this with master. I'll hit merge once the build is green. Thanks.

@bradenmacdonald bradenmacdonald merged commit 6e28ba3 into openedx:master Sep 1, 2023
42 checks passed
@bradenmacdonald bradenmacdonald deleted the rpenido/fal-3460-content-auto-tagging-by-system-taxonomies branch September 1, 2023 18:09
@openedx-webhooks
Copy link

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

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

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] Automatically add system tags for Language (to courses and course content)
7 participants