Last active
October 26, 2020 05:49
-
-
Save robert8138/c6e492d00cd7b7e7626670ba2ed32e6a to your computer and use it in GitHub Desktop.
A toy example DAG
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
""" | |
A DAG definition file in Airflow, written in Python. | |
""" | |
from datetime import datetime, timedelta | |
from airflow.models import DAG # Import the DAG class | |
from airflow.operators.bash_operator import BashOperator | |
from airflow.operators.sensors import TimeDeltaSensor | |
default_args = { | |
'owner': 'you', | |
'depends_on_past': False, | |
'start_date': datetime(2018, 1, 8), | |
} | |
dag = DAG( | |
dag_id='anatomy_of_a_dag', | |
description="This describes my DAG", | |
default_args=default_args, | |
schedule_interval=timedelta(days=1)) # This is a daily DAG. | |
# t0 and t1 are examples of tasks created by instantiating operators | |
t0 = TimeDeltaSensor( | |
task_id='wait_a_second', | |
delta=timedelta(seconds=1), | |
dag=dag) | |
t1 = BashOperator( | |
task_id='print_date_in_bash', | |
bash_command='date', | |
dag=dag) | |
t1.set_upstream(t0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment