Vijay
Vijay

Reputation: 49

Airflow tasks not gettin running

I am trying to run a simple BASHOperator task in Airflow. The DAG when trigerred manually lists the tasks in Tree and Graph view but the tasks are always in not started state.

I have restarted my Airflow scheduler. I am running Airflow on local host using a Kubectl image on Docker Compose.

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

default_args = {
    'owner': 'airflow',
    'depends_on_past': False,
    'email': ['[email protected]'],
    'email_on_success': True,
    'email_on_failure': True,
    'email_on_retry': False,
    'retries': 1,
    'retry_delay': timedelta(minutes=2),
}

with DAG(
    dag_id='bash_demo',
    default_args=default_args,
    description='Bash Demo',
    start_date=datetime(2021, 1, 1),
    # schedule_interval='0 2 * * *',
    schedule_interval=None,
    max_active_runs=1,
    catchup=False,
    tags=['bash_demo'],
) as dag:
    dag.doc_md = __doc__

    # Task 1
    dummy_task = DummyOperator(task_id='dummy_task')

    # Task 2
    bash_task = BashOperator(
        task_id='bash_task', bash_command="echo 'command executed from BashOperator'")

    dummy_task >> bash_task

DAG Image

Upvotes: 1

Views: 248

Answers (1)

Elad Kalif
Elad Kalif

Reputation: 15931

As shown on the image you added the DAG is set to off thus it's not running. You should click on the toggle button to set it to on.

enter image description here

This issue can be avoided in two ways:

Global solution- if you wills set dags_are_paused_at_creation = False in airflow.cfg - This will effect all DAGs in the system.

Local solution - if you will use is_paused_upon_creation in the DAG contractor:

with DAG(
    dag_id='bash_demo',
    ...
    is_paused_upon_creation=False,
) as dag:

This parameter specifies if the dag is paused when created for the first time. If the dag exists already, the parameter is being ignored.

Upvotes: 1

Related Questions