测试使网络往返的单个DAG

时间:2018-12-11 23:29:56

标签: python-3.x airflow apache-airflow-xcom

我有一个任务,该任务从Azure读取文件列表,并将结果推送到XCOM。运算符特别是AzureDataLakeStorageListOperator。来源在这里:adls_list_operator.py

我想使用BashOperator之类的东西来打印此任务的输出,但是我不确定如何在本地执行此操作。据我所知,airflow test命令仅执行单个任务,因此在测试第二个任务时无法获得第一个任务的输出。

这是我的完整DAG:

from airflow import DAG
from airflow.contrib.operators.adls_list_operator import AzureDataLakeStorageListOperator
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': ['vishaalkal@gmail.com'],
    'email_on_failure': False,
    'email_on_retry': False,
    'retries': 1,
    'retry_delay': timedelta(minutes=5),
    # 'queue': 'bash_queue',
    # 'pool': 'backfill',
    # 'priority_weight': 10,
    # 'end_date': datetime(2016, 1, 1),
}

dag = DAG('adls', default_args=default_args,
          schedule_interval=timedelta(days=1))

# t1, t2 and t3 are examples of tasks created by instantiating operators
t1 = AzureDataLakeStorageListOperator(
    task_id='list_adls_files',
    path='reportdata/*.csv',
    dag=dag)

t2 = BashOperator(
    task_id='templated',
    bash_command='date; echo "{{ task_instance.xcom_pull("t1") }}"',
    dag=dag
)

t2.set_upstream(t1)

我相信我已经正确设置了身份验证,因为它以前给我AccessDenied个错误,但不再引发异常。

0 个答案:

没有答案