Skip to content

Commit 1934a7d

Browse files
committed
docs: mark api as UNSTABLE and add comment about get_library_object_hierarchy implementation
1 parent 3e969af commit 1934a7d

2 files changed

Lines changed: 22 additions & 14 deletions

File tree

‎openedx/core/djangoapps/content_libraries/api/container_metadata.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ def from_container(cls, library_key, container: Container, associated_collection
129129
class ContainerHierarchy:
130130
"""
131131
Describes the full ancestry and descendents of a given library object.
132+
133+
TODO: We intend to replace this implementation with a more efficient one that makes fewer
134+
database queries in the future. More details being discussed in
135+
https://github.com/openedx/edx-platform/pull/36813#issuecomment-3136631767
132136
"""
133137
sections: list[ContainerHierarchyMember] = dataclass_field(default_factory=list)
134138
subsections: list[ContainerHierarchyMember] = dataclass_field(default_factory=list)

‎openedx/core/djangoapps/content_libraries/api/containers.py‎

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
from openedx.core.djangoapps.content_staging.api import UserClipboardData
4646

4747

48-
# The public API is only the following symbols:
48+
# 🛑 UNSTABLE: All APIs related to containers are unstable until we've figured
49+
# out our approach to dynamic content (randomized, A/B tests, etc.)
4950
__all__ = [
5051
"get_container",
5152
"create_container",
@@ -71,7 +72,7 @@ def get_container(
7172
include_collections=False,
7273
) -> ContainerMetadata:
7374
"""
74-
Get a container (a Section, Subsection, or Unit).
75+
[ 🛑 UNSTABLE ] Get a container (a Section, Subsection, or Unit).
7576
"""
7677
container = get_container_from_key(container_key)
7778
if include_collections:
@@ -99,7 +100,7 @@ def create_container(
99100
created: datetime | None = None,
100101
) -> ContainerMetadata:
101102
"""
102-
Create a container (a Section, Subsection, or Unit) in the specified content library.
103+
[ 🛑 UNSTABLE ] Create a container (a Section, Subsection, or Unit) in the specified content library.
103104
104105
It will initially be empty.
105106
"""
@@ -168,7 +169,7 @@ def update_container(
168169
user_id: int | None,
169170
) -> ContainerMetadata:
170171
"""
171-
Update a container (a Section, Subsection, or Unit) title.
172+
[ 🛑 UNSTABLE ] Update a container (a Section, Subsection, or Unit) title.
172173
"""
173174
container = get_container_from_key(container_key)
174175
library_key = container_key.lib_key
@@ -256,7 +257,7 @@ def delete_container(
256257
container_key: LibraryContainerLocator,
257258
) -> None:
258259
"""
259-
Delete a container (a Section, Subsection, or Unit) (soft delete).
260+
[ 🛑 UNSTABLE ] Delete a container (a Section, Subsection, or Unit) (soft delete).
260261
261262
No-op if container doesn't exist or has already been soft-deleted.
262263
"""
@@ -331,7 +332,7 @@ def delete_container(
331332

332333
def restore_container(container_key: LibraryContainerLocator) -> None:
333334
"""
334-
Restore the specified library container.
335+
[ 🛑 UNSTABLE ] Restore the specified library container.
335336
"""
336337
library_key = container_key.lib_key
337338
container = get_container_from_key(container_key, include_deleted=True)
@@ -421,7 +422,7 @@ def get_container_children(
421422
published=False,
422423
) -> list[LibraryXBlockMetadata | ContainerMetadata]:
423424
"""
424-
Get the entities contained in the given container
425+
[ 🛑 UNSTABLE ] Get the entities contained in the given container
425426
(e.g. the components/xblocks in a unit, units in a subsection, subsections in a section)
426427
"""
427428
container = get_container_from_key(container_key)
@@ -459,7 +460,7 @@ def get_container_children_count(
459460
published=False,
460461
) -> int:
461462
"""
462-
Get the count of entities contained in the given container (e.g. the components/xblocks in a unit)
463+
[ 🛑 UNSTABLE ] Get the count of entities contained in the given container (e.g. the components/xblocks in a unit)
463464
"""
464465
container = get_container_from_key(container_key)
465466
return authoring_api.get_container_children_count(container, published=published)
@@ -472,7 +473,7 @@ def update_container_children(
472473
entities_action: authoring_api.ChildrenEntitiesAction = authoring_api.ChildrenEntitiesAction.REPLACE,
473474
):
474475
"""
475-
Adds children components or containers to given container.
476+
[ 🛑 UNSTABLE ] Adds children components or containers to given container.
476477
"""
477478
library_key = container_key.lib_key
478479
container_type = ContainerType(container_key.container_type)
@@ -555,8 +556,7 @@ def get_containers_contains_item(
555556
key: LibraryUsageLocatorV2 | LibraryContainerLocator
556557
) -> list[ContainerMetadata]:
557558
"""
558-
Get containers that contains the item,
559-
that can be a component or another container.
559+
[ 🛑 UNSTABLE ] Get containers that contains the item, that can be a component or another container.
560560
"""
561561
item: Component | Container
562562

@@ -577,7 +577,7 @@ def get_containers_contains_item(
577577

578578
def publish_container_changes(container_key: LibraryContainerLocator, user_id: int | None) -> None:
579579
"""
580-
Publish all unpublished changes in a container and all its child
580+
[ 🛑 UNSTABLE ] Publish all unpublished changes in a container and all its child
581581
containers/blocks.
582582
"""
583583
container = get_container_from_key(container_key)
@@ -600,7 +600,7 @@ def publish_container_changes(container_key: LibraryContainerLocator, user_id: i
600600

601601
def copy_container(container_key: LibraryContainerLocator, user_id: int) -> UserClipboardData:
602602
"""
603-
Copy a container (a Section, Subsection, or Unit) to the content staging.
603+
[ 🛑 UNSTABLE ] Copy a container (a Section, Subsection, or Unit) to the content staging.
604604
"""
605605
container_metadata = get_container(container_key)
606606
container_serializer = ContainerSerializer(container_metadata)
@@ -625,6 +625,10 @@ def get_library_object_hierarchy(
625625
object_key: LibraryUsageLocatorV2 | LibraryContainerLocator,
626626
) -> ContainerHierarchy:
627627
"""
628-
Returns the full ancestry and descendents of the library object with the given object_key.
628+
[ 🛑 UNSTABLE ] Returns the full ancestry and descendents of the library object with the given object_key.
629+
630+
TODO: We intend to replace this implementation with a more efficient one that makes fewer
631+
database queries in the future. More details being discussed in
632+
https://github.com/openedx/edx-platform/pull/36813#issuecomment-3136631767
629633
"""
630634
return ContainerHierarchy.create_from_library_object_key(object_key)

0 commit comments

Comments
 (0)