我正在尝试运行过去特定于运行历史记录时间轴的日期。
例如,所附的Figure: Airflow Test {1}节目每天从7月3日至7月8日运行。 但是,我们决定需要在6月29日进行跑步。
我尝试更改一些参数,但没有帮助,直到7月8日它一直执行。Figure: Airflow Test {2}
我尝试用以下参数替换:
“开始日期”:datetime.strptime(“ 2019-06-29”,“%Y-%m-%d”),
schedule_interval =“ @ once”
这是代码:
from datetime import datetime, timedelta, date as dt
import airflow
from airflow import DAG
from airflow.operators.bash_operator import BashOperator
# These args will get passed on to each operator
# You can override them on a per-task basis during operator initialization
default_args = {
'owner': 'airflow',
'depends_on_past': False,
'start_date': datetime.strptime("2019-06-29", "%Y-%m-%d"),#airflow.utils.dates.days_ago(5),
'email': ['airflow@example.com'],
'email_on_failure': False,
'email_on_retry': False,
'retries': 1,
'retry_delay': timedelta(minutes=5),
# 'queue': 'bash_queue',
# 'pool': 'backfill',
# 'priority_weight': 10,
# 'end_date': datetime(2016, 1, 1),
# 'wait_for_downstream': False,
# 'dag': dag,
# 'sla': timedelta(hours=2),
# 'execution_timeout': timedelta(seconds=300),
# 'on_failure_callback': some_function,
# 'on_success_callback': some_other_function,
# 'on_retry_callback': another_function,
# 'sla_miss_callback': yet_another_function,
# 'trigger_rule': 'all_success'
}
dag = DAG(
'tutorial',
default_args=default_args,
description='A simple tutorial DAG',
schedule_interval="@once"#timedelta(days=1),
)
# t1, t2 and t3 are examples of tasks created by instantiating operators
t1 = BashOperator(
task_id='print_date',
bash_command='date',
dag=dag,
)
t1.doc_md = """\
dag.doc_md = __doc__
t2 = BashOperator(
task_id='sleep',
depends_on_past=False,
bash_command='sleep 5',
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',
depends_on_past=False,
bash_command=templated_command,
params={'my_param': 'Parameter I passed in'},
dag=dag,
)
t1 >> [t2, t3]"
预计:该特定日期为6月29日,并且保持运行历史记录。
答案 0 :(得分:1)
我可以使用CLI做到这一点。
气流回填。
气流回填教程-s 2019-06-29 -e 2019-06-29