如何 运行 自动 apache airflow 任务

how to run automatically apache airflow tasks

我正在使用 Apache Airflow 来安排 python 脚本的 ETL 作业。 当我在气流上创建 dags 时,它会将 dags 状态设置为关闭。我的代码是这样的。

import airflow
from airflow import DAG
from airflow.operators.bash_operator import BashOperator
from datetime import datetime, timedelta

default_args = {
    'owner': 'oguz',
    'depends_on_past': False,
    'start_date': datetime(2018, 1, 25),
    'email': ['airflow@airflow.com'],
    'email_on_failure': False,
    'email_on_retry': False,
    'retries': 1,
    'retry_delay': timedelta(minutes=5),
    'end_date': datetime(9999, 1, 1),
}

dag = DAG('%s', default_args=default_args, schedule_interval='@daily')

# t1 and t2 are examples of tasks created by instantiating operators
t1 = BashOperator(
    task_id='%s',
    bash_command='python /bookmark/ETL/extract/incremental/%s.py',
    dag=dag)

t2 = BashOperator(
    task_id='%s',
    bash_command='python /bookmark/ETL/load/incremental/%s.py',
    retries=3,
    dag=dag)

t2.set_upstream(t1)

我搜索了 airflow 文档,但找不到任何内容。

我怎样才能运行自动气流dags?

谢谢,

如果您在 UI 中将状态切换为 "ON",它应该根据给定的时间间隔(在您的情况下为每天)启动 运行 您的 DAG。如果您希望默认启用新的 DAG,您可以在气流配置中的 [core] 下更新设置 dags_are_paused_at_creation = False