From 598d1b5043f9fa33bac2d09fc82b811938f92410 Mon Sep 17 00:00:00 2001 From: andrii-hantkovskyi <131773947+andrii-hantkovskyi@users.noreply.github.com> Date: Wed, 10 Apr 2024 19:47:10 +0300 Subject: [PATCH] fix: [ACI-901] use customized openedx-events package to prevent CI failures (#2535) * ci: [ACI-901] change standard events to cuztomized to prevent ci failing * fix: [ACI-901] few fixes for ci * refactor: [ACI-901] refactor code to pass ci checks * style: [ACI-901] adjust style to pep8 --------- Co-authored-by: Andrii --- cms/djangoapps/contentstore/signals/handlers.py | 2 -- .../contentstore/signals/tests/test_handlers.py | 2 -- cms/envs/common.py | 14 +++++++++++++- lms/djangoapps/grades/events.py | 2 +- lms/djangoapps/grades/tests/test_events.py | 4 ++-- lms/envs/common.py | 5 ++++- lms/envs/production.py | 2 +- requirements/constraints.txt | 2 +- requirements/edx/base.in | 1 - requirements/edx/base.txt | 7 ++----- requirements/edx/development.txt | 7 ++----- requirements/edx/testing.txt | 7 ++----- 12 files changed, 28 insertions(+), 27 deletions(-) diff --git a/cms/djangoapps/contentstore/signals/handlers.py b/cms/djangoapps/contentstore/signals/handlers.py index 76711eaa4ddc..6030b015313a 100644 --- a/cms/djangoapps/contentstore/signals/handlers.py +++ b/cms/djangoapps/contentstore/signals/handlers.py @@ -27,7 +27,6 @@ from lms.djangoapps.grades.api import task_compute_all_grades_for_course from openedx.core.djangoapps.content.learning_sequences.api import key_supports_outlines from openedx.core.djangoapps.discussions.tasks import update_discussions_settings_from_course_task -from openedx.core.djangoapps.models.course_details import CourseDetails from openedx.core.lib.gating import api as gating_api from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.django import SignalHandler, modulestore @@ -95,7 +94,6 @@ def create_catalog_data_for_signal(course_key: CourseKey) -> Optional[CourseCata enrollment_start=course.enrollment_start, enrollment_end=course.enrollment_end, ), - effort=CourseDetails.fetch_about_attribute(course_key, 'effort'), hidden=course.catalog_visibility in ['about', 'none'] or course_key.deprecated, invitation_only=course.invitation_only, ) diff --git a/cms/djangoapps/contentstore/signals/tests/test_handlers.py b/cms/djangoapps/contentstore/signals/tests/test_handlers.py index 943fe4aab2cd..8cb4c60018c5 100644 --- a/cms/djangoapps/contentstore/signals/tests/test_handlers.py +++ b/cms/djangoapps/contentstore/signals/tests/test_handlers.py @@ -39,8 +39,6 @@ def setUp(self): end=None, enrollment_start=None, enrollment_end=None), - short_description=None, - effort=None, hidden=False, invitation_only=False ) diff --git a/cms/envs/common.py b/cms/envs/common.py index 9741035e55d0..f1813fcfb09b 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -516,6 +516,14 @@ # in the LMS and CMS. # .. toggle_tickets: 'https://github.com/open-craft/edx-platform/pull/429' 'DISABLE_UNENROLLMENT': False, + + # .. toggle_name: FEATURES['BADGES_ENABLED'] + # .. toggle_implementation: DjangoSetting + # .. toggle_default: False + # .. toggle_description: Set to True to enable the Badges feature. + # .. toggle_use_cases: open_edx + # .. toggle_creation_date: 2024-04-10 + 'BADGES_ENABLED': False, } # .. toggle_name: ENABLE_COPPA_COMPLIANCE @@ -2699,6 +2707,7 @@ EVENT_BUS_REDIS_CONNECTION_URL = "redis://:password@edx.devstack.redis:6379/" EVENT_BUS_TOPIC_PREFIX = "dev" + def _should_send_learning_badge_events(settings): return settings.FEATURES['BADGES_ENABLED'] @@ -2740,7 +2749,10 @@ def _should_send_learning_badge_events(settings): "enabled", ) -# If the consumer encounters this many consecutive errors, exit with an error. This is intended to be used in a context where a management system (such as Kubernetes) will relaunch the consumer automatically. +# If the consumer encounters this many consecutive errors, exit with an error. +# This is intended to be used in a context where a management system (such as Kubernetes) +# will relaunch the consumer automatically. + #EVENT_BUS_REDIS_CONSUMER_CONSECUTIVE_ERRORS_LIMIT (defaults to None) # How long the consumer should wait for new entries in a stream. diff --git a/lms/djangoapps/grades/events.py b/lms/djangoapps/grades/events.py index 7a02bb7d7bb5..538f3b34eef3 100644 --- a/lms/djangoapps/grades/events.py +++ b/lms/djangoapps/grades/events.py @@ -280,7 +280,7 @@ def course_grade_now_failed(user, course_id): else: COURSE_PASSING_STATUS_UPDATED.send_event( course_passing_status=CoursePassingStatusData( - status = CoursePassingStatusData.FAILING, + status=CoursePassingStatusData.FAILING, user=UserData( pii=UserPersonalData( username=user.username, diff --git a/lms/djangoapps/grades/tests/test_events.py b/lms/djangoapps/grades/tests/test_events.py index c6059d06854a..906b0d23ee00 100644 --- a/lms/djangoapps/grades/tests/test_events.py +++ b/lms/djangoapps/grades/tests/test_events.py @@ -111,7 +111,7 @@ def test_persistent_grade_event_emitted(self): ) -class CoursePassingStatusEventsTest(SharedModuleStoreTestCase, OpenEdxEventsTestMixin): +class CoursePassingStatusEventsTest(SharedModuleStoreTestCase, OpenEdxEventsTestMixin): # pylint: disable=missing-class-docstring ENABLED_OPENEDX_EVENTS = [ "org.openedx.learning.course.passing.status.updated.v1", ] @@ -169,7 +169,7 @@ def test_course_passing_status_updated_emitted(self): ) -class CCXCoursePassingStatusEventsTest( +class CCXCoursePassingStatusEventsTest( # pylint: disable=missing-class-docstring SharedModuleStoreTestCase, OpenEdxEventsTestMixin ): ENABLED_OPENEDX_EVENTS = [ diff --git a/lms/envs/common.py b/lms/envs/common.py index 27b4b2506f09..ebd3ec8b6115 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -5275,6 +5275,7 @@ def _make_locale_paths(settings): # pylint: disable=missing-function-docstring EVENT_BUS_REDIS_CONNECTION_URL = "redis://:password@edx.devstack.redis:6379/" EVENT_BUS_TOPIC_PREFIX = "dev" + def _should_send_learning_badge_events(settings): return settings.FEATURES['BADGES_ENABLED'] @@ -5316,7 +5317,9 @@ def _should_send_learning_badge_events(settings): "enabled", ) -# If the consumer encounters this many consecutive errors, exit with an error. This is intended to be used in a context where a management system (such as Kubernetes) will relaunch the consumer automatically. +# If the consumer encounters this many consecutive errors, exit with an error. +# This is intended to be used in a context where a management system (such as Kubernetes) +# will relaunch the consumer automatically. #EVENT_BUS_REDIS_CONSUMER_CONSECUTIVE_ERRORS_LIMIT (defaults to None) # How long the consumer should wait for new entries in a stream. diff --git a/lms/envs/production.py b/lms/envs/production.py index 478d51bec7ca..554e8859de7a 100644 --- a/lms/envs/production.py +++ b/lms/envs/production.py @@ -1087,4 +1087,4 @@ def get_env_setting(setting): ############## Event bus producer ############## EVENT_BUS_PRODUCER_CONFIG = merge_producer_configs( EVENT_BUS_PRODUCER_CONFIG, ENV_TOKENS.get("EVENT_BUS_PRODUCER_CONFIG", {}) -) \ No newline at end of file +) diff --git a/requirements/constraints.txt b/requirements/constraints.txt index 3017d343ad31..4c955add3bcc 100644 --- a/requirements/constraints.txt +++ b/requirements/constraints.txt @@ -100,4 +100,4 @@ pytz==2022.2.1 # openedx-events>0.13.0 causes test failures due to breaking changes # These broken tests will be fixed in a separate PR -openedx-events==0.13.0 +-e git+https://github.com/raccoongang/openedx-events.git@aci.main#egg=openedx_events diff --git a/requirements/edx/base.in b/requirements/edx/base.in index e3d9dd537025..e86ba71babca 100644 --- a/requirements/edx/base.in +++ b/requirements/edx/base.in @@ -124,7 +124,6 @@ nltk # Natural language processing; used by the c nodeenv # Utility for managing Node.js environments; we use this for deployments and testing oauthlib # OAuth specification support for authenticating via LTI or other Open edX services openedx-calc # Library supporting mathematical calculations for Open edX -openedx-events>=0.12.0 # Open edX Events from Hooks Extension Framework (OEP-50) openedx-filters # Open edX Filters from Hooks Extension Framework (OEP-50) optimizely-sdk # Optimizely full stack SDK for Python ora2>=4.5.0 diff --git a/requirements/edx/base.txt b/requirements/edx/base.txt index f8213d991ec4..b59b4526ed18 100644 --- a/requirements/edx/base.txt +++ b/requirements/edx/base.txt @@ -16,6 +16,8 @@ # via -r requirements/edx/github.in -e git+https://github.com/openedx/xblock-google-drive.git@2d176468e33c0713c911b563f8f65f7cf232f5b6#egg=xblock-google-drive # via -r requirements/edx/github.in +-e git+https://github.com/raccoongang/openedx-events.git@aci.main#egg=openedx_events + # via -r requirements/edx/github.in acid-xblock==0.2.1 # via -r requirements/edx/base.in aiohttp==3.8.3 @@ -759,11 +761,6 @@ openedx-calc==3.0.1 # via -r requirements/edx/base.in openedx-django-pyfs==3.2.1 # via xblock -openedx-events==0.13.0 - # via - # -c requirements/edx/../constraints.txt - # -r requirements/edx/base.in - # edx-event-bus-kafka openedx-filters==0.8.0 # via # -r requirements/edx/base.in diff --git a/requirements/edx/development.txt b/requirements/edx/development.txt index 6c3ecce2cd1a..ae9e30d25e5c 100644 --- a/requirements/edx/development.txt +++ b/requirements/edx/development.txt @@ -16,6 +16,8 @@ # via -r requirements/edx/testing.txt -e git+https://github.com/openedx/xblock-google-drive.git@2d176468e33c0713c911b563f8f65f7cf232f5b6#egg=xblock-google-drive # via -r requirements/edx/testing.txt +-e git+https://github.com/raccoongang/openedx-events.git@aci.main#egg=openedx_events + # via -r requirements/edx/testing.txt acid-xblock==0.2.1 # via -r requirements/edx/testing.txt aiohttp==3.8.3 @@ -991,11 +993,6 @@ openedx-django-pyfs==3.2.1 # via # -r requirements/edx/testing.txt # xblock -openedx-events==0.13.0 - # via - # -c requirements/edx/../constraints.txt - # -r requirements/edx/testing.txt - # edx-event-bus-kafka openedx-filters==0.8.0 # via # -r requirements/edx/testing.txt diff --git a/requirements/edx/testing.txt b/requirements/edx/testing.txt index 3638b2451459..e5a447bd659a 100644 --- a/requirements/edx/testing.txt +++ b/requirements/edx/testing.txt @@ -16,6 +16,8 @@ # via -r requirements/edx/base.txt -e git+https://github.com/openedx/xblock-google-drive.git@2d176468e33c0713c911b563f8f65f7cf232f5b6#egg=xblock-google-drive # via -r requirements/edx/base.txt +-e git+https://github.com/raccoongang/openedx-events.git@aci.main#egg=openedx_events + # via -r requirements/edx/base.txtß acid-xblock==0.2.1 # via -r requirements/edx/base.txt aiohttp==3.8.3 @@ -942,11 +944,6 @@ openedx-django-pyfs==3.2.1 # via # -r requirements/edx/base.txt # xblock -openedx-events==0.13.0 - # via - # -c requirements/edx/../constraints.txt - # -r requirements/edx/base.txt - # edx-event-bus-kafka openedx-filters==0.8.0 # via # -r requirements/edx/base.txt