Skip to content

Commit

Permalink
update celery beat scheduler time to env (#6352)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnJyong authored Jul 16, 2024
1 parent 06fcc0c commit 7c397f5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions api/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,7 @@ WORKFLOW_CALL_MAX_DEPTH=5
# App configuration
APP_MAX_EXECUTION_TIME=1200
APP_MAX_ACTIVE_REQUESTS=0


# Celery beat configuration
CELERY_BEAT_SCHEDULER_TIME=1
9 changes: 9 additions & 0 deletions api/configs/feature/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class SecurityConfig(BaseSettings):
default=24,
)


class AppExecutionConfig(BaseSettings):
"""
App Execution configs
Expand Down Expand Up @@ -435,6 +436,13 @@ class ImageFormatConfig(BaseSettings):
)


class CeleryBeatConfig(BaseSettings):
CELERY_BEAT_SCHEDULER_TIME: int = Field(
description='the time of the celery scheduler, default to 1 day',
default=1,
)


class FeatureConfig(
# place the configs in alphabet order
AppExecutionConfig,
Expand Down Expand Up @@ -462,5 +470,6 @@ class FeatureConfig(

# hosted services config
HostedServiceConfig,
CeleryBeatConfig,
):
pass
6 changes: 3 additions & 3 deletions api/extensions/ext_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ def __call__(self, *args: object, **kwargs: object) -> object:
"schedule.clean_embedding_cache_task",
"schedule.clean_unused_datasets_task",
]

day = app.config["CELERY_BEAT_SCHEDULER_TIME"]
beat_schedule = {
'clean_embedding_cache_task': {
'task': 'schedule.clean_embedding_cache_task.clean_embedding_cache_task',
'schedule': timedelta(days=1),
'schedule': timedelta(days=day),
},
'clean_unused_datasets_task': {
'task': 'schedule.clean_unused_datasets_task.clean_unused_datasets_task',
'schedule': timedelta(minutes=3),
'schedule': timedelta(days=day),
}
}
celery_app.conf.update(
Expand Down

0 comments on commit 7c397f5

Please sign in to comment.