From 3e7eeb66d1dcd13b4cfe9a24fa258a4905edef90 Mon Sep 17 00:00:00 2001 From: Robert Raposa Date: Thu, 5 Dec 2024 15:30:18 -0500 Subject: [PATCH] feat!: remove code owner optional prefix paths (#867) This implements a TODO comment stating that once edx-platform import_shims is no longer used, we could remove the _OPTIONAL_MODULE_PREFIX_PATTERN implementation. See https://github.com/openedx/edx-platform/tree/854502b560bda74ef898501bb2a95ce238cf794c/import_shims Phase 1 of the code owner refactor is an opportune time to make this clean-up because we can compare code_owner and code_owner_2 results. See https://github.com/edx/edx-arch-experiments/issues/784 --- .../datadog_monitoring/code_owner/utils.py | 12 ------------ .../tests/code_owner/test_utils.py | 3 --- 2 files changed, 15 deletions(-) diff --git a/edx_arch_experiments/datadog_monitoring/code_owner/utils.py b/edx_arch_experiments/datadog_monitoring/code_owner/utils.py index ecff3af..72ca14f 100644 --- a/edx_arch_experiments/datadog_monitoring/code_owner/utils.py +++ b/edx_arch_experiments/datadog_monitoring/code_owner/utils.py @@ -2,7 +2,6 @@ Utilities for monitoring code_owner_2 """ import logging -import re from django.conf import settings from edx_django_utils.monitoring import set_custom_attribute @@ -95,11 +94,6 @@ def get_code_owner_mappings(): path_list = code_owner_mappings[code_owner] for path in path_list: path_to_code_owner_mapping[path] = code_owner - optional_module_prefix_match = _OPTIONAL_MODULE_PREFIX_PATTERN.match(path) - # if path has an optional prefix, also add the module name without the prefix - if optional_module_prefix_match: - path_without_prefix = path[optional_module_prefix_match.end():] - path_to_code_owner_mapping[path_without_prefix] = code_owner except TypeError as e: log.exception( 'Error processing CODE_OWNER_MAPPINGS. {}'.format(e) # pylint: disable=logging-format-interpolation @@ -157,12 +151,6 @@ def clear_cached_mappings(): _CODE_OWNER_TO_THEME_AND_SQUAD_MAPPINGS = None -# TODO: Retire this once edx-platform import_shims is no longer used. -# Note: This should be ready for removal because import_shims has been removed. -# See https://github.com/openedx/edx-platform/tree/854502b560bda74ef898501bb2a95ce238cf794c/import_shims -_OPTIONAL_MODULE_PREFIX_PATTERN = re.compile(r'^(lms|common|openedx\.core)\.djangoapps\.') - - # Cached lookup table for code owner theme and squad given a code owner. # - Although code owner is "theme-squad", a hyphen may also be in the theme or squad name, so this ensures we get both # correctly from config. diff --git a/edx_arch_experiments/datadog_monitoring/tests/code_owner/test_utils.py b/edx_arch_experiments/datadog_monitoring/tests/code_owner/test_utils.py index be17856..68357f4 100644 --- a/edx_arch_experiments/datadog_monitoring/tests/code_owner/test_utils.py +++ b/edx_arch_experiments/datadog_monitoring/tests/code_owner/test_utils.py @@ -36,13 +36,10 @@ def setUp(self): @ddt.data( ('xbl', None), ('xblock_2', None), - ('xblock', 'team-red'), ('openedx.core.djangoapps', None), ('openedx.core.djangoapps.xblock', 'team-red'), ('openedx.core.djangoapps.xblock.views', 'team-red'), - ('grades', 'team-red'), ('lms.djangoapps.grades', 'team-red'), - ('xblock_django', 'team-blue'), ('common.djangoapps.xblock_django', 'team-blue'), ) @ddt.unpack