Gowtham M
Gowtham M

Reputation: 369

Airflow DAGs are successful but tasks are not running

I am trying to run a sample Airflow DAG. The DAG status is successful, but tasks are not running. Can anyone help me understand why?

I've tried the following:

enter image description here

Here is my code:

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

Upvotes: 1

Views: 1668

Answers (1)

Ofek Hod
Ofek Hod

Reputation: 4024

Change the dag_id from my_different_dag to different name, it will actually create a new DAG.
So assuming you configured airflow correctrly it should work now.

Upvotes: 1

Related Questions