【问题标题】:how to run automatically apache airflow tasks如何自动运行apache气流任务
【发布时间】:2018-02-09 12:51:00
【问题描述】:

我正在使用 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)

我搜索了气流文档,但找不到任何东西。

如何自动运行气流 dags?

谢谢,

【问题讨论】:

    标签: python airflow etl directed-acyclic-graphs


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多