Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Airflow, enable dag on creation

Tags:

python

airflow

When I create a DAG with air flow in python I can pass some parameters.

SETTINGS = {
    'owner': 'hello',
    'depends_on_past': False,
    'start_date': datetime(2019, 1, 1),
    'email_on_failure': False,
    'email_on_retry': False,
    'retries': 1,
    'retry_delay': timedelta(minutes=5),
 }
dag = DAG(dag_id,
              schedule_interval='@daily',
              catchup=False,
              default_args=SETTINGS)

Yet when I do so, I still have to go on the interface and to enable the DAG with a click. I would like to know if there is a settings to pass to do it directly on creation. I think it has something to do with "pause" but can't find the name of the parameter.

like image 727
Robert Reynolds Avatar asked Sep 16 '19 09:09

Robert Reynolds


2 Answers

Change dags_are_paused_at_creation in airflow.cfg to False. The default value is True, so your dags are paused at creation.

[core]
dags_are_paused_at_creation = False

Set the following environment variable.

AIRFLOW__CORE__DAGS_ARE_PAUSED_AT_CREATION=False

If you want to limit this setting for a single DAG you can set is_paused_upon_creation DAG parameter to True.

Example:

DAG(dag_id='my-dag', is_paused_upon_creation=True)
like image 143
kaxil Avatar answered Oct 01 '22 15:10

kaxil


There is a parameter for a DAG: is_paused_upon_creation. I haven't tried to use it, but you can find some information in the source code: https://github.com/apache/airflow/blob/master/airflow/models/dag.py

like image 27
amoskaliov Avatar answered Oct 01 '22 13:10

amoskaliov