Skip to content

feat: hook xblock publish, delete and duplicate openedx-events - #31350

Merged
sameenfatima78 merged 6 commits into
openedx:masterfrom
open-craft:navin/hook-xblock-events
Feb 14, 2023
Merged

feat: hook xblock publish, delete and duplicate openedx-events#31350
sameenfatima78 merged 6 commits into
openedx:masterfrom
open-craft:navin/hook-xblock-events

Conversation

@navinkarkera

@navinkarkera navinkarkera commented Nov 28, 2022

Copy link
Copy Markdown
Contributor

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
Copy Markdown

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.

@navinkarkera
navinkarkera force-pushed the navin/hook-xblock-events branch from 8aba443 to 0de012b Compare November 28, 2022 14:11
@mariajgrimaldi

Copy link
Copy Markdown
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
Copy Markdown
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.

@tecoholic tecoholic 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.

@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?

Comment thread xmodule/modulestore/mixed.py Outdated
@tecoholic

tecoholic commented Dec 2, 2022

Copy link
Copy Markdown
Contributor

@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?

Comment thread xmodule/modulestore/mixed.py Outdated
@navinkarkera
navinkarkera force-pushed the navin/hook-xblock-events branch from 0de012b to 8af8dee Compare December 5, 2022 12:34
@mariajgrimaldi

Copy link
Copy Markdown
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
Copy Markdown
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
navinkarkera force-pushed the navin/hook-xblock-events branch from 8af8dee to a2c935d Compare December 5, 2022 14:53
@navinkarkera

Copy link
Copy Markdown
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
Copy Markdown
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
navinkarkera force-pushed the navin/hook-xblock-events branch from a2c935d to 76a9e31 Compare December 6, 2022 09:33
@navinkarkera

Copy link
Copy Markdown
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.

@tecoholic tecoholic 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.

@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
navinkarkera force-pushed the navin/hook-xblock-events branch from 123abd5 to c03d55a Compare December 15, 2022 07:12
@navinkarkera

Copy link
Copy Markdown
Contributor Author

@mariajgrimaldi Gentle reminder.

@mariajgrimaldi

mariajgrimaldi commented Dec 15, 2022

Copy link
Copy Markdown
Member

@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
Copy Markdown

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
Copy Markdown
Member

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

@mariajgrimaldi

mariajgrimaldi commented Feb 6, 2023

Copy link
Copy Markdown
Member

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
Copy Markdown
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

mariajgrimaldi commented Feb 6, 2023

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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
navinkarkera force-pushed the navin/hook-xblock-events branch from cd28c4c to 4f59faf Compare February 14, 2023 06:37
@navinkarkera

Copy link
Copy Markdown
Contributor Author

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

@navinkarkera
navinkarkera force-pushed the navin/hook-xblock-events branch from 4f59faf to df9f88c Compare February 14, 2023 13:33

@mariajgrimaldi mariajgrimaldi left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown

@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
Copy Markdown
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
Copy Markdown
Contributor

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

@dianakhuang

Copy link
Copy Markdown
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

mariajgrimaldi commented Feb 21, 2023

Copy link
Copy Markdown
Member

@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
Copy Markdown
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.

9 participants