Last active
December 25, 2018 18:47
-
-
Save kaxil/0007846c885950da9d2488756630db3e to your computer and use it in GitHub Desktop.
Example DAG to showcase repeating dag parameter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Normal DAG without Context Manager | |
args = { | |
'owner': 'airflow', | |
'start_date': airflow.utils.dates.days_ago(2), | |
} | |
dag = DAG( | |
dag_id='example_dag', | |
default_args=args, | |
schedule_interval='0 0 * * *', | |
) | |
run_this_last = DummyOperator( | |
task_id='run_this_last', | |
dag=dag, # You need to repeat this for each task | |
) | |
run_this_first = BashOperator( | |
task_id='run_this_first', | |
bash_command='echo 1', | |
dag=dag, # You need to repeat this for each task | |
) | |
run_this_first >> run_this_last |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# DAG with Context Manager | |
args = { | |
'owner': 'airflow', | |
'start_date': airflow.utils.dates.days_ago(2), | |
} | |
with DAG(dag_id='example_dag', default_args=args, schedule_interval='0 0 * * *') as dag: | |
run_this_last = DummyOperator( | |
task_id='run_this_last' | |
) | |
run_this_first = BashOperator( | |
task_id='run_this_first', | |
bash_command='echo 1' | |
) | |
run_this_first >> run_this_last |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment