From 606f6402e6928d61651bcde17d151b1acdbebf46 Mon Sep 17 00:00:00 2001 From: farhan Date: Sat, 17 Feb 2024 19:01:03 +0500 Subject: [PATCH 1/2] chore: Deprecate the user-retirement scripts that are migrated within edx-platform repo --- tubular/scripts/get_learners_to_retire.py | 3 +++ tubular/scripts/replace_usernames.py | 3 +++ tubular/scripts/retire_one_learner.py | 3 +++ tubular/scripts/retirement_archive_and_cleanup.py | 3 +++ tubular/scripts/retirement_bulk_status_update.py | 3 +++ tubular/scripts/retirement_partner_report.py | 3 +++ tubular/utils/deprecation.py | 14 ++++++++++++++ 7 files changed, 32 insertions(+) create mode 100644 tubular/utils/deprecation.py diff --git a/tubular/scripts/get_learners_to_retire.py b/tubular/scripts/get_learners_to_retire.py index ef36008b..bc4d5fed 100755 --- a/tubular/scripts/get_learners_to_retire.py +++ b/tubular/scripts/get_learners_to_retire.py @@ -12,6 +12,8 @@ import click import yaml +from tubular.utils.deprecation import deprecated_script + # Add top-level module path to sys.path before importing tubular code. sys.path.append(path.dirname(path.dirname(path.abspath(__file__)))) @@ -49,6 +51,7 @@ "setting then it will not error.", default=200 ) +@deprecated_script def get_learners_to_retire(config_file, cool_off_days, output_dir, diff --git a/tubular/scripts/replace_usernames.py b/tubular/scripts/replace_usernames.py index b3913fda..27827dc4 100644 --- a/tubular/scripts/replace_usernames.py +++ b/tubular/scripts/replace_usernames.py @@ -17,6 +17,8 @@ import click import yaml +from tubular.utils.deprecation import deprecated_script + # Add top-level module path to sys.path before importing tubular code. sys.path.append(path.dirname(path.dirname(path.abspath(__file__)))) @@ -42,6 +44,7 @@ def write_responses(writer, replacements, status): '--username_replacement_csv', help='File in which YAML config exists that overrides all other params.' ) +@deprecated_script def replace_usernames(config_file, username_replacement_csv): """ Retrieves a JWT token as the retirement service user, then calls the LMS diff --git a/tubular/scripts/retire_one_learner.py b/tubular/scripts/retire_one_learner.py index 45232c4d..586f1a8f 100755 --- a/tubular/scripts/retire_one_learner.py +++ b/tubular/scripts/retire_one_learner.py @@ -30,6 +30,8 @@ import click +from tubular.utils.deprecation import deprecated_script + # Add top-level module path to sys.path before importing tubular code. sys.path.append(path.dirname(path.dirname(path.abspath(__file__)))) @@ -154,6 +156,7 @@ def _get_ecom_segment_id(config, learner): '--config_file', help='File in which YAML config exists that overrides all other params.' ) +@deprecated_script def retire_learner( username, config_file diff --git a/tubular/scripts/retirement_archive_and_cleanup.py b/tubular/scripts/retirement_archive_and_cleanup.py index 03ca93d4..5c868c69 100644 --- a/tubular/scripts/retirement_archive_and_cleanup.py +++ b/tubular/scripts/retirement_archive_and_cleanup.py @@ -19,6 +19,8 @@ from botocore.exceptions import BotoCoreError, ClientError from six import text_type +from tubular.utils.deprecation import deprecated_script + # Add top-level module path to sys.path before importing tubular code. sys.path.append(path.dirname(path.dirname(path.abspath(__file__)))) @@ -263,6 +265,7 @@ def _get_utc_now(): help='Number of user retirements to process', type=int ) +@deprecated_script def archive_and_cleanup(config_file, cool_off_days, dry_run, start_date, end_date, batch_size): """ Cleans up UserRetirementStatus rows in LMS by: diff --git a/tubular/scripts/retirement_bulk_status_update.py b/tubular/scripts/retirement_bulk_status_update.py index a6b41676..4c512fe0 100755 --- a/tubular/scripts/retirement_bulk_status_update.py +++ b/tubular/scripts/retirement_bulk_status_update.py @@ -13,6 +13,8 @@ import click from six import text_type +from tubular.utils.deprecation import deprecated_script + # Add top-level module path to sys.path before importing tubular code. sys.path.append(path.dirname(path.dirname(path.abspath(__file__)))) @@ -127,6 +129,7 @@ def _update_learners_or_exit(config, learners, new_state=None, rewind_state=Fals default=False, is_flag=True ) +@deprecated_script def update_statuses(config_file, initial_state, new_state, start_date, end_date, rewind_state): """ Bulk-updates user retirement statuses which are in the specified state -and- retirement was diff --git a/tubular/scripts/retirement_partner_report.py b/tubular/scripts/retirement_partner_report.py index 3c1e6fd7..3c2dd0dc 100755 --- a/tubular/scripts/retirement_partner_report.py +++ b/tubular/scripts/retirement_partner_report.py @@ -17,6 +17,8 @@ import click from six import text_type +from tubular.utils.deprecation import deprecated_script + # Add top-level module path to sys.path before importing tubular code. sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) @@ -354,6 +356,7 @@ def _add_comments_to_files(config, file_ids): default=True, help='Do or skip adding notification comments to the reports.' ) +@deprecated_script def generate_report(config_file, google_secrets_file, output_dir, comments): """ Retrieves a JWT token as the retirement service learner, then performs the reporting process as that user. diff --git a/tubular/utils/deprecation.py b/tubular/utils/deprecation.py new file mode 100644 index 00000000..20ec46c8 --- /dev/null +++ b/tubular/utils/deprecation.py @@ -0,0 +1,14 @@ +import warnings + +import click + + +def deprecated_script(func): + def wrapper(*args, **kwargs): + warning = f"WARNING: Script {func.__module__} has been marked deprecated and " \ + f"migrated to within 'edx-platform' repository." + warnings.warn(warning, DeprecationWarning, stacklevel=3) + click.secho(warning, fg="yellow", bold=True) + func(*args, **kwargs) + + return wrapper From 5bed44c54270df8e91e5abc60e84d76053f5e1f3 Mon Sep 17 00:00:00 2001 From: farhan Date: Fri, 23 Feb 2024 16:09:48 +0500 Subject: [PATCH 2/2] chore: Update readme --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index a3992254..e601812d 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,32 @@ Python scripts for integrating pipelines with various services/tools such as: The scripts perform work to enable continuous delivery (CD) for https://edx.org. These scripts are called from various tasks/jobs/stages in GoCD pipelines - but could be called from any automation/CD framework. + +## ⚠️ Deprecation Notice ⚠️ + +**Effective Date:** February 26, 2024 + +**Repository Migration:** +Following scripts related to user retirement feature has been [deprecated](https://github.com/openedx/axim-engineering/issues/881) +and migrated [here](https://github.com/openedx/edx-platform/tree/master/scripts/user_retirement) on `edx-platform` repository. + +- `tubular/scripts/get_learners_to_retire.py` +- `tubular/scripts/replace_usernames.py` +- `tubular/scripts/retire_one_learner.py` +- `tubular/scripts/retirement_archive_and_cleanup.py` +- `tubular/scripts/retirement_bulk_status_update.py` +- `tubular/scripts/retirement_partner_report.py` + +This decision was made to streamline and consolidate our codebase. + +The migration process was completed through this Pull Request: [PR #34063](https://github.com/openedx/edx-platform/pull/34063) + +**Archival**: Afterwards we are going to archive the `tubular` repository. This means that it will become read-only, and no further updates or changes will be accepted. + +We appreciate your understanding and cooperation during this transition. If you have any questions or concerns, please don't hesitate to reach out to us. + +Thank you for your continued support and contributions to the Open edX community. + ## Configuration ``` pip install -e .[dev]