Skip to content

Conversation

@rpenido
Copy link
Contributor

@rpenido rpenido commented Apr 8, 2025

Description

This PR adds support for adding Containers to Collections.

ToDo:

Supporting information

Testing instructions


Private ref: FAL-4111

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Apr 8, 2025
@openedx-webhooks
Copy link

openedx-webhooks commented Apr 8, 2025

Thanks for the pull request, @rpenido!

This repository is currently maintained by @openedx/wg-maintenance-edx-platform.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are 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.


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.

@github-project-automation github-project-automation bot moved this to Needs Triage in Contributions Apr 8, 2025
@rpenido rpenido force-pushed the rpenido/fal-4111/units-collections branch 3 times, most recently from 111684c to 3a7ee98 Compare April 9, 2025 00:37
@rpenido rpenido changed the title feat: container collections support feat: container collections support [FC-0083] Apr 9, 2025
@rpenido rpenido force-pushed the rpenido/fal-4111/units-collections branch from 3a7ee98 to b0854a1 Compare April 9, 2025 11:29
@rpenido rpenido closed this Apr 9, 2025
@github-project-automation github-project-automation bot moved this from Needs Triage to Done in Contributions Apr 9, 2025
@rpenido rpenido reopened this Apr 9, 2025
@rpenido rpenido closed this Apr 9, 2025
@rpenido rpenido reopened this Apr 9, 2025
@rpenido rpenido force-pushed the rpenido/fal-4111/units-collections branch 7 times, most recently from 0f63f14 to 88fdc7f Compare April 9, 2025 22:45
@rpenido rpenido force-pushed the rpenido/fal-4111/units-collections branch 5 times, most recently from c372da4 to 8e80240 Compare April 10, 2025 15:26
@rpenido rpenido changed the title feat: container collections support [FC-0083] feat: collections support for containers [FC-0083] Apr 10, 2025
@rpenido rpenido force-pushed the rpenido/fal-4111/units-collections branch 2 times, most recently from fa6bc82 to ffcc45d Compare April 10, 2025 15:58
@rpenido rpenido force-pushed the rpenido/fal-4111/units-collections branch 2 times, most recently from 353d2fd to 8255a8d Compare April 10, 2025 23:18
@rpenido rpenido force-pushed the rpenido/fal-4111/units-collections branch from 8255a8d to 3ad01b2 Compare April 10, 2025 23:41
@rpenido rpenido marked this pull request as ready for review April 10, 2025 23:48
Copy link
Contributor

@pomegranited pomegranited left a comment

Choose a reason for hiding this comment

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

@rpenido This is working great, with the exception of when I "undo delete" (aka restore) a Unit that is part of a Collection.

Have left a bunch of nits, but I love the refactoring you did! Makes things clearer, and you're right, better to do now than later.

Would like to review again once my comments are addressed, but this is looking great.

Comment on lines 355 to 356
else:
return result
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I'd either remove this else entirely (and let control just fall through), or raise an error about an unexpected OpaqueKey type here?

Suggested change
else:
return result

Copy link
Contributor Author

@rpenido rpenido Apr 12, 2025

Choose a reason for hiding this comment

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

You're right! Fixed here: 20c307b

Comment on lines 782 to 783
library_key: LibraryLocatorV2,
collection_key: str,
Copy link
Contributor

Choose a reason for hiding this comment

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

#36476 started using a single LibraryCollectionLocator key wherever we could, instead of passing the library_key with the collection_key. Can you do the same thing here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

Comment on lines +372 to +384
def to_internal_value(self, value: str) -> OpaqueKey:
"""
Returns a UsageKeyV2 or a LibraryContainerLocator from the string value.
Raises ValidationError if invalid UsageKeyV2 or LibraryContainerLocator.
"""
try:
return UsageKeyV2.from_string(value)
except InvalidKeyError:
try:
return LibraryContainerLocator.from_string(value)
except InvalidKeyError as err:
raise ValidationError from err
Copy link
Contributor

Choose a reason for hiding this comment

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

If we genuinely don't care what kind of OpaqueKey we deserialize here, this can be simpler:

Suggested change
def to_internal_value(self, value: str) -> OpaqueKey:
"""
Returns a UsageKeyV2 or a LibraryContainerLocator from the string value.
Raises ValidationError if invalid UsageKeyV2 or LibraryContainerLocator.
"""
try:
return UsageKeyV2.from_string(value)
except InvalidKeyError:
try:
return LibraryContainerLocator.from_string(value)
except InvalidKeyError as err:
raise ValidationError from err
def to_internal_value(self, value: str) -> OpaqueKey:
"""
Returns an OpaqueKey from the string value.
Raises ValidationError if invalid OpaqueKey.
"""
try:
return OpaqueKey.from_string(value)
except InvalidKeyError as err:
raise ValidationError from err

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

That's cool -- then we probably don't need to duplicate these checks in the serializer too, right?


@shared_task(base=LoggedTask, autoretry_for=(MeilisearchError, ConnectionError))
@set_code_owner_attribute
def update_library_containers_collections(library_key_str: str, collection_key: str) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

#36476 started using a single LibraryCollectionLocator key wherever we could, instead of passing the library_key with the collection_key. Can you do the same thing here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

@rpenido rpenido force-pushed the rpenido/fal-4111/units-collections branch from c712133 to 881292f Compare April 12, 2025 00:42
@rpenido rpenido marked this pull request as draft April 12, 2025 04:48
@rpenido rpenido requested a review from pomegranited April 12, 2025 04:49
Copy link
Contributor

@pomegranited pomegranited left a comment

Choose a reason for hiding this comment

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

👍 Working perfectly thank you @rpenido !

  • I tested this on my tutor dev stack by adding and removing units to/from collections, deleting a unit that's in a collection, and restoring that unit to ensure the collection link is also restored.
  • I read through the code
  • I checked for accessibility issues by using my keyboard to navigate
  • Includes documentation -- code comments
  • User-facing strings are extracted for translation N/A

Copy link
Contributor

@navinkarkera navinkarkera left a comment

Choose a reason for hiding this comment

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

@rpenido Nice work! 👍

  • I tested this: (Used frontend to add/remove/update container collections)
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation

@rpenido rpenido marked this pull request as ready for review April 15, 2025 15:34
@ChrisChV ChrisChV merged commit 1047ed4 into openedx:master Apr 15, 2025
49 checks passed
@ChrisChV ChrisChV deleted the rpenido/fal-4111/units-collections branch April 15, 2025 18:12
@edx-pipeline-bot
Copy link
Contributor

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

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

tonybusa pushed a commit to tonybusa/edx-platform that referenced this pull request Apr 23, 2025
Adds support for adding Containers to Collections.
UsamaSadiq pushed a commit that referenced this pull request May 14, 2025
Adds support for adding Containers to Collections.
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

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants