diff --git a/src/pypelines/__init__.py b/src/pypelines/__init__.py index 2f181b6bcfcc656af55bbc407ef1f46a459e9e6d..a1932b5975acfcce377aeb9919a04ae9bf12ab36 100644 --- a/src/pypelines/__init__.py +++ b/src/pypelines/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.0.48" +__version__ = "0.0.49" from . import loggs from .pipes import * diff --git a/src/pypelines/celery_tasks.py b/src/pypelines/celery_tasks.py index 4c2301b6588cb9b6c2aa3f964eacefe4050b6e64..2ee1cce689b20dcfcfd8d9996c25ea78cd3353b7 100644 --- a/src/pypelines/celery_tasks.py +++ b/src/pypelines/celery_tasks.py @@ -316,8 +316,26 @@ class LogTask: def create_celery_app(conf_path, app_name="pypelines", v_host=None) -> "Celery | None": + + failure_message = ( + f"Celery app : {app_name} failed to be created." + "Don't worry, about this alert, " + "this is not be an issue if you didn't explicitely planned on using celery. Issue was : " + ) + + logger = getLogger("pypelines.create_celery_app") + + if app_name in APPLICATIONS_STORE.keys(): + logger.warning(f"Tried to create a celery app named {app_name}, but it already exists. Returning it instead.") + return APPLICATIONS_STORE[app_name] + + try: + from celery import Task + except ImportError as e: + logger.warning(f"{failure_message} Could not import celery app. {e}") + return None + from types import MethodType - from celery import Task def get_setting_files_path(conf_path) -> List[Path]: conf_path = Path(conf_path) @@ -480,18 +498,6 @@ def create_celery_app(conf_path, app_name="pypelines", v_host=None) -> "Celery | ) return task_record - failure_message = ( - f"Celery app : {app_name} failed to be created." - "Don't worry, about this alert, " - "this is not be an issue if you didn't explicitely planned on using celery. Issue was : " - ) - - logger = getLogger("pypelines.create_celery_app") - - if app_name in APPLICATIONS_STORE.keys(): - logger.warning(f"Tried to create a celery app named {app_name}, but it already exists. Returning it instead.") - return APPLICATIONS_STORE[app_name] - settings_files = get_setting_files_path(conf_path) if len(settings_files) == 0: