platform-plugin-aspects 0.9.3__tar.gz → 0.9.5__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.3 → platform_plugin_aspects-0.9.5}/CHANGELOG.rst +17 -0
  2. {platform_plugin_aspects-0.9.3/platform_plugin_aspects.egg-info → platform_plugin_aspects-0.9.5}/PKG-INFO +18 -1
  3. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/__init__.py +1 -1
  4. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/extensions/filters.py +0 -1
  5. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/management/commands/load_test_tracking_events.py +0 -1
  6. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/management/commands/monitor_load_test_tracking.py +2 -0
  7. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/signals.py +19 -5
  8. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/sinks/serializers.py +27 -1
  9. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/xblock.py +2 -2
  10. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5/platform_plugin_aspects.egg-info}/PKG-INFO +18 -1
  11. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/LICENSE +0 -0
  12. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/MANIFEST.in +0 -0
  13. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/README.rst +0 -0
  14. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/apps.py +0 -0
  15. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/extensions/__init__.py +0 -0
  16. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/management/__init__.py +0 -0
  17. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/management/commands/__init__.py +0 -0
  18. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/management/commands/dump_data_to_clickhouse.py +0 -0
  19. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/settings/__init__.py +0 -0
  20. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/settings/common.py +0 -0
  21. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/settings/production.py +0 -0
  22. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/sinks/__init__.py +0 -0
  23. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/sinks/base_sink.py +0 -0
  24. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/sinks/course_overview_sink.py +0 -0
  25. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/sinks/external_id_sink.py +0 -0
  26. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/sinks/user_profile_sink.py +0 -0
  27. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/sinks/user_retire_sink.py +0 -0
  28. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/static/css/superset.css +0 -0
  29. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/static/html/superset.html +0 -0
  30. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/static/html/superset_student.html +0 -0
  31. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/static/js/embed_dashboard.js +0 -0
  32. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/static/js/install_required.js +0 -0
  33. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/static/js/superset.js +0 -0
  34. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/tasks.py +0 -0
  35. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/templates/instructor_dashboard/aspects.html +0 -0
  36. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/urls.py +0 -0
  37. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/utils.py +0 -0
  38. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/views.py +0 -0
  39. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects/waffle.py +0 -0
  40. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects.egg-info/SOURCES.txt +0 -0
  41. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects.egg-info/dependency_links.txt +0 -0
  42. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects.egg-info/entry_points.txt +0 -0
  43. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects.egg-info/not-zip-safe +0 -0
  44. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects.egg-info/requires.txt +0 -0
  45. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/platform_plugin_aspects.egg-info/top_level.txt +0 -0
  46. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/requirements/base.in +0 -0
  47. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/requirements/constraints.txt +0 -0
  48. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/setup.cfg +0 -0
  49. {platform_plugin_aspects-0.9.3 → platform_plugin_aspects-0.9.5}/setup.py +0 -0
@@ -14,6 +14,23 @@ Change Log
14
14
  Unreleased
15
15
  **********
16
16
 
17
+ 0.9.5 - 2024-05-24
18
+ ******************
19
+
20
+ Fixes
21
+ =====
22
+
23
+ * 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.
24
+
25
+
26
+ 0.9.4 - 2024-05-16
27
+ ******************
28
+
29
+ Fixes
30
+ =====
31
+
32
+ * Allow to serialize dates as strings in JSON.
33
+
17
34
  0.9.3 - 2024-05-15
18
35
  ******************
19
36
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: platform-plugin-aspects
3
- Version: 0.9.3
3
+ Version: 0.9.5
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,23 @@ Change Log
276
276
  Unreleased
277
277
  **********
278
278
 
279
+ 0.9.5 - 2024-05-24
280
+ ******************
281
+
282
+ Fixes
283
+ =====
284
+
285
+ * 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.
286
+
287
+
288
+ 0.9.4 - 2024-05-16
289
+ ******************
290
+
291
+ Fixes
292
+ =====
293
+
294
+ * Allow to serialize dates as strings in JSON.
295
+
279
296
  0.9.3 - 2024-05-15
280
297
  ******************
281
298
 
@@ -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.3"
8
+ __version__ = "0.9.5"
9
9
 
10
10
  ROOT_DIRECTORY = Path(os.path.dirname(os.path.abspath(__file__)))
@@ -71,7 +71,6 @@ class AddSupersetTab(PipelineStep):
71
71
  "show_dashboard_link": show_dashboard_link,
72
72
  }
73
73
 
74
- print(section_data)
75
74
  context["sections"].append(section_data)
76
75
  return {
77
76
  "context": context,
@@ -158,7 +158,6 @@ class LoadTest:
158
158
  output = io.StringIO()
159
159
  writer = csv.writer(output)
160
160
  writer.writerow((self.run_id, event_type, json.dumps(extra)))
161
- print(output.getvalue().encode("utf-8"))
162
161
 
163
162
  response = requests.post(
164
163
  url=self.ch_url,
@@ -142,8 +142,10 @@ class Monitor:
142
142
  while True:
143
143
  start = datetime.datetime.now()
144
144
  log.info(f"----------- {start} --------")
145
+ lag = None
145
146
 
146
147
  current_stats = {"clickhouse": self.get_clickhouse_stats()}
148
+ lag = -1
147
149
  if collect_redis_bus:
148
150
  current_stats["redis_bus"] = self.get_redis_bus_stats()
149
151
  lag = current_stats["redis_bus"]["lag"]
@@ -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
@@ -2,13 +2,39 @@
2
2
 
3
3
  import json
4
4
  import uuid
5
+ from datetime import date, datetime
5
6
 
6
7
  from django.utils import timezone
8
+ from pytz import UTC
7
9
  from rest_framework import serializers
8
10
 
9
11
  from platform_plugin_aspects.utils import get_model, get_tags_for_block
10
12
 
11
13
 
14
+ class DateTimeJSONEncoder(json.JSONEncoder):
15
+ """JSON encoder aware of datetime.datetime and datetime.date objects"""
16
+
17
+ def default(self, obj): # pylint: disable=arguments-renamed
18
+ """
19
+ Serialize datetime and date objects of iso format.
20
+
21
+ datetime objects are converted to UTC.
22
+ """
23
+
24
+ if isinstance(obj, datetime):
25
+ if obj.tzinfo is None:
26
+ # Localize to UTC naive datetime objects
27
+ obj = UTC.localize(obj) # pylint: disable=no-value-for-parameter
28
+ else:
29
+ # Convert to UTC datetime objects from other timezones
30
+ obj = obj.astimezone(UTC)
31
+ return obj.isoformat()
32
+ elif isinstance(obj, date):
33
+ return obj.isoformat()
34
+
35
+ return super().default(obj)
36
+
37
+
12
38
  class BaseSinkSerializer(serializers.Serializer): # pylint: disable=abstract-method
13
39
  """Base sink serializer for ClickHouse."""
14
40
 
@@ -148,7 +174,7 @@ class CourseOverviewSerializer(BaseSinkSerializer, serializers.ModelSerializer):
148
174
  "language": getattr(overview, "language", ""),
149
175
  "tags": get_tags_for_block(overview.id),
150
176
  }
151
- return json.dumps(json_fields)
177
+ return json.dumps(json_fields, cls=DateTimeJSONEncoder)
152
178
 
153
179
  def get_course_key(self, overview):
154
180
  """Return the course key as a string."""
@@ -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.3
3
+ Version: 0.9.5
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,23 @@ Change Log
276
276
  Unreleased
277
277
  **********
278
278
 
279
+ 0.9.5 - 2024-05-24
280
+ ******************
281
+
282
+ Fixes
283
+ =====
284
+
285
+ * 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.
286
+
287
+
288
+ 0.9.4 - 2024-05-16
289
+ ******************
290
+
291
+ Fixes
292
+ =====
293
+
294
+ * Allow to serialize dates as strings in JSON.
295
+
279
296
  0.9.3 - 2024-05-15
280
297
  ******************
281
298