为Airflow添加额外的芹菜配置

Ace*_*rey 4 celery airflow

谁知道我可以在哪里添加额外的芹菜配置到气流芹菜执行器?例如,我想http://docs.celeryproject.org/en/latest/userguide/configuration.html#worker-pool-restarts这个属性,但我如何允许额外的芹菜属性..

Ash*_*lor 7

使用刚刚发布的Airflow 1.9.0,现在可配置.

在airflow.cfg中有这一行:

# Import path for celery configuration options
celery_config_options = airflow.config_templates.default_celery.DEFAULT_CELERY_CONFIG
Run Code Online (Sandbox Code Playgroud)

它指向导入路径中的python文件.当前的默认版本可以是https://github.com/apache/incubator-airflow/blob/1.9.0/airflow/config_templates/default_celery.py

如果您需要通过该文件无法调整的设置,请创建一个新模块,例如'my_celery_config.py':

CELERY_CONFIG = {
    # ....
}
Run Code Online (Sandbox Code Playgroud)

并将其放在AIRFLOW_HOME目录中(即在dags /文件夹旁边),然后celery_config_options = my_celery_config.CELERY_CONFIG在配置中设置.

  • 扩展您的答案:`from airflow.config_templates.default_celery import DEFAULT_CELERY_CONFIG``CELERY_CONFIG = dict(DEFAULT_CELERY_CONFIG,** {key1:value1,...})`将为您提供所有常规默认值,并覆盖您的值 (2认同)