feat: index library collections in meilisearch [FC-0062] - #35324
Conversation
|
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 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. |
4aa6025 to
af40d47
Compare
8ce6b33 to
3777566
Compare
3777566 to
885ee47
Compare
| status_cb(f"Done! {num_blocks_done} blocks indexed across {num_contexts_done} courses and libraries.") | ||
| ############## Collections ############## | ||
| status_cb("Indexing collections...") | ||
| # To reduce memory usage on large instances, split up the Collections into pages of 100 collections: |
523fab9 to
d605a5c
Compare
2d5d1f7 to
47db5d1
Compare
| openedx-events # Open edX Events from Hooks Extension Framework (OEP-50) | ||
| openedx-filters # Open edX Filters from Hooks Extension Framework (OEP-50) | ||
| openedx-learning # Open edX Learning core (experimental) | ||
| # FIXME Remove this line after release of openedx-learning |
| num_blocks_done += len(docs) | ||
|
|
||
| status_cb(f"Done! {num_blocks_done} blocks indexed across {num_contexts_done} courses and libraries.") | ||
| ############## Collections ############## |
There was a problem hiding this comment.
This is starting to get really big.
We have a lot of local variables here, but could you try to create some inner functions like config_index(), index_libraries(), index_courses(), and index_collections()?
There was a problem hiding this comment.
@rpenido Not sure if it improves readability but converted some parts to inner functions.
rpenido
left a comment
There was a problem hiding this comment.
LGTM 👍
Thank you for your work, @navinkarkera!
There is a small nit in the testing instructions.
- I tested this using the instructions from the PR, using the updated snippet:
import random
from openedx_learning.api import authoring as authoring_api
from openedx_learning.api import authoring_models
learning_packages = authoring_models.LearningPackage.objects.all()
for i in range(20):
learning_id = random.choice(learning_packages).id
authoring_api.create_collection(learning_id, f"collection_{i}", None, f'description_{i}')- I read through the code
-
I checked for accessibility issues - Includes documentation
Not blocking, but I think a small refactor in our indexing function would be great.
Also, we could add the description field to the searchable attributes. What do you think?
da19109 to
c1edbb0
Compare
|
@rpenido Thanks!
There was an update to openedx_learning after I created this PR so missed to update the instructions. Thanks!
Updated. |
rpenido
left a comment
There was a problem hiding this comment.
Thank you @navinkarkera!
@pomegranited This is ready for CC review.
c1edbb0 to
51ba403
Compare
pomegranited
left a comment
There was a problem hiding this comment.
I ran this and it works perfectly, using your test instructions, thank you @navinkarkera :)
But I've got a concern about this line that I'd like addressed before approving here.
| Fields.context_key: collection.learning_package.key, | ||
| } | ||
| # Just in case learning_package is not related to a library | ||
| if hasattr(collection.learning_package, 'contentlibrary'): |
There was a problem hiding this comment.
Is this actually the way to check if a learning package has an associated content library? It doesn't seem right..
Could you add a test for the case where a collection is associated with a learning package that is not associated with a content library, so we can be sure this logic is correct?
There was a problem hiding this comment.
@pomegranited That is a good point. I am not really sure if we have a scenario where a learning_package is not related to a library, maybe a course?
There was a problem hiding this comment.
Ya, within the context of openedx, a collection should always be related to a learning_package with a content library (courses don't have collections). I just think the hasattr mechanism is weird, and may always be true, even if collection.learning_package.contentlibrary == None.
There was a problem hiding this comment.
@pomegranited Ohh, I added a test with a learning package that is not associated with a library. The hasattr mechanism worked but like you said it is weird and may not work in case the attr is none, so updated to make use of try..catch DoesNotExist exception.
51ba403 to
0e87179
Compare
0e87179 to
7664e02
Compare
pomegranited
left a comment
There was a problem hiding this comment.
👍 Works perfectly, thank you @navinkarkera !
I also tested with your latest change on openedx-learning.
- I tested this using the PR test instructions (with one change, line 6 of the code sample should be
learning_id = random.choice(learning_packages).id) - I read through the code
-
I checked for accessibility issuesN/A - Includes documentation
-
User-facing strings are extracted for translationN/A
Co-authored-by: Jillian <jill@opencraft.com>
c38a198 to
ed66903
Compare
ed66903 to
2ac22c3
Compare
|
@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. |
|
2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production. |
|
2U Release Notice: This PR has been deployed to the edX production environment. |
1 similar comment
|
2U Release Notice: This PR has been deployed to the edX production environment. |
Description
Updates
rebuild_indexfunction to include collections for indexing in meilisearch.Supporting information
Private-ref: FAL-3786Testing instructions
tutor dev run cms ./manage.py cms reindex_studio --experimental.collectionand verify the contents of collection documents.Deadline
None