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: hook xblock publish, delete and duplicate openedx-events #31350

Merged
merged 6 commits into from
Feb 14, 2023

Conversation

navinkarkera
Copy link
Contributor

@navinkarkera navinkarkera commented Nov 28, 2022

Description

openedx-events: XBLOCK_DELETED, XBLOCK_DUPLICATED and XBLOCK_PUBLISHED are hooked into appropriate functions to publish xblock changes.

These signals are implemented in openedx/openedx-events#143 to handle changes to xblocks in taxonomy-connector/course-discovery.

Supporting information

Testing instructions

  1. Add below snippet somewhere, for example in cms/djangoapps/contentstore/signals/handlers.py
from openedx_events.content_authoring.signals import XBLOCK_PUBLISHED, XBLOCK_DELETED, XBLOCK_DUPLICATED
XBLOCK_PUBLISHED.connect(lambda **x: print(x))
XBLOCK_DELETED.connect(lambda **x: print(x))
XBLOCK_DUPLICATED.connect(lambda **x: print(x))
  1. Start lms and studio and monitor studio logs using make lms-up studio-up studio-logs
  2. Publish, delete and duplicate some xblocks in studio and related signals should be printed in logs.

Deadline

"None" if there's no rush, or provide a specific date or event (and reason) if there is one.

Pre-merge checklist:

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Nov 28, 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.

@mariajgrimaldi
Copy link
Member

You don't have to write a step-by-step guide of how to test the events with receivers and all, but at least you could describe how to trigger them, so it's easier to test.

@navinkarkera
Copy link
Contributor Author

@mariajgrimaldi Sorry, I am not in front of my system now but I'll soon figure out steps to test and post it.

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 Changes look good to me at first pass. But the CI is failing. But it doesn't seem to connected to the changes in this PR, but instead some dependencies in enterprise. Can you kindly rebase this to master and see if the CI passes?

xmodule/modulestore/mixed.py Show resolved Hide resolved
@tecoholic
Copy link
Contributor

tecoholic commented Dec 2, 2022

@mariajgrimaldi What would be right way to test the values these events get, assuming @navinkarkera adds the instructions on how to trigger these events? Do we have something like a openedx-events-debugger package that we can just install, to log all the events and the event data?

@mariajgrimaldi
Copy link
Member

@tecoholic: we added a line that logs the event responses for just triggers when in a production environment, so it's not that useful for dev (I'll make a mental note on that). What a usually do is create a dummy receiver that logs the input data, that could work here.

@tecoholic
Copy link
Contributor

@mariajgrimaldi Thank you for the dummy receiver suggestion. I will try to add something like that for testing.

@navinkarkera Everything looks good to me. I will test this tomorrow.

@navinkarkera
Copy link
Contributor Author

@mariajgrimaldi @tecoholic I have added test instructions in description. While doing so I found that publish signal is only emitted for vertical and higher level blocks like sequential. I expected it to publish each xblock in vertical separately.

We want to be notified about the published vertical and video blocks. If this is not possible here, we would need to handle this in consumer. I'll investigate bit more and come back on this.

@tecoholic
Copy link
Contributor

@navinkarkera

I have added test instructions in description. While doing so I found that publish signal is only emitted for vertical and higher level blocks like sequential. I expected it to publish each xblock in vertical separately.

This is understandable given the smallest content we can publish from the Studio is a Unit (VerticalBlock). Good luck with your testing.

@navinkarkera
Copy link
Contributor Author

@tecoholic

This is understandable given the smallest content we can publish from the Studio is a Unit (VerticalBlock). Good luck with your testing.

Makes sense. We are now handling this in the xblock provider implemented in course-discovery ( ref MR: openedx/course-discovery#3692 ). It fetches all vertical and video blocks under the published item and processes it.

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 👍 LGTM

  • I tested this: Verified that the signals are being sent when changes are made in studio
  • I read through the code
  • I checked for accessibility issues - NA
  • Includes documentation

@navinkarkera
Copy link
Contributor Author

@mariajgrimaldi Gentle reminder.

@mariajgrimaldi
Copy link
Member

mariajgrimaldi commented Dec 15, 2022

@navinkarkera: I'm out until Dec 20, I'll check on this when I'm back. Sorry for the delay.

Unless @felipemontoya can pick this up.

@navinkarkera navinkarkera force-pushed the navin/hook-xblock-events branch 2 times, most recently from 69c18fc to 63e148c Compare December 22, 2022 14:58
@mphilbrick211
Copy link

Friendly ping on this @mariajgrimaldi :)

@navinkarkera navinkarkera force-pushed the navin/hook-xblock-events branch 3 times, most recently from 99d012d to cd28c4c Compare February 6, 2023 08:54
@mariajgrimaldi
Copy link
Member

Hello! I was out on vacation. I'll be checking these comments right away :)

@mariajgrimaldi
Copy link
Member

mariajgrimaldi commented Feb 6, 2023

hello @mphilbrick211: should someone from Enterprise Markhors approve this PR also? According to this comment, they're also involved in this work, and we'll probably need their support for merging.
@sameenfatima78 could you give us a hand?

@mariajgrimaldi
Copy link
Member

@navinkarkera: exciting work! Thanks for all the info context. I'm happy with the state of the PR and all the discussion surrounding it. Do you know if there is anything else that should be addressed?

@mariajgrimaldi
Copy link
Member

mariajgrimaldi commented Feb 6, 2023

I reran the tests, but they kept failing. It seems related to the runner / system itself 🤔.

Update: it seems to be working now :)

@sameenfatima78
Copy link
Member

@sameenfatima78 could you give us a hand?

@mariajgrimaldi Sure, I'll let my team know and will also take a look myself.

@navinkarkera
Copy link
Contributor Author

@navinkarkera: exciting work! Thanks for all the info context. I'm happy with the state of the PR and all the discussion surrounding it. Do you know if there is anything else that should be addressed?

@mariajgrimaldi Thanks! Nothing to add from my side.

@navinkarkera
Copy link
Contributor Author

@mariajgrimaldi Updated the MR. It should be ready for merge, let me know if something is missing.

Copy link
Member

@mariajgrimaldi mariajgrimaldi left a comment

Choose a reason for hiding this comment

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

I'll contact the team in charge, so they merge when convenient. Thank you again for your work!

@sameenfatima78 sameenfatima78 merged commit 4697adc into openedx:master Feb 14, 2023
@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.

@edx-pipeline-bot
Copy link
Contributor

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

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

@dianakhuang
Copy link
Contributor

Hi! Would it be possible to put these events behind a feature flag for now? edx.org isn't set up for them, and we're seeing some errors because of it.

@mariajgrimaldi
Copy link
Member

mariajgrimaldi commented Feb 21, 2023

@dianakhuang: hey there! thanks for the report. @sameenfatima78 @navinkarkera what do you say?

We could do something like:

    if settings.FEATURES["ENABLE_SEND_XBLOCK_EVENTS_OVER_BUS"]:
        get_producer().send(
            signal=XBLOCK_DUPLICATED, topic='xblock-duplicated',
            event_key_field='xblock_info.usage_key', event_data={'xblock_info': kwargs['xblock_info']},
            event_metadata=kwargs['metadata'],
        )

Let me know if you need help with this! I'd be glad to help.

@navinkarkera
Copy link
Contributor Author

@mariajgrimaldi Thanks, created #31813. Please review and merge.

cc: @sameenfatima78 @dianakhuang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
event-bus Relating to the event bus project 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.

None yet

9 participants