气流DAG成功,但任务未运行

时间:2020-03-14 13:24:22

标签: airflow

我正在尝试运行Airflow DAG示例。 DAG状态为成功,但是任务未运行。谁能帮我理解为什么?

我尝试了以下操作:

  • 将开始日期更改为过去日期
  • 重新启动Web服务器和调度程序

enter image description here

这是我的代码:

import datetime as dt

from airflow import DAG
from airflow.operators.bash_operator import BashOperator
from airflow.operators.python_operator import PythonOperator
print('test1')
def greet():
    print('Writing in file')
    print('testing the dag')
    with open('/Users/abc/Documents/airflow_workspace/greet.txt', 'a+', encoding='utf8') as f:
        now = dt.datetime.now()
        t = now.strftime("%Y-%m-%d %H:%M")
        f.write(str(t) + '\n')
    return 'Greeted'
def respond():
    return 'Greet Responded Again'

default_args = {
    'owner': 'airflow',
    'start_date': dt.datetime(2019, 3, 12, 10, 00, 00),
    'concurrency': 1,
    'retries': 0
}

with DAG('my_simple_dag',
         default_args=default_args,
         schedule_interval='*/10 * * * *',
         ) as dag:
    opr_hello = BashOperator(task_id='say_Hi',
                             bash_command='echo "Hi!!"')

    opr_greet = PythonOperator(task_id='greet',
                               python_callable=greet)
    opr_sleep = BashOperator(task_id='sleep_me',
                             bash_command='sleep 5')

    opr_respond = PythonOperator(task_id='respond',
                                 python_callable=respond)
print('test2')
opr_hello >> opr_greet >> opr_sleep >> opr_respond

1 个答案:

答案 0 :(得分:1)

dag_idmy_different_dag更改为其他名称,它实际上将创建一个新的DAG。
因此,假设您正确配置了气流,它现在应该可以工作。