Skip to content

Instantly share code, notes, and snippets.

@anilshanbhag
Created December 7, 2020 17:50
Show Gist options
  • Save anilshanbhag/2b91583c67600793edad2f43de6fa8e0 to your computer and use it in GitHub Desktop.
Save anilshanbhag/2b91583c67600793edad2f43de6fa8e0 to your computer and use it in GitHub Desktop.
Airflow Example
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": ["airflow@example.com"],
"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