Skip to content

Commit

Permalink
Designate a queue for running the pipeline tasks
Browse files Browse the repository at this point in the history
Fix syntax error and PEP8

add space

hardcode worker

fixup! hardcode worker

fix test

fix another test

fix test funtino

fixup! fix test funtino

fix monkeypatch

fixup! fix monkeypatch

fixup! fix monkeypatch

fix test again

fix test again

fix test again

fix test again

remove settings
  • Loading branch information
melvinsoft committed May 26, 2021
1 parent 5a105a8 commit 5a9043d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
28 changes: 28 additions & 0 deletions figures/settings/lms_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ def update_celerybeat_schedule(celerybeat_schedule_settings, figures_env_tokens)
hour=figures_env_tokens.get('DAILY_METRICS_IMPORT_HOUR', 2),
minute=figures_env_tokens.get('DAILY_METRICS_IMPORT_MINUTE', 0),
),
'options': {
'queue': figures_env_tokens.get(
'DAILY_METRICS_IMPORT_QUEUE',
'edx.lms.core.high'
)
},
}

if figures_env_tokens.get('ENABLE_DAILY_MAU_IMPORT', False):
Expand All @@ -48,15 +54,36 @@ def update_celerybeat_schedule(celerybeat_schedule_settings, figures_env_tokens)
hour=figures_env_tokens.get('DAILY_MAU_IMPORT_HOUR', 0),
minute=figures_env_tokens.get('DAILY_MAU_IMPORT_MINUTE', 0),
),
'options': {
'queue': figures_env_tokens.get(
'DAILY_MAU_IMPORT_QUEUE',
'edx.lms.core.high'
)
},
}

if figures_env_tokens.get('ENABLE_FIGURES_MONTHLY_METRICS', True):
celerybeat_schedule_settings['figures-monthly-metrics'] = {
'task': 'figures.tasks.run_figures_monthly_metrics',
'schedule': crontab(0, 0, day_of_month=1),
'options': {
'queue': figures_env_tokens.get(
'FIGURES_MONTHLY_METRICS_QUEUE',
'edx.lms.core.high'
)
},
}


def update_celery_routes(celery_routes_settings, figures_env_tokens):
celery_routes_settings['figures.tasks.run_figures_monthly_metrics'] = {
'queue': figures_env_tokens.get(
'FIGURES_MONTHLY_METRICS_QUEUE',
'edx.lms.core.high'
)
}


def plugin_settings(settings):
"""
Update the LMS/Production (aka AWS) settings to use Figures properly.
Expand All @@ -80,6 +107,7 @@ def plugin_settings(settings):
settings.ENV_TOKENS.setdefault('FIGURES', {})
update_webpack_loader(settings.WEBPACK_LOADER, settings.ENV_TOKENS['FIGURES'])
update_celerybeat_schedule(settings.CELERYBEAT_SCHEDULE, settings.ENV_TOKENS['FIGURES'])
update_celery_routes(settings.CELERY_ROUTES, settings.ENV_TOKENS['FIGURES'])

settings.CELERY_IMPORTS += (
"figures.tasks",
Expand Down
4 changes: 3 additions & 1 deletion tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def test_update_settings(self, figures_env_tokens, run_celery):
'FIGURES': figures_env_tokens,
},
CELERY_IMPORTS=[],
CELERY_ROUTES={},
)
plugin_settings(settings)

Expand Down Expand Up @@ -112,13 +113,14 @@ def setup(self, db):
FEATURES={},
ENV_TOKENS={},
CELERY_IMPORTS=[],
CELERY_ROUTES={},
)

def test_daily_mau_pipeline_flag_enabled(self):
self.settings.ENV_TOKENS['FIGURES'] = { 'ENABLE_DAILY_MAU_IMPORT': True }
plugin_settings(self.settings)
assert self.TASK_NAME in self.settings.CELERYBEAT_SCHEDULE
assert set(['task', 'schedule']) == set(
assert set(['task', 'schedule', 'options']) == set(
self.settings.CELERYBEAT_SCHEDULE[self.TASK_NAME].keys())

def test_daily_mau_pipeline_flag_disabled(self):
Expand Down

0 comments on commit 5a9043d

Please sign in to comment.