-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pend deprecation populate_figures_metrics, replace functionality
pass --mau usage to new run_figures_mau_metrics pass other usage to backfill_figures_daily_metrics (with start and end date of single date passed )
- Loading branch information
1 parent
4f166fa
commit 459b181
Showing
2 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
""" | ||
Deprecated: | ||
Please call instead backfill_figures_daily_metrics. | ||
Management command to manually populate course metrics | ||
see the model ``edx_figures.models.CourseDailyMetrics`` | ||
""" | ||
|
||
from __future__ import print_function | ||
|
||
from __future__ import absolute_import | ||
from textwrap import dedent | ||
import warnings | ||
|
||
from django.core.management import call_command | ||
from django.core.management.base import BaseCommand | ||
|
||
|
||
class Command(BaseCommand): | ||
'''Populate Figures metrics models | ||
''' | ||
help = dedent(__doc__).strip() | ||
|
||
def add_arguments(self, parser): | ||
''' | ||
''' | ||
|
||
parser.add_argument('--date', | ||
help='date for which we are retrieving data in yyyy-mm-dd format') | ||
parser.add_argument('--no-delay', | ||
action='store_true', | ||
default=False, | ||
help='Disable the celery "delay" directive') | ||
parser.add_argument('--force-update', | ||
action='store_true', | ||
default=False, | ||
help='Overwrite metrics records if they exist for the given date') | ||
parser.add_argument('--experimental', | ||
action='store_true', | ||
default=False, | ||
help=('Run with Celery workflows (Warning: This is still under' + | ||
' development and likely to get stuck/hung jobs')) | ||
parser.add_argument('--mau', | ||
action='store_true', | ||
default=False, | ||
help='Run just the MAU pipeline') | ||
|
||
def handle(self, *args, **options): | ||
''' | ||
Pending deprecation. Passes handling off to new commands. | ||
The 'mau' conditional check in this method is a quick hack to run the | ||
MAU task from this command. What we probably want is a 'figures_cli' | ||
command with subcommands. | ||
''' | ||
warnings.warn( | ||
"populate_figures_metrics is pending deprecation and will be removed in " | ||
"Figures 1.0. Please use backfill_figures_daily_metrics, instead; or, " | ||
"if you were calling with --mau option, use populate_figures_mau_metrics.", | ||
PendingDeprecationWarning | ||
) | ||
print('populating Figures metrics...') | ||
|
||
if options['mau']: | ||
call_command('run_figures_mau_metrics', no_delay=options['no_delay']) | ||
else: | ||
call_command( | ||
'backfill_figures_daily_metrics', | ||
no_delay=options['no_delay'], | ||
date_start=options['date'], | ||
date_end=options['date'], | ||
overwrite=options['force_update'], | ||
experimental=options['experimental'] | ||
) | ||
|
||
# TODO: improve this message to say 'today' when options['date'] is None | ||
print('Management command populate_figures_metrics complete. date_for: {}'.format( | ||
options['date'])) | ||
print('Done.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""Figures management command to run course MAU metrics for all courses, all Sites. | ||
""" | ||
|
||
from __future__ import print_function | ||
|
||
from __future__ import absolute_import | ||
|
||
from textwrap import dedent | ||
|
||
from django.core.management.base import BaseCommand | ||
|
||
from figures.tasks import ( | ||
populate_all_mau | ||
) | ||
|
||
|
||
class Command(BaseCommand): | ||
"""Task runner to kick off Figures celery tasks | ||
""" | ||
help = dedent(__doc__).strip() | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument('--no-delay', | ||
action='store_true', | ||
default=False, | ||
help='Disable the celery "delay" directive') | ||
|
||
def handle(self, *args, **options): | ||
print('Starting Figures MAU metrics for all Sites...') | ||
|
||
if options['no_delay']: | ||
populate_all_mau() | ||
else: | ||
populate_all_mau.delay() | ||
|
||
print('Done.') |