From 4718af6512c8503f93cb7c2da1196da7c25b3a4b Mon Sep 17 00:00:00 2001 From: Cristhian Garcia Date: Fri, 22 Nov 2024 11:15:27 -0500 Subject: [PATCH] refactor!: use new filter to define celery command --- tutorcelery/__about__.py | 2 +- tutorcelery/patches/k8s-override | 26 -------------------------- tutorcelery/plugin.py | 14 +++++++++++++- 3 files changed, 14 insertions(+), 28 deletions(-) delete mode 100644 tutorcelery/patches/k8s-override diff --git a/tutorcelery/__about__.py b/tutorcelery/__about__.py index 0122a6f..22ed769 100644 --- a/tutorcelery/__about__.py +++ b/tutorcelery/__about__.py @@ -1 +1 @@ -__version__ = "19.0.0" +__version__ = "18.3.0" diff --git a/tutorcelery/patches/k8s-override b/tutorcelery/patches/k8s-override deleted file mode 100644 index 3d3eda8..0000000 --- a/tutorcelery/patches/k8s-override +++ /dev/null @@ -1,26 +0,0 @@ -{% for service in ["lms", "cms"] %} -{% set exclude = "lms" if service == "cms" else "cms" %} -{% set service_variants = iter_celery_workers_config().get(service) %} ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{service}}-worker -spec: - template: - spec: - containers: - - name: {{service}}-worker - args: - - "celery" - - "--app={{service}}.celery" - - "worker" - - "--loglevel=info" - - "--hostname=edx.{{service}}.core.default.%%h" - - "--max-tasks-per-child=100" - {% if is_celery_multiqueue(service) -%} - - "--queues=edx.{{service}}.core.default" - {% else -%} - - "--exclude-queues=edx.{{exclude}}.core.default" - {% endif -%} -{% endfor %} diff --git a/tutorcelery/plugin.py b/tutorcelery/plugin.py index afcdbd3..3a291ed 100644 --- a/tutorcelery/plugin.py +++ b/tutorcelery/plugin.py @@ -6,7 +6,7 @@ import click import importlib_resources import tutor -from tutor import hooks +from tutor import hooks, config from .__about__ import __version__ from .hooks import CELERY_WORKERS_CONFIG, CELERY_WORKERS_ATTRS_TYPE @@ -80,6 +80,18 @@ def is_celery_multiqueue(service: str) -> bool: return True +@hooks.Actions.PROJECT_ROOT_READY.add() +def run_this_on_start(config): + if is_celery_multiqueue("lms"): + hooks.Filters.LMS_WORKER_COMMAND.add_items([ + "--queues=edx.lms.core.default" + ]) + if is_celery_multiqueue("cms"): + hooks.Filters.CMS_WORKER_COMMAND.add_items([ + "--queues=edx.cms.core.default" + ]) + + hooks.Filters.CONFIG_DEFAULTS.add_items( [ # Add your new settings that have default values here.