platform-plugin-aspects 0.9.4__tar.gz → 0.9.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/CHANGELOG.rst +18 -0
  2. {platform_plugin_aspects-0.9.4/platform_plugin_aspects.egg-info → platform_plugin_aspects-0.9.6}/PKG-INFO +19 -1
  3. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/__init__.py +1 -1
  4. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/signals.py +19 -5
  5. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/sinks/course_overview_sink.py +91 -34
  6. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/xblock.py +2 -2
  7. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6/platform_plugin_aspects.egg-info}/PKG-INFO +19 -1
  8. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/LICENSE +0 -0
  9. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/MANIFEST.in +0 -0
  10. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/README.rst +0 -0
  11. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/apps.py +0 -0
  12. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/extensions/__init__.py +0 -0
  13. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/extensions/filters.py +0 -0
  14. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/management/__init__.py +0 -0
  15. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/management/commands/__init__.py +0 -0
  16. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/management/commands/dump_data_to_clickhouse.py +0 -0
  17. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/management/commands/load_test_tracking_events.py +0 -0
  18. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/management/commands/monitor_load_test_tracking.py +0 -0
  19. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/settings/__init__.py +0 -0
  20. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/settings/common.py +0 -0
  21. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/settings/production.py +0 -0
  22. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/sinks/__init__.py +0 -0
  23. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/sinks/base_sink.py +0 -0
  24. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/sinks/external_id_sink.py +0 -0
  25. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/sinks/serializers.py +0 -0
  26. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/sinks/user_profile_sink.py +0 -0
  27. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/sinks/user_retire_sink.py +0 -0
  28. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/static/css/superset.css +0 -0
  29. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/static/html/superset.html +0 -0
  30. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/static/html/superset_student.html +0 -0
  31. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/static/js/embed_dashboard.js +0 -0
  32. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/static/js/install_required.js +0 -0
  33. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/static/js/superset.js +0 -0
  34. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/tasks.py +0 -0
  35. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/templates/instructor_dashboard/aspects.html +0 -0
  36. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/urls.py +0 -0
  37. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/utils.py +0 -0
  38. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/views.py +0 -0
  39. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects/waffle.py +0 -0
  40. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects.egg-info/SOURCES.txt +0 -0
  41. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects.egg-info/dependency_links.txt +0 -0
  42. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects.egg-info/entry_points.txt +0 -0
  43. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects.egg-info/not-zip-safe +0 -0
  44. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects.egg-info/requires.txt +0 -0
  45. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/platform_plugin_aspects.egg-info/top_level.txt +0 -0
  46. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/requirements/base.in +0 -0
  47. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/requirements/constraints.txt +0 -0
  48. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/setup.cfg +0 -0
  49. {platform_plugin_aspects-0.9.4 → platform_plugin_aspects-0.9.6}/setup.py +0 -0
@@ -14,6 +14,24 @@ Change Log
14
14
  Unreleased
15
15
  **********
16
16
 
17
+ 0.9.6 - 2024-06-07
18
+ ******************
19
+
20
+ Fixes
21
+ =====
22
+
23
+ * The CourseOutline sink was not always ordering blocks correctly, leading to issues with blocks appearing in the wrong sections/subsection.
24
+
25
+
26
+ 0.9.5 - 2024-05-24
27
+ ******************
28
+
29
+ Fixes
30
+ =====
31
+
32
+ * UserProfile sink now runs after the transaction is committed, preventing UserProfileNotFound errors and creation of rows in ClickHouse that don't exist in MySQL in the case of a rollback.
33
+
34
+
17
35
  0.9.4 - 2024-05-16
18
36
  ******************
19
37
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: platform-plugin-aspects
3
- Version: 0.9.4
3
+ Version: 0.9.6
4
4
  Summary: Aspects plugins for edx-platform
5
5
  Home-page: https://github.com/openedx/platform-plugin-aspects
6
6
  Author: Open edX Project
@@ -276,6 +276,24 @@ Change Log
276
276
  Unreleased
277
277
  **********
278
278
 
279
+ 0.9.6 - 2024-06-07
280
+ ******************
281
+
282
+ Fixes
283
+ =====
284
+
285
+ * The CourseOutline sink was not always ordering blocks correctly, leading to issues with blocks appearing in the wrong sections/subsection.
286
+
287
+
288
+ 0.9.5 - 2024-05-24
289
+ ******************
290
+
291
+ Fixes
292
+ =====
293
+
294
+ * UserProfile sink now runs after the transaction is committed, preventing UserProfileNotFound errors and creation of rows in ClickHouse that don't exist in MySQL in the case of a rollback.
295
+
296
+
279
297
  0.9.4 - 2024-05-16
280
298
  ******************
281
299
 
@@ -5,6 +5,6 @@ Aspects plugins for edx-platform.
5
5
  import os
6
6
  from pathlib import Path
7
7
 
8
- __version__ = "0.9.4"
8
+ __version__ = "0.9.6"
9
9
 
10
10
  ROOT_DIRECTORY = Path(os.path.dirname(os.path.abspath(__file__)))
@@ -2,6 +2,7 @@
2
2
  Signal handler functions, mapped to specific signals in apps.py.
3
3
  """
4
4
 
5
+ from django.db import transaction
5
6
  from django.db.models.signals import post_save
6
7
  from django.dispatch import Signal, receiver
7
8
 
@@ -33,11 +34,9 @@ def receive_course_publish( # pylint: disable=unused-argument # pragma: no cov
33
34
  dump_course_to_clickhouse.delay(str(course_key))
34
35
 
35
36
 
36
- def on_user_profile_updated( # pylint: disable=unused-argument # pragma: no cover
37
- sender, instance, **kwargs
38
- ):
37
+ def on_user_profile_updated(instance):
39
38
  """
40
- Receives post save signal and queues the dump job.
39
+ Queues the UserProfile dump job when the parent transaction is committed.
41
40
  """
42
41
  # import here, because signal is registered at startup, but items in tasks are not yet able to be loaded
43
42
  from platform_plugin_aspects.tasks import ( # pylint: disable=import-outside-toplevel
@@ -52,11 +51,26 @@ def on_user_profile_updated( # pylint: disable=unused-argument # pragma: no co
52
51
  )
53
52
 
54
53
 
54
+ def on_user_profile_updated_txn(**kwargs):
55
+ """
56
+ Handle user_profile saves in the middle of a transaction.
57
+
58
+ If this gets fired before the transaction commits, the task may try to
59
+ query an id that doesn't exist yet and throw an error. This should postpone
60
+ queuing the Celery task until after the transaction is committed.
61
+ """
62
+ transaction.on_commit(
63
+ lambda: on_user_profile_updated(kwargs["instance"])
64
+ ) # pragma: no cover
65
+
66
+
55
67
  # Connect the UserProfile.post_save signal handler only if we have a model to attach to.
56
68
  # (prevents celery errors during tests)
57
69
  _user_profile = get_model("user_profile")
58
70
  if _user_profile:
59
- post_save.connect(on_user_profile_updated, sender=_user_profile) # pragma: no cover
71
+ post_save.connect(
72
+ on_user_profile_updated_txn, sender=_user_profile
73
+ ) # pragma: no cover
60
74
 
61
75
 
62
76
  def on_externalid_saved( # pylint: disable=unused-argument # pragma: no cover
@@ -29,6 +29,8 @@ CLICKHOUSE_BULK_INSERT_PARAMS = {
29
29
  "input_format_allow_errors_ratio": 0.1,
30
30
  }
31
31
 
32
+ MODULESTORE_PUBLISHED_ONLY_FLAG = "rev-opt-published-only"
33
+
32
34
 
33
35
  class XBlockSink(ModelBaseSink):
34
36
  """
@@ -49,6 +51,48 @@ class XBlockSink(ModelBaseSink):
49
51
  initial={"dump_id": dump_id, "time_last_dumped": time_last_dumped},
50
52
  )
51
53
 
54
+ def get_xblocks_recursive(self, parent_block, detached_xblock_types, initial):
55
+ """
56
+ Serialize the course tree recursively, return a flattened list of XBlocks.
57
+
58
+ Note that this list will not include detached blocks, those are handled
59
+ in get_detached_xblocks. This method preserves the course ordering for
60
+ non-detached blocks.
61
+ """
62
+ items = [
63
+ self.serialize_xblock(
64
+ parent_block,
65
+ detached_xblock_types,
66
+ initial["dump_id"],
67
+ initial["time_last_dumped"],
68
+ )
69
+ ]
70
+
71
+ for child in parent_block.get_children():
72
+ items.extend(
73
+ self.get_xblocks_recursive(child, detached_xblock_types, initial)
74
+ )
75
+
76
+ return items
77
+
78
+ def get_detached_xblocks(self, course_blocks, detached_xblock_types, initial):
79
+ """
80
+ Spin through the flat list of all blocks in a course and return only
81
+ the detached blocks. Ordering of non-detached blocks is already
82
+ guaranteed in get_xblocks_recursive. Order of detached blocks
83
+ is not guaranteed.
84
+ """
85
+ return [
86
+ self.serialize_xblock(
87
+ block,
88
+ detached_xblock_types,
89
+ initial["dump_id"],
90
+ initial["time_last_dumped"],
91
+ )
92
+ for block in course_blocks
93
+ if block.scope_ids.block_type in detached_xblock_types
94
+ ]
95
+
52
96
  def serialize_item(self, item, many=False, initial=None):
53
97
  """
54
98
  Serialize an XBlock into a dict
@@ -58,10 +102,26 @@ class XBlockSink(ModelBaseSink):
58
102
  detached_xblock_types = get_detached_xblock_types()
59
103
 
60
104
  location_to_node = {}
61
- items = modulestore.get_items(course_key)
62
105
 
63
- # Serialize the XBlocks to dicts and map them with their location as keys the
64
- # whole map needs to be completed before we can define relationships
106
+ # This call gets the entire course tree in order, because the
107
+ # get_items call does not guarantee ordering. It does not return
108
+ # detached blocks, so we gather them separately below.
109
+ course_block = modulestore.get_course(
110
+ course_key, revision=MODULESTORE_PUBLISHED_ONLY_FLAG
111
+ )
112
+
113
+ items = self.get_xblocks_recursive(course_block, detached_xblock_types, initial)
114
+
115
+ # Here we fetch the detached blocks and add them to the list.
116
+ detached = self.get_detached_xblocks(
117
+ modulestore.get_items(course_key, revision=MODULESTORE_PUBLISHED_ONLY_FLAG),
118
+ detached_xblock_types,
119
+ initial,
120
+ )
121
+
122
+ items.extend(detached)
123
+
124
+ # Add location and tag data to the dict mappings of the blocks
65
125
  index = 0
66
126
  section_idx = 0
67
127
  subsection_idx = 0
@@ -69,41 +129,39 @@ class XBlockSink(ModelBaseSink):
69
129
 
70
130
  for block in items:
71
131
  index += 1
72
- fields = self.serialize_xblock(
73
- block,
74
- index,
75
- detached_xblock_types,
76
- initial["dump_id"],
77
- initial["time_last_dumped"],
78
- )
79
132
 
80
- if fields["xblock_data_json"]["block_type"] == "chapter":
81
- section_idx += 1
82
- subsection_idx = 0
83
- unit_idx = 0
84
- elif fields["xblock_data_json"]["block_type"] == "sequential":
85
- subsection_idx += 1
86
- unit_idx = 0
87
- elif fields["xblock_data_json"]["block_type"] == "vertical":
88
- unit_idx += 1
89
-
90
- fields["xblock_data_json"]["section"] = section_idx
91
- fields["xblock_data_json"]["subsection"] = subsection_idx
92
- fields["xblock_data_json"]["unit"] = unit_idx
93
- fields["xblock_data_json"]["tags"] = get_tags_for_block(
94
- fields["location"],
133
+ block["order"] = index
134
+
135
+ # Ensure that detached types aren't part of the tree
136
+ if block["xblock_data_json"]["detached"]:
137
+ block["xblock_data_json"]["section"] = 0
138
+ block["xblock_data_json"]["subsection"] = 0
139
+ block["xblock_data_json"]["unit"] = 0
140
+ else:
141
+ if block["xblock_data_json"]["block_type"] == "chapter":
142
+ section_idx += 1
143
+ subsection_idx = 0
144
+ unit_idx = 0
145
+ elif block["xblock_data_json"]["block_type"] == "sequential":
146
+ subsection_idx += 1
147
+ unit_idx = 0
148
+ elif block["xblock_data_json"]["block_type"] == "vertical":
149
+ unit_idx += 1
150
+
151
+ block["xblock_data_json"]["section"] = section_idx
152
+ block["xblock_data_json"]["subsection"] = subsection_idx
153
+ block["xblock_data_json"]["unit"] = unit_idx
154
+
155
+ block["xblock_data_json"]["tags"] = get_tags_for_block(
156
+ block["location"],
95
157
  )
96
158
 
97
- fields["xblock_data_json"] = json.dumps(fields["xblock_data_json"])
98
- location_to_node[XBlockSink.strip_branch_and_version(block.location)] = (
99
- fields
100
- )
159
+ block["xblock_data_json"] = json.dumps(block["xblock_data_json"])
160
+ location_to_node[block["location"]] = block
101
161
 
102
162
  return list(location_to_node.values())
103
163
 
104
- def serialize_xblock(
105
- self, item, index, detached_xblock_types, dump_id, time_last_dumped
106
- ):
164
+ def serialize_xblock(self, item, detached_xblock_types, dump_id, time_last_dumped):
107
165
  """Serialize an XBlock instance into a dict"""
108
166
  course_key = item.scope_ids.usage_id.course_key
109
167
  block_type = item.scope_ids.block_type
@@ -123,10 +181,9 @@ class XBlockSink(ModelBaseSink):
123
181
  serialized_block = {
124
182
  "org": course_key.org,
125
183
  "course_key": str(course_key),
126
- "location": str(item.location),
184
+ "location": str(XBlockSink.strip_branch_and_version(item.location)),
127
185
  "display_name": item.display_name_with_default.replace("'", "'"),
128
186
  "xblock_data_json": json_data,
129
- "order": index,
130
187
  "edited_on": str(getattr(item, "edited_on", "")),
131
188
  "dump_id": dump_id,
132
189
  "time_last_dumped": time_last_dumped,
@@ -16,10 +16,10 @@ from xblock.fields import List, Scope, String
16
16
 
17
17
  # These moved from xblockutils to xblock in Quince, these can be removed
18
18
  # when we stop supporting earlier versions.
19
- try: # pragma: no-cover
19
+ try: # pragma: no cover
20
20
  from xblock.utils.resources import ResourceLoader
21
21
  from xblock.utils.studio_editable import StudioEditableXBlockMixin
22
- except ImportError:
22
+ except ImportError: # pragma: no cover
23
23
  from xblockutils.resources import ResourceLoader
24
24
  from xblockutils.studio_editable import StudioEditableXBlockMixin
25
25
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: platform-plugin-aspects
3
- Version: 0.9.4
3
+ Version: 0.9.6
4
4
  Summary: Aspects plugins for edx-platform
5
5
  Home-page: https://github.com/openedx/platform-plugin-aspects
6
6
  Author: Open edX Project
@@ -276,6 +276,24 @@ Change Log
276
276
  Unreleased
277
277
  **********
278
278
 
279
+ 0.9.6 - 2024-06-07
280
+ ******************
281
+
282
+ Fixes
283
+ =====
284
+
285
+ * The CourseOutline sink was not always ordering blocks correctly, leading to issues with blocks appearing in the wrong sections/subsection.
286
+
287
+
288
+ 0.9.5 - 2024-05-24
289
+ ******************
290
+
291
+ Fixes
292
+ =====
293
+
294
+ * UserProfile sink now runs after the transaction is committed, preventing UserProfileNotFound errors and creation of rows in ClickHouse that don't exist in MySQL in the case of a rollback.
295
+
296
+
279
297
  0.9.4 - 2024-05-16
280
298
  ******************
281
299