Created
December 7, 2020 17:50
-
-
Save anilshanbhag/2b91583c67600793edad2f43de6fa8e0 to your computer and use it in GitHub Desktop.
Airflow Example
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
from datetime import datetime, timedelta | |
from airflow import DAG | |
from airflow.operators.dummy_operator import DummyOperator | |
from airflow.operators.python_operator import PythonOperator | |
def print_hello(): | |
return "Hello world!" | |
default_args = { | |
"owner": "airflow", | |
"depends_on_past": False, | |
"start_date": datetime(2019, 4, 30), | |
"email": ["[email protected]"], | |
"email_on_failure": False, | |
"email_on_retry": False, | |
"retries": 1, | |
"retry_delay": timedelta(minutes=2), | |
} | |
dag = DAG( | |
"hello_world", | |
description="Simple tutorial DAG", | |
schedule_interval="0 12 * * *", | |
default_args=default_args, | |
catchup=False, | |
) | |
t1 = DummyOperator(task_id="dummy_task", retries=3, dag=dag) | |
t2 = PythonOperator(task_id="hello_task", python_callable=print_hello, dag=dag) | |
# sets downstream foe t1 | |
t1 >> t2 | |
# equivalent | |
# t2.set_upstream(t1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment