-
Notifications
You must be signed in to change notification settings - Fork 21
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 Content Library Collections signals [FC-0062] #386
feat: Add Content Library Collections signals [FC-0062] #386
Conversation
Thanks for the pull request, @yusuf-musleh! What's next?Please work through the following steps to get your changes ready for engineering review: 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. 🔘 Let us know that your PR is ready for review:Who will review my changes?This repository is currently maintained by Where can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:
When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
1f1a753
to
030965e
Compare
030965e
to
8101eb4
Compare
# .. event_name: LIBRARY_COLLECTION_CREATED | ||
# .. event_description: emitted when a content library collection is created | ||
# .. event_data: LibraryCollectionData | ||
LIBRARY_COLLECTION_CREATED = OpenEdxPublicSignal( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bradenmacdonald Are we allowed to put new signals in this repo? Or are we supposed to put them in https://github.com/openedx/openedx-events ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm actually not sure. Maybe @mariajgrimaldi can answer? What's the difference between this signals.py
and that signals.py
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I follow. This repo es openedx-events
and both signals.py files are the same.
You are definitely allowed to propose new signal definitions in this repository and the location is correct. The idea of having the signal here instead of in the edx-platform code is that plugins that will listen for the signal can include this lightweight library in their dependencies instead of requiring edx-platform all the time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol whoops, please ignore my confusion. I thought this was edx-platform :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries. Happy to address this in depth. As before, if you are planning to add a signal into edx-platform, then it would be better to write it here so plugins can use that without the large import.
However, other pattern we have seen is when a plugin defines a new signal and uses it in its own code. In that case if reuse of said signal is not a goal from the devs, then the definition can be left in the plugin as you could import that plugin as a library if you are writing a second level library/plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My apologies for the noise! I could have sworn there was a signals.py file in openedx-learning, but it's not there now, so not sure what I was on about :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, it was here in this closed PR! signals.py. I'm not going nuts.. 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍
I would prefer not to add the LIBRARY_COLLECTION_DELETED without implementing it. If we decide not to implement the delete action (or take some time to do it), this code could lead to some confusion.
I put the same comment in the edx-platform PR. Feel free to push back if you think differently!
@rpenido We will definitely need to implement deleting collections as part of this MVP so we might as well add the event now to save another PR. |
@ormsbee Do you think it makes sense to have these hooks in openedx-events called e.g. @yusuf-musleh I'm also wondering if we should have a separate event for when the contents of a collection are updated, i.e. a component is added to the collection or a component is modified within the collection. That case can be handled differently in some cases. Or a field like Keep in mind I'm not asking for these changes, just proposing them and wondering if this makes sense. |
I'm inclined to start with signals in |
I disagree.. I don't think events should be used for synchronous actions like this -- they're for notifying other areas of the code about something that happened, possibly via the event bus. I think if we want a mechanism for rolling back commits, it should be some kind of hook. But I'm less sure about where these events should live.. The argument for openedx-events being separate from edx-platform is obvious, because no one wants to import edx-platform just to receive some events. But since you'll need the openedx-learning APIs to access any objects indicated by the events, you have to import it anyway. Does having all the events in one place make it easier to document them? If so, they should continue to live in openedx-events.
I'm doing three things for openedx/modular-learning#227 when adding/removing components:
|
I'm not thrilled about using the TAG event here. Today, tagging and collections are completely decoupled. We could deactivate tags and still have collections. This will not break the collections as we implement it, but I still find it odd to use the tags events, functions and properties in the index with the tagging feature disabled.
If we pass the changed component list in the As a bonus, we can do a single index update (instead of one call for each component in the Does this make sense? |
@bradenmacdonald @pomegranited I like the idea of adding a Depending on how the collection was updated, whether its the collection itself or its contents, there will likely be more than one reason, eg: when a component is added to a collection (reason 1) the modified date for the collection is updated (reason 2), as @pomegranited mentioned. To avoid emitting multiple events, I think we can have the [
{
"type": "metadata",
"change": "modified updated",
"value": "..."
},
{
"type": "content",
"change": "components changed"
"value": ["cmp1", "cmp2", "..."],
},
] This is also great because it gives us more flexibility on what type of
That is still the case, that they are decoupled. There was a discussion in the discovery about reusing this event (and it's logic) to update meillisearch index for the content object when either the content objects tags or it's collections changed. The name of the event now would be a bit confusing, since technically now it's not just the content object TAGS are being changed, but more general than that. I can see how this can get confusing though. It might be interesting to revisit the discussion of possibly renaming or creating a new more general event, eg: |
Re event
Actually, emitting a single I get that using the But I'm ok with whatever @bradenmacdonald decides. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I'm good with these events -- both where they live, and the data they contain. We can add more detail later if the use case arises.
- I tested this as part of feat: Add Library Collections REST endpoints [FC-0062] edx-platform#35321
- I read through the code
-
I checked for accessibility issuesN/A - Includes documentation
- User-facing strings are extracted for translation
Just to clarify, it would certainly be a batch of changes, but they can be done in only one meilisearch API call, with less overhead. |
I do still like the idea of adding Renaming the TAGS event to I don't have a strong opinion on these events though. |
@bradenmacdonald Should the |
@pomegranited I would prefer to send them from openedx-learning so we only implement it once, and they're consistent - but that assumes we have an easy way to indicate what type of collection it is in the event (i.e. that it's a library collection). And I'm not sure if Learning Core "knows" about that. So if that's not easy to do, then I guess we'll emit them from platform. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Thank you for your work, @yusuf-musleh !
- I tested this using the instructions from feat: Add Library Collections REST endpoints [FC-0062] edx-platform#35321
- I read through the code
-
I checked for accessibility issues - Includes documentation
Sorry, a I'm a bit premature here, we have one more issue to sort out first. |
74af7c5
to
b6ab399
Compare
…CT_ASSOCIATIONS_CHANGED #66 * feat: adds event CONTENT_OBJECT_ASSOCIATOONS_CHANGED and ContentObjectChangedData, which has a field for indicating what has changed. * chore: updates changelog
…library-collections-signals
6f45aa4
to
18a3544
Compare
Ok! @openedx/hooks-extension-framework this is now ready for your eyes, thank you! FYI I'm unable to update the PR description here, but this PR also includes Collection-related changes from open-craft#66. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yusuf-musleh @pomegranited LGTM, left some suggestions which you can ignore if you disagree.
# .. event_description: emitted when an object's associations are changed, e.g tags, collections | ||
# .. event_data: ContentObjectData | ||
CONTENT_OBJECT_ASSOCIATIONS_CHANGED = OpenEdxPublicSignal( | ||
event_type="org.openedx.content_authoring.content.object.associations.changed.v1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
event_type="org.openedx.content_authoring.content.object.associations.changed.v1", | |
event_type="org.openedx.content_authoring.content_object.associations.changed.v1", |
Thank you for your review @navinkarkera ! I believe I've addressed them, and so if you're happy, feel free to merge and create a new release :) |
Description: This PR adds new signals for Content Library Collections.
The following new signals will be added:
LIBRARY_COLLECTION_CREATED
- emitted when new library collection is createdLIBRARY_COLLECTION_UPDATED
- emitted when a library collection is updatedLIBRARY_COLLECTION_DELETED
- emitted when a library collection is deletedISSUE: openedx/modular-learning#226
Dependencies: Needed for openedx/edx-platform#35321
Merge deadline: List merge deadline (if any)
Installation instructions: List any non-trivial installation
instructions.
Testing instructions:
Make sure tests are passing, and follow testing instructions in openedx/edx-platform#35321
Reviewers:
Merge checklist:
Post merge:
finished.
Author concerns: List any concerns about this PR - inelegant
solutions, hacks, quick-and-dirty implementations, concerns about
migrations, etc.