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: set collections for a library component [FC-0062] #35600

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

navinkarkera
Copy link
Contributor

@navinkarkera navinkarkera commented Oct 7, 2024

Description

Adds api to set/update collections on a given component. Related to openedx/frontend-app-authoring#1373

Supporting information

Depends on:

Testing instructions

See openedx/frontend-app-authoring#1373 for instructions.

Deadline

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

Other information

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Oct 7, 2024
@openedx-webhooks
Copy link

openedx-webhooks commented Oct 7, 2024

Thanks for the pull request, @navinkarkera!

What's next?

Please work through the following steps to get your changes ready for engineering review:

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.

🔘 Provide context

To 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:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads

🔘 Get a green build

If 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 @openedx/wg-maintenance-edx-platform. Tag them in a comment and let them know that your changes are ready for review.

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:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@@ -824,7 +824,7 @@ openedx-filters==1.10.0
# -r requirements/edx/kernel.in
# lti-consumer-xblock
# ora2
openedx-learning==0.13.1
openedx-learning @ git+https://github.com/open-craft/openedx-learning@navin/component-collection-api
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: update this after merging openedx/openedx-learning#238 releasing new version of openedx-learning

@@ -1373,7 +1373,7 @@ openedx-filters==1.10.0
# -r requirements/edx/testing.txt
# lti-consumer-xblock
# ora2
openedx-learning==0.13.1
openedx-learning @ git+https://github.com/open-craft/openedx-learning@navin/component-collection-api
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: update this after merging openedx/openedx-learning#238 releasing new version of openedx-learning

@@ -983,7 +983,7 @@ openedx-filters==1.10.0
# -r requirements/edx/base.txt
# lti-consumer-xblock
# ora2
openedx-learning==0.13.1
openedx-learning @ git+https://github.com/open-craft/openedx-learning@navin/component-collection-api
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: update this after merging openedx/openedx-learning#238 releasing new version of openedx-learning

@@ -1034,7 +1034,7 @@ openedx-filters==1.10.0
# -r requirements/edx/base.txt
# lti-consumer-xblock
# ora2
openedx-learning==0.13.1
openedx-learning @ git+https://github.com/open-craft/openedx-learning@navin/component-collection-api
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: update this after merging openedx/openedx-learning#238 releasing new version of openedx-learning

@navinkarkera navinkarkera changed the title feat: set collections for a library component feat: set collections for a library component [FC-0062] Oct 8, 2024
Comment on lines 1278 to 1299
from ..content.search.tasks import update_library_collection_index_doc
for collection in affected_collections:
update_library_collection_index_doc.delay(str(library_key), collection.key)
Copy link
Contributor Author

@navinkarkera navinkarkera Oct 8, 2024

Choose a reason for hiding this comment

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

Trigger collection indexing asynchronously instead of relying on sync indexing via signals. See https://github.com/openedx/openedx-learning/pull/238/files#diff-50734dffd9d06d0a9cbc318f1b298dddd25968d064b515d716dc7a0023b7190bR660-R666

You can test the performance improvement by setting CELERY_ALWAYS_EAGER = False in cms/envs/devstack.py.

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't notice a performance improvement here (maybe I tested it wrong?).

This call is always in the 600ms - 2500ms range (which I agree is not good), but I don't think we should call the search tasks directly here. Maybe add another parameter to the LIBRARY_COLLECTION_UPDATED event to define beforehand whether the task should run sync or async.

@bradenmacdonald, can you give us your insight here? I don't want to make things complicated near the version cut.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe add another parameter to the LIBRARY_COLLECTION_UPDATED event to define beforehand whether the task should run sync or async.

Yes, that is better. I was probably feeling lazy to update the event as part of this ticket but seems like it is unavoidable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't notice a performance improvement here (maybe I tested it wrong?).

You need to add and remove multiple collections for a component to see the difference. Also set CELERY_ALWAYS_EAGER = False to run celery tasks in worker.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rpenido Updated LibraryCollectionData to include a field call lazy and used it here instead.

@navinkarkera navinkarkera marked this pull request as ready for review October 8, 2024 12:13
@rpenido rpenido force-pushed the navin/component-collection-api branch from 93f436d to eb7d2d1 Compare October 8, 2024 13:54
Copy link
Contributor

@rpenido rpenido left a 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, @navinkarkera!

I added a small PR to circumvent the meilisearch bug below. It is missing some tests fixes:

Note
We have an unused endpoint that we created beforehand for handling components/collections here:

def update_components(self, request, *args, **kwargs) -> Response:
(and some API methods too). I'm not sure if we should remove it right away. It could be helpful if we implement the "Remove from this collection" action in the three dot menu.

Comment on lines 1278 to 1299
from ..content.search.tasks import update_library_collection_index_doc
for collection in affected_collections:
update_library_collection_index_doc.delay(str(library_key), collection.key)
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't notice a performance improvement here (maybe I tested it wrong?).

This call is always in the 600ms - 2500ms range (which I agree is not good), but I don't think we should call the search tasks directly here. Maybe add another parameter to the LIBRARY_COLLECTION_UPDATED event to define beforehand whether the task should run sync or async.

@bradenmacdonald, can you give us your insight here? I don't want to make things complicated near the version cut.

@navinkarkera navinkarkera force-pushed the navin/component-collection-api branch 3 times, most recently from ce7f906 to 3e889a9 Compare October 9, 2024 11:08
Using `get_collection_components` does not work in case of post_remove
as the component is already removed from collection and we don't really
need additional filtering as we already have pk_set from the signal.
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
Status: Needs Triage
Development

Successfully merging this pull request may close these issues.

3 participants