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: xblock deleted and duplicated event handlers #127

Merged
merged 1 commit into from
Dec 15, 2022

Conversation

navinkarkera
Copy link
Contributor

@navinkarkera navinkarkera commented Nov 30, 2022

Description

Implement signals and handlers for xblock delete and duplicated events.

Related MRs:

Merge checklist:

  • Any new requirements are in the right place (do not manually modify the requirements/*.txt files)
    • make upgrade && make requirements have been run to regenerate requirements
  • ./manage.py makemigrations has been run
    • Checkout the Database Migration Confluence page for helpful tips on creating migrations.
    • Note: This must be run if you modified any models.
      • It may or may not make a migration depending on exactly what you modified, but it should still be run.
  • Version bumped
  • Changelog record added

Post merge:

  • Tag pushed and a new version released
    • Note: Assets will be added automatically. You just need to provide a tag (should match your version number) and title and description.
  • After versioned build finishes in GitHub Actions, verify version has been pushed to PyPI
    • Each step in the release build has a condition flag that checks if the rest of the steps are done and if so will deploy to PyPi.
      (so basically once your build finishes, after maybe a minute you should see the new version in PyPi automatically (on refresh))
  • PR created in course-discovery to upgrade dependencies (including taxonomy-connector)
    • This must be done after the version is visible in PyPi as make upgrade in course-discovery will look for the latest version in PyPi.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Nov 30, 2022
@openedx-webhooks
Copy link

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

Copy link
Contributor

@tecoholic tecoholic left a comment

Choose a reason for hiding this comment

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

@navinkarkera I have some design questions and suggested some changes. Kindly see the inline comments.

@@ -8,3 +8,5 @@
UPDATE_COURSE_SKILLS = Signal()
UPDATE_PROGRAM_SKILLS = Signal()
UPDATE_XBLOCK_SKILLS = Signal()
XBLOCK_DELETED = Signal()
XBLOCK_DUPLICATED = Signal()
Copy link
Contributor

Choose a reason for hiding this comment

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

I am unsure about these signals for the reason I mentioned in the course discovery PR and also because, these signals cannot be actually emitted by the taxonomy connector for other apps to listen.

What the taxonomy connector could possibly emit are DELETE_XBLOCK_SKILLS, DUPLICATE_XBLOCK_SKILLS at the start of the processing or XBLOCK_SKILLS_DELETED, XBLOCK_SKILLS_DUPLICATED at the end of the processing depending on the kind of signal that's emitted.

Again, it seems the only reason for these signals to be defined here, is to allow for them to be handled in handlers.py. I would suggest we think if this is actually necessary. Wouldn't it be better to not define them at all and do the following in handlers.py?

from .signals import (
    UPDATE_COURSE_SKILLS,
    UPDATE_PROGRAM_SKILLS,
    UPDATE_XBLOCK_SKILLS,
-    XBLOCK_DELETED,
-    XBLOCK_DUPLICATED,
)
+ from openedx_events.content_authoring.signals import XBLOCK_DELETED, XBLOCK_DUPLICATED, XBLOCK_PUBLISHED

I guess the answer again is in the question, why can't we add openedx-events as a dependency to the taxonomy-connector.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tecoholic I don't have a strong reason to not include openedx-events as a dependency to taxonomy-connector. openedx-events is already added as a dependency in course-discovery through event-bus-kafka so I did not include it here. This also keeps taxonomy-connector independent of openedx-events if that matters at all. I think we can ask @sameenfatima78 for her advice here.

Copy link
Member

Choose a reason for hiding this comment

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

Discussed this with @saleem-latif and while we both agree with using standardized signals as suggested by @tecoholic, we are still unsure about how taxonomy-connector would listen these events if these signals are not being fired from course-discovery? But other than that, installing this new dependency in taxonomy-connector won't be an issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sameenfatima78

we are still unsure about how taxonomy-connector would listen these events if these signals are not being fired from course-discovery

In the current design, they are fired from course-discovery as implemented in openedx/course-discovery#3710. But if we directly include openedx-events as dependency in taxonomy, it is not required. The events fired in openedx/edx-platform#31350 can be directly handled here.

Copy link
Contributor Author

@navinkarkera navinkarkera Dec 6, 2022

Choose a reason for hiding this comment

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

@tecoholic @sameenfatima78 Updated to include openedx-events directly as dependency and handle xblock signals. Please review.

Please re-run the failed CI job, the test has nothing to do with this MR (it is using random values for primary keys which fails sometimes due to not being unique).

taxonomy/utils.py Show resolved Hide resolved
taxonomy/utils.py Show resolved Hide resolved
taxonomy/tasks.py Outdated Show resolved Hide resolved
taxonomy/tasks.py Outdated Show resolved Hide resolved
Copy link
Contributor

@tecoholic tecoholic left a comment

Choose a reason for hiding this comment

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

@navinkarkera 👍 I found one place where the docstring needs a correction. Other than that this looks great.

  • I tested this: relying on the unit tests here as there aren't any testing instructions
  • I read through the code
  • I checked for accessibility issues - NA
  • Includes documentation

PS: You have mentioned that the CI Error, I ran the unit tests locally and everything seems to pass. My guess is the Faker.rand_int might have generated the same ID in the failing test.

Copy link
Member

@sameenfatima78 sameenfatima78 left a comment

Choose a reason for hiding this comment

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

Left some feedback, also the coverage seems to be failing.

taxonomy/utils.py Outdated Show resolved Hide resolved
taxonomy/utils.py Show resolved Hide resolved
taxonomy/utils.py Show resolved Hide resolved
@navinkarkera
Copy link
Contributor Author

navinkarkera commented Dec 12, 2022

Left some feedback, also the coverage seems to be failing.

The changes in this MR has 100% coverage as seen in coverage:patch section of CI.
Sorry, got confused with a different MR. Will fix it.

Implements handlers for openedx-events XBLOCK_PUBLISHED, XBLOCK_DELETED,
and XBLOCK_DUPLICATED.

chore: bump version and update changelog

Update taxonomy/signals/handlers.py

Co-authored-by: Arunmozhi <tecoholic@users.noreply.github.com>
@navinkarkera
Copy link
Contributor Author

@sameenfatima78 Updated MR. Also implemented tests for missing lines but the check is still failing here.
If we open the link for pull request in codecov, it shows that 100% coverage. So not sure what ti do here.

image

@sameenfatima78
Copy link
Member

@sameenfatima78 Updated MR. Also implemented tests for missing lines but the check is still failing here. If we open the link for pull request in codecov, it shows that 100% coverage. So not sure what ti do here.

image

@navinkarkera Hmm, I remember there was a known issue where coverage only gets calculated for the first commit, the rest of the commits are ignored by CI. This seems to be the case here I guess. You can merge the PR for now and I'll file a ticket in our backlog to look into this issue.

@navinkarkera
Copy link
Contributor Author

You can merge the PR for now and I'll file a ticket in our backlog to look into this issue.

@sameenfatima78 I don't have appropriate rights to merge. 🚫

@sameenfatima78
Copy link
Member

You can merge the PR for now and I'll file a ticket in our backlog to look into this issue.

@sameenfatima78 I don't have appropriate rights to merge. 🚫

I'll merge it for you. Just wanted to confirm if all changes are finalized.

@navinkarkera
Copy link
Contributor Author

I'll merge it for you. Just wanted to confirm if all changes are finalized.

@sameenfatima78 Confirmed. 👍

@sameenfatima78 sameenfatima78 merged commit c7e8dc9 into openedx:master Dec 15, 2022
@openedx-webhooks
Copy link

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

@navinkarkera navinkarkera deleted the navin/events-handler branch December 15, 2022 10:06
@HammadAhmadWaqas
Copy link
Member

@navinkarkera
Version change is missing in init.py from this PR. So, It was never deployed in course-discovery before.
Today I created a version bump PR in course-discovery which includes your code and found out there is a problem with code merged in this PR. Could you please have a look?

Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/edx/app/discovery/discovery/.tox/py38-django32/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/edx/app/discovery/discovery/.tox/py38-django32/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute
    django.setup()
  File "/edx/app/discovery/discovery/.tox/py38-django32/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/edx/app/discovery/discovery/.tox/py38-django32/lib/python3.8/site-packages/django/apps/registry.py", line 122, in populate
    app_config.ready()
  File "/edx/app/discovery/discovery/.tox/py38-django32/lib/python3.8/site-packages/taxonomy/apps.py", line 25, in ready
    from .signals import handlers  # pylint: disable=unused-import,import-outside-toplevel
  File "/edx/app/discovery/discovery/.tox/py38-django32/lib/python3.8/site-packages/taxonomy/signals/handlers.py", line 8, in <module>
    from openedx_events.content_authoring.data import DuplicatedXBlockData, XBlockData
ImportError: cannot import name 'DuplicatedXBlockData' from 'openedx_events.content_authoring.data' (/edx/app/discovery/discovery/.tox/py38-django32/lib/python3.8/site-packages/openedx_events/content_authoring/data.py)

@navinkarkera
Copy link
Contributor Author

@HammadAhmadWaqas Apologies for the confusion. I missed to update the dependency in base.in, instead updated dev.txt and test.txt directly to point to the version of openedx-events. This issue should be fixed by #129 as it updates init.py as well as the requirements properly. cc: @sameenfatima78

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.

5 participants