Reputation: 5355
I'm completely new to Airflow, and I really struggle getting a very simple test DAG to run:
from airflow import DAG
from datetime import datetime, timedelta
from airflow.utils.dates import days_ago
from airflow.operators.bash import BashOperator
default_args ={
"owner":"airflow",
"depends_on_past":False,
"retries":0,
"email": ["[email protected]"],
"email_on_failure":True
}
dag = DAG(dag_id="create_test_folder",
default_args=default_args,
start_date = days_ago(1),
catchup=False,
schedule_interval="@once")
start = BashOperator(task_id="start",dag=dag,bash_command="mkdir ~/airflow/test_folder")
end = BashOperator(task_id="end",dag=dag,bash_command="date")
start>>end
If I open the webserver and press "trigger DAG" it is stuck under "running" and seems to never start (the tree-diagram says "not started")
Upvotes: 2
Views: 1106
Reputation: 15911
Your DAG isn't running because it's paused. You need to unpause it.
Note that you can avoid this issue by using is_paused_upon_creation
this flag specifies if the dag is paused when created for the first time.
If the dag exists already, this flag will be ignored.
dag = DAG(dag_id="create_test_folder",
default_args=default_args,
start_date=days_ago(1),
catchup=False,
schedule_interval="@once",
is_paused_upon_creation=False
)
You can also set up it globally in airflow.cfg
or by setting env var: AIRFLOW__CORE__DAGS_ARE_PAUSED_AT_CREATION
Upvotes: 1