Add ContainerTypes to openedx-core [FC-0117]#495
Add ContainerTypes to openedx-core [FC-0117]#495bradenmacdonald wants to merge 13 commits intomainfrom
Conversation
|
Thanks for the pull request, @bradenmacdonald! This repository is currently maintained by 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 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. DetailsWhere 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. |
a0a83aa to
4e22996
Compare
cc4b63e to
bc3e931
Compare
|
So this is definitely not something that needs to roll into this work, but in case it's relevant: Now that everything is in applets and publishing dependencies are explicitly modeled, I think container models and logic can move out of |
7bed463 to
0c75f56
Compare
|
@ormsbee As you expected it was quite easy to do, so I've included that change in this PR. I just have to make the corresponding edx-platform changes, and clean up a few small loose ends, and this will be ready. |
37757d1 to
9430410
Compare
9430410 to
92f8a1b
Compare
| # If the version has a container version, add its children | ||
| container_table = tomlkit.table() | ||
| children = publishing_api.get_container_children_entities_keys(version.containerversion) | ||
| children = containers_api.get_container_children_entities_keys(version.containerversion) | ||
| container_table.add("children", children) | ||
| version_table.add("container", container_table) |
There was a problem hiding this comment.
I noticed that this if branch of toml_publishable_entity_version is not covered by any tests. I think we need a lot more test coverage of the backup/restore format.
92f8a1b to
6e60108
Compare
Claude explanation: In `_create_side_effects_for_change_log`, `change_log.records.all()` has no `ORDER BY`. On SQLite, this returns records in insertion order (PK order) — which is root-first, since `publish_from_drafts` inserts the initial draft first, then its dependencies layer by layer. On MySQL/InnoDB, the query uses the `oel_plr_uniq_pl_publishable` unique index on (`publish_log`, `entity`) to service the `WHERE publish_log_id = ?` filter, which returns records in `entity_id` order — i.e. leaf-first, because `child_entity2` has a lower entity PK than `parent_of_two`, `grandparent`, etc. The `processed_entity_ids` optimization on line 899–904 is order-sensitive: when you process leaf records first, `processed_entity_ids` isn't yet populated with their ancestors' IDs, so the while loop traverses all the way up the tree redundantly on each leaf
73df8cd to
9f49bde
Compare
kdmccormick
left a comment
There was a problem hiding this comment.
Partial review.
So happy to see the containers applet factored out and the create_container_* APIs made DRYer and safer.
| """Raised when trying to modify a container whose implementation [plugin] is no longer available.""" | ||
|
|
||
|
|
||
| class ContainerTypeRecord(models.Model): |
There was a problem hiding this comment.
I think I'd rather call this just ContainerType, consistent with ComponentType.
The type alias you're calling ContainerType now, ie type[Container], could be ContainerSubclass, which is more precise from a Python standpoint. Or you could drop the alias altogether. You have several methods named along these lines, eg subclass_for_type_code, all_subclasses, etc., and I think it is very clear what all of those method do just by their names.
| # The "containers" app is built on top of publishing, and is a peer to | ||
| # "components" but they do not depend on each other. | ||
| openedx_content.applets.components | openedx_content.applets.containers |
There was a problem hiding this comment.
did not know about this syntax. cool!
|
@kdmccormick @ormsbee It occurred to me (unfortunately rather late) that the |
|
@bradenmacdonald: Would you see |
|
Another random thought while everything gets moved around is that we might someday stuff |
ormsbee
left a comment
There was a problem hiding this comment.
I'm broadly supportive of this PR, but I'm likely not going to get to properly reviewing it this week. I'm totally happy to have it merge once it gets approval from @kdmccormick. No need to wait for my review.
Thank you.
Implements #412
ContainerTypeconcept and corresponding database table (ContainerTypeRecord). Now every container must have a corresponding type; plainContainerinstances cannot be saved on their own.publishingapp and don't depend onUnit,Subsection, etc. This consolidates the core container logic, and should also make it easier to extract to a separatecontainersapp.Unit,Subsection, andSectionclasses, apps, and test cases are substantially simplified.Unit.create_next_container_versionnow accepts aContainerobject. Previously it only accepted a container PK, but passing the object is more convenient (also see next point)Containerinstance (or subclass instance) tocreate_next_container_version, it now automatically clears Django's internal field cache for accessing the latest draft version, so you don't have to remember to callrefresh_from_db()beforecontainer.versioning.draftwill be correct.soft_delete_draft()but I think we should.Corresponding openedx-platform PR: openedx/openedx-platform#38181