Apache airflow:将catchup设置为False不起作用

问题描述 投票:4回答:1

我在Apache airflow上创建了一个DAG。似乎调度程序配置为从2015年6月运行它(顺便说一下。我不知道为什么,但它是一个新的DAG y创建并且我没有回填它,我只回填了其他具有不同DAG ID的dag日期间隔,调度程序采取了那些日期,并填写了我的新dag。我开始使用气流)。

(更新:我意识到DAG已回填,因为开始日期是在DAG默认配置上设置的,尽管这并不能解释我在下面公开的行为)

我试图阻止调度程序从该日期开始运行所有DAG执行。 airflow backfill --mark_success tutorial2 -s '2015-06-01' -e '2019-02-27'命令给我数据库错误(见下文),所以我试图将catchup设置为False。

sqlalchemy.exc.OperationalError:(sqlite3.OperationalError)没有这样的表:job [SQL:'INSERT INTO job(dag_id,state,job_type,start_date,end_date,latest_heartbeat,executor_class,hostname,unixname)VALUES(?,?,?, ?,?,?,?,?,?)'] [参数:('tutorial2','running','BackfillJob','2019-02-27 10:52:37.281716',无,'2019-02- 27 10:52:37.281733','SequentialExecutor','08b6eb432df9','airflow')](关于此错误的背景:http://sqlalche.me/e/e3q8

所以我正在使用另一种方法。我尝试过的:

  1. 在airflow.cfg中设置catchup_by_default = False并重新启动整个docker容器。
  2. 在我的python DAG文件上设置catchup = False并再次使用python启动该文件。

我在网络用户界面上看到的内容:

DAG的执行将于2015年6月开始执行:在DAG​​的配置中,DAG's executions are being launched starting at June 2015. Catchup设置为False:

Catchup is set to False on DAG's configuration所以我不明白为什么那些DAG的执行正在发布。

谢谢

日代码:

"""
Code that goes along with the Airflow tutorial located at:
https://github.com/apache/airflow/blob/master/airflow/example_dags/tutorial.py
"""
from airflow import DAG
from airflow.operators.bash_operator import BashOperator
from datetime import datetime, timedelta


default_args = {
    'owner': 'airflow',
    'depends_on_past': False,
    'start_date': datetime(2015, 6, 1),
    'email': ['[email protected]'],
    'email_on_failure': False,
    'email_on_retry': False,
    'retries': 1,
    'retry_delay': timedelta(minutes=5),
    'catchup' : False,
    # 'queue': 'bash_queue',
    # 'pool': 'backfill',
    # 'priority_weight': 10,
    # 'end_date': datetime(2016, 1, 1),
}

dag = DAG(
    'tutorial2', default_args=default_args, schedule_interval='* * * * *')

# t1, t2 and t3 are examples of tasks created by instantiating operators
t1 = BashOperator(
    task_id='print_date',
    bash_command='date',
    dag=dag)

t2 = BashOperator(
    task_id='sleep',
    bash_command='sleep 5',
    retries=3,
    dag=dag)

templated_command = """
    {% for i in range(5) %}
        echo "{{ ds }}"
        echo "{{ macros.ds_add(ds, 7)}}"
        echo "{{ params.my_param }}"
    {% endfor %}
"""

t3 = BashOperator(
    task_id='templated',
    bash_command=templated_command,
    params={'my_param': 'Parameter I passed in'},
    dag=dag)

t2.set_upstream(t1)
t3.set_upstream(t1)
scheduler airflow
1个回答
0
投票

我认为你实际上需要在dag级别指定追赶,而不是通过default_args传递它。 (后者无论如何都没有意义,因为这些是任务的默认参数。你不能让一些任务赶上而其他任务没有。)

试试这个:

dag = DAG(
    'tutorial2', default_args=default_args, schedule_interval='* * * * *', catchup=False)
© www.soinside.com 2019 - 2024. All rights reserved.