diff --git a/src/celery_app/app.py b/src/celery_app/app.py index 421037544..05bd706c6 100644 --- a/src/celery_app/app.py +++ b/src/celery_app/app.py @@ -6,8 +6,8 @@ from celery import Celery, signals from sentry_sdk.integrations.celery import CeleryIntegration +from seer.bootup import bootup_celery from celery_app.config import CeleryConfig -from seer.bootup import bootup from seer.dependency_injection import inject, injected logger = logging.getLogger(__name__) @@ -23,7 +23,7 @@ def setup_celery_entrypoint(app: Celery): def init_celery_app(*args: Any, sender: Celery, config: CeleryConfig = injected, **kwargs: Any): for k, v in config.items(): setattr(sender.conf, k, v) - bootup(start_model_loading=False, integrations=[CeleryIntegration(propagate_traces=True)]) + bootup_celery(integrations=[CeleryIntegration(propagate_traces=True)]) from celery_app.tasks import setup_periodic_tasks sender.on_after_finalize.connect(setup_periodic_tasks) diff --git a/src/seer/bootup.py b/src/seer/bootup.py index 2bd03b18f..b3c6489ef 100644 --- a/src/seer/bootup.py +++ b/src/seer/bootup.py @@ -32,13 +32,27 @@ class DisablePreparedStatementConnection(Connection): @inject -def bootup( +def bootup_something( *, start_model_loading: bool, integrations: list[Integration], config: AppConfig = injected ): initialize_sentry_sdk(integrations) with sentry_sdk.metrics.timing(key="seer_bootup_time"): initialize_logs(["seer.", "celery_app."]) config.do_validation() + +@inject +def bootup( + *, start_model_loading: bool, integrations: list[Integration], config: AppConfig = injected +): + bootup_core(start_model_loading=start_model_loading, integrations=integrations) + initialize_database() + initialize_models(start_model_loading) + +@inject +def bootup_celery(*, integrations: list[Integration], config: AppConfig = injected): + """Celery-specific initialization that avoids database setup""" + bootup_core(start_model_loading=False, integrations=integrations) + initialize_models(start_model_loading=False) initialize_database() initialize_models(start_model_loading)