One - One Code All

Blog Content

airflow中task之间传参数

Python 并行计算   2014-05-12 22:12:10


可以直接使用jinja模板语言,在{{}}中调用ti的xcom_push和xcom_pull方法,下面的例子为t1使用xcom_push推出了一个kv,t2通过taskid和key来接收

dag = DAG(
   dag_id='xcomtest', default_args=default_args, schedule_interval='*/2 * ** *')
 
t1 = BashOperator(
   task_id='xcom',
   bash_command='''{{ ti.xcom_push(key='aaa', value='bbb') }}''',
    dag=dag)
 
t2 = BashOperator(
   task_id='xcom2',
    bash_command='''echo"{{ ti.xcom_pull(key='aaa', task_ids='xcom') }}" ''',
    dag=dag)
t2.set_upstream(t1)


上一篇:双重移动平均线(Dual Moving Averages)
下一篇:linux中wget 断点续传

The minute you think of giving up, think of the reason why you held on so long.