Demo entry 6622932

airflow

   

Submitted by anonymous on Jun 06, 2017 at 21:00
Language: Python. Code size: 1.1 kB.

from airflow import DAG
from airflow.operators.bash_operator import BashOperator
from datetime import datetime, timedelta
default_args = {
    'owner': 'airflow',
    'depends_on_past': False,
    'start_date': datetime(2015, 6, 1),
    'email': ['airflow@airflow.com'],
    'email_on_failure': False,
    'email_on_retry': False,
    'retries': 1,
    'retry_delay': timedelta(minutes=5),
}

dag = DAG('My-Awesome-DAG', default_args=default_args)

# t1, t2 and t3 are examples of tasks created by instantiating operators
t1 = BashOperator(
    task_id='print_date',
    bash_command='date',
    dag=dag)

t2 = BashOperator(
    task_id='sleep',
    bash_command='sleep 5',
    retries=3,
    dag=dag)
t4 = BashOperator(
    task_id='bring-it-all-together-again',
    bash_command='sleep 5',
    dag=dag
    )

for x in xrange(1,10):
    t3 = BashOperator(
        task_id='hello-{0}'.format(str(x)),
        bash_command="echo HELLO",
        dag=dag)
    t3.set_upstream(t1)
    t3.set_downstream(t4)

t2.set_upstream(t1)

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).