Пример #1
0
#dags/latest_only_with_trigger.py
import datetime as dt

from airflow.models import DAG
from airflow.operators.dummy_operator import DummyOperator
from airflow.operators.latest_only_operator import LatestOnlyOperator
from airflow.utils.trigger_rule import TriggerRule

dag = DAG(
    dag_id='latest_only_with_trigger_with_doc',
    schedule_interval=dt.timedelta(hours=1),
    start_date=dt.datetime(2018, 6, 25),
)

dag.doc = "Hello Tony, what can I do for you?"
dag.doc_md = __doc__

latest_only = LatestOnlyOperator(task_id='latest_only', dag=dag)

task1 = DummyOperator(task_id='task1', dag=dag)
task1.set_upstream(latest_only)

task2 = DummyOperator(task_id='task2', dag=dag)

task3 = DummyOperator(task_id='task3', dag=dag)
task3.set_upstream([task1, task2])

task4 = DummyOperator(task_id='task4',
                      dag=dag,
                      trigger_rule=TriggerRule.ALL_DONE)
task4.set_upstream([task1, task2])
Пример #2
0
    'start_date': datetime(2017, 2, 1),
    'depends_on_past': False,
    'retries': 1,
    'retry_delay': timedelta(minutes=5),
}

##
## The DAG for the application audience job to run
##
dag = DAG(
    'sensor_dag_creation_inoperator',
    default_args=default_args,
    schedule_interval='*/5 * * * *'  # every five minutes
)

dag.doc = """
Simple http call which triggers when a row shows up in a database
"""


def response_check(response):
    """
    Dumps the http response and returns True when the http call status is 200/success
    """
    print("checking the reponse from the app")
    print(response.content)
    return response.status_code == 200


def process_new_accounts(ds, **kwargs):
    """