forked from LAION-AI/Open-Assistant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcelery_worker.py
32 lines (28 loc) · 1019 Bytes
/
celery_worker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
from celery import Celery
from loguru import logger
"""
To run the worker run `celery run -A oasst_backend.celery_worker worker -l INFO`
in the parent directory of this file, add -B to embed the beat scheduler inside
the worker.
"""
app = Celery(
"oasst_worker",
broker=os.environ.get("CELERY_BROKER_URL", "redis://localhost:6379/0"),
backend=os.environ.get("CELERY_RESULT_BACKEND", "redis://localhost:6379/0"),
include=["oasst_backend.scheduled_tasks"],
)
logger.info(f"celery.conf.broker_url {app.conf.broker_url}, app.conf.result_backend{app.conf.result_backend}")
# see https://docs.celeryq.dev/en/stable/userguide/periodic-tasks.html
app.conf.beat_schedule = {
"reset-user-streak": {
"task": "periodic_user_streak_reset",
"schedule": 60.0 * 60.0 * 4, # in seconds, every 4h
},
"update-search-vectors": {
"task": "update_search_vectors",
"schedule": 60.0 * 20.0,
"args": (1000,), # (batch_size,)
},
}
app.conf.timezone = "UTC"