예제 #1
0
# -*- coding: utf-8 -*-

from __future__ import absolute_import, print_function, division, unicode_literals
from airflow import DAG
from airflow.operators import BranchPythonOperator, DummyOperator
from airflow.utils import chain
from datetime import datetime, timedelta
import random

yesterday = datetime.combine(datetime.today() - timedelta(7), datetime.min.time())

default_args = {
    'owner': 'airflow',
    'start_date': yesterday,
}

dag = DAG('aggregate', default_args=default_args)

t1 = DummyOperator(task_id='task1', dag=dag)
t2 = DummyOperator(task_id='task2', dag=dag)
t3 = DummyOperator(task_id='task3', dag=dag)

a1 = DummyOperator(task_id='aggregate', dag=dag)

chain(t1, a1)
chain(t2, a1)
chain(t3, a1)
예제 #2
0
# -*- coding: utf-8 -*-

from __future__ import absolute_import, print_function, division, unicode_literals
from airflow import DAG
from airflow.operators import DummyOperator
from airflow.utils import chain
from datetime import datetime, timedelta

yesterday = datetime.combine(datetime.today() - timedelta(7), datetime.min.time())

default_args = {
    'owner': 'airflow',
    'start_date': yesterday,
}

dag = DAG('sequence', default_args=default_args)

t1 = DummyOperator(task_id='task1', dag=dag)
t2 = DummyOperator(task_id='task2', dag=dag)
t3 = DummyOperator(task_id='task3', dag=dag)

chain(t1, t2, t3)
예제 #3
0
from airflow.operators import BranchPythonOperator, DummyOperator
from airflow.utils import chain
from datetime import datetime, timedelta
import random

yesterday = datetime.combine(datetime.today() - timedelta(7),
                             datetime.min.time())

default_args = {
    'owner': 'airflow',
    'start_date': yesterday,
}

dag = DAG('branch', default_args=default_args)

t1 = DummyOperator(task_id='task1', dag=dag)

b1 = DummyOperator(task_id='branch1', dag=dag)
b2 = DummyOperator(task_id='branch2', dag=dag)
b3 = DummyOperator(task_id='branch3', dag=dag)

select = BranchPythonOperator(
    task_id='select',
    python_callable=lambda: random.choice(['branch1', 'branch2', 'branch3']),
    dag=dag)

chain(t1, select)
chain(select, b1)
chain(select, b2)
chain(select, b3)
예제 #4
0
# -*- coding: utf-8 -*-

from __future__ import absolute_import, print_function, division, unicode_literals
from airflow import DAG
from airflow.operators import DummyOperator
from airflow.utils import chain
from datetime import datetime, timedelta

yesterday = datetime.combine(datetime.today() - timedelta(7), datetime.min.time())

default_args = {
    'owner': 'airflow',
    'start_date': yesterday
}

dag = DAG('distribute', default_args=default_args)

t1 = DummyOperator(task_id='task1', dag=dag)
t2 = DummyOperator(task_id='task2', dag=dag)
t3 = DummyOperator(task_id='task3', dag=dag)

chain(t1, t2)
chain(t1, t3)
예제 #5
0
# -*- coding: utf-8 -*-

from __future__ import absolute_import, print_function, division, unicode_literals
from airflow import DAG
from airflow.operators import DummyOperator, ShortCircuitOperator
from airflow.utils import chain
from datetime import datetime, timedelta

yesterday = datetime.combine(datetime.today() - timedelta(7), datetime.min.time())

default_args = {
    'owner': 'airflow',
    'start_date': yesterday,
}

dag = DAG('skip', default_args=default_args)

t1 = DummyOperator(task_id='task1', dag=dag)
t2 = DummyOperator(task_id='task2', dag=dag)
t3 = DummyOperator(task_id='task3', dag=dag)

cond_true = ShortCircuitOperator(task_id='cond_t', python_callable=lambda: True, dag=dag)
cond_false = ShortCircuitOperator(task_id='cond_f', python_callable=lambda: False, dag=dag)

chain(t1, cond_true, t2)
chain(t1, cond_false, t3)
예제 #6
0
# -*- coding: utf-8 -*-

from __future__ import absolute_import, print_function, division, unicode_literals
from airflow import DAG
from airflow.operators import DummyOperator
from airflow.utils import chain
from datetime import datetime, timedelta

yesterday = datetime.combine(datetime.today() - timedelta(7),
                             datetime.min.time())

default_args = {'owner': 'airflow', 'start_date': yesterday}

dag = DAG('distribute', default_args=default_args)

t1 = DummyOperator(task_id='task1', dag=dag)
t2 = DummyOperator(task_id='task2', dag=dag)
t3 = DummyOperator(task_id='task3', dag=dag)

chain(t1, t2)
chain(t1, t3)
예제 #7
0
from airflow.operators import BranchPythonOperator, DummyOperator
from airflow.utils import chain
from datetime import datetime, timedelta
import random

yesterday = datetime.combine(datetime.today() - timedelta(7), datetime.min.time())

default_args = {
    'owner': 'airflow',
    'start_date': yesterday,
}

dag = DAG('branch', default_args=default_args)

t1 = DummyOperator(task_id='task1', dag=dag)

b1 = DummyOperator(task_id='branch1', dag=dag)
b2 = DummyOperator(task_id='branch2', dag=dag)
b3 = DummyOperator(task_id='branch3', dag=dag)

select = BranchPythonOperator(
    task_id='select',
    python_callable=lambda: random.choice(['branch1', 'branch2', 'branch3']),
    dag=dag
)

chain(t1, select)
chain(select, b1)
chain(select, b2)
chain(select, b3)
예제 #8
0
# -*- coding: utf-8 -*-

from __future__ import absolute_import, print_function, division, unicode_literals
from airflow import DAG
from airflow.operators import DummyOperator
from airflow.utils import chain
from datetime import datetime, timedelta

yesterday = datetime.combine(datetime.today() - timedelta(7),
                             datetime.min.time())

default_args = {
    'owner': 'airflow',
    'start_date': yesterday,
}

dag = DAG('sequence', default_args=default_args)

t1 = DummyOperator(task_id='task1', dag=dag)
t2 = DummyOperator(task_id='task2', dag=dag)
t3 = DummyOperator(task_id='task3', dag=dag)

chain(t1, t2, t3)