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

Commit

Permalink
chore: Deprecate the user-retirement scripts that are migrated within…
Browse files Browse the repository at this point in the history
… edx-platform repo
  • Loading branch information
farhan committed Feb 17, 2024
1 parent 82f39d6 commit 606f640
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 0 deletions.
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 606f640

Please sign in to comment.