Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #736 from farhan/farhan/deprecate-user-retirement-…
Browse files Browse the repository at this point in the history
…code

Deprecate User Retirement Scripts
  • Loading branch information
Feanil Patel authored Feb 26, 2024
2 parents 82f39d6 + 5bed44c commit 1b8a6cb
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 3 additions & 0 deletions tubular/scripts/get_learners_to_retire.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))))

Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions tubular/scripts/replace_usernames.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))))

Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions tubular/scripts/retire_one_learner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))))

Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions tubular/scripts/retirement_archive_and_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))))

Expand Down Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions tubular/scripts/retirement_bulk_status_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))))

Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions tubular/scripts/retirement_partner_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))))

Expand Down Expand Up @@ -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.
Expand Down
14 changes: 14 additions & 0 deletions tubular/utils/deprecation.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1b8a6cb

Please sign in to comment.